I have a sub-package setup in my autotools repository, in which several related projects are glued together using a master configure.ac and Makefile.am.
Aside from the compilation ordering, easily done via AC_CONFIG_SUBDIRS() macro, there is the need to export headers and library locations required between these excessively coupled sub-projects.
--- configure.ac
|- Makefile.am
|- subproj1 --- configure.ac
| |- Makefile.am
| |- src
| \- include
[...]
|
\- subprojN --- configure.ac // requires -I${top_srcdir}/subprojX/include and
|- Makefile.am // -L${top_srcdir}/subprojX/src
|- src
\- include
Regrouping these packages as one is not an option, unfortunately. I tried exporting variables using AC_SUBST() and/or make’s export command, for no avail.
The only way I could get these flags available into every sub-project Makefile was passing CPPFLAGS and LDFLAGS into the root configure invocation (via command-line). However, I’d hope if there is a way to keep these values inside autotools stuff, instead of having to create a separate script for them.
PS: similar to automake and project dependencies
The autotools are not really designed to be a package management system, so this is an awkward usage, but it is possible to reference relative paths outside of the build tree in the sub-projects. In other words, in subprojN/Makefile.am, you can add:
In this scenario, if subprojN/configure is trying to find libsubprojX, it will fail unless you instead add
../subprojX/{include,lib}to CPPFLAGS and LDFLAGS for configure, which can be done in configure.ac:If the configure scripts of the subprojects are not checking for the libraries in the coupled subprojects, it would probably be cleaner to specify LDADD in Makefile.am to get the necessary libraries linked.