cautotoolsautoconf

share AC_DEFINE trough AC_CONFIG_SUBDIRS in autoconf


I have two progrects using autoconf. Project A uses project B through AC_CONFIG_SUBDIRS()

project A configure.ac:

AC_CONFIG_SUBDIRS([projectb])

project B configure.ac:

AC_DEFINE([NEWDEFINE])

I would like to export the NEWDEFINE from project B to project A.

a.c:

#ifndef NEWDEFINE
#error NEWDEFINE not defined
#endif
$ autoreconf
$ ./configure
$ make
a.c:2:2: error: #error PTHREAD not defined
    2 | #error NEWDEFINE not defined
      |  ^~~~~

I want to view the NEWDEFINE in a.c of project A.


Solution

  • I would like to export the NEWDEFINE from project B to project A.

    AC_CONFIG_SUBDIRS is for configuring a bundled standalone project. The configuration of such a project is its own. If you're looking for an external macro of such a project, as built, then you will find it in one of the project's public headers, which the project A sources that need it should #include. Possibly a generated header.

    If the macro you want is not accessible that way then to a first approximation, it is not available at all. That is, project A's build should not be made dependent on internal build details of project B or any other separate project. Alternatives include:

    Any way around, you cannot get data generated by project B's configure into project A's configure when the former is run by the latter under control of AC_CONFIG_SUBDIRS. The structure and timing do not work for that.