Discussion:
Getting AC_CONFIG_SUBDIRS output before AC_OUTPUT
Rhys Ulerich
2014-01-10 17:45:40 UTC
Permalink
Hi all,

I've got an autoconfiscated project and two subprojects where I'd like
to use AC_CONFIG_SUBDIRS. The subprojects configure scripts perform
some nontrivial checks, and dump their results into pkg-config files
sub1.pc and sub2.pc. The usual,
wait-until-AC_OUTPUT-to-invoke-subconfigure behavior won't generate
sub1.pc from sub1.pc.in until well after I need to snarf those
results.

I've done some reading on how Audacity tried doing this in the past
[1] but I'm unsure if a better pattern has arisen since then. In
particular, I notice that the hack [2] discussed in [1] doesn't cause
autoreconf to run on the subdirectories. This makes me think it is
broken.

I have tried issuing
AC_CONFIG_SUBDIRS([sub1])
AC_CONFIG_SUBDIRS([sub2])
_AC_OUTPUT_SUBDIRS
well before AC_OUTPUT in my configure.ac, which seems to solve the
autoreconf issue but it has the side-effect of configure being run
twice. First when _AC_OUTPUT_SUBDIRS is run and second when AC_OUTPUT
is encountered.

Is there some way to tell AC_OUTPUT that _AC_OUTPUT_SUBDIRS has
already been run? Possibly by redefining it to be empty?

I am way of manipulating $subdirs directly as [3] comments that
Makefiles can use $(subdirs).

The Audacity-related messages are quite old. Has a better pattern for
accomplishing this arisen in the meantime?

- Rhys

[1] http://lists.gnu.org/archive/html/autoconf/2008-05/msg00067.html
[2] http://audacity.googlecode.com/svn/audacity-src/trunk/m4/ax_config_dir.m4
[3] http://www.gnu.org/software/autoconf/manual/autoconf.html#Subdirectories
Rhys Ulerich
2014-01-10 18:21:10 UTC
Permalink
Post by Rhys Ulerich
Is there some way to tell AC_OUTPUT that _AC_OUTPUT_SUBDIRS has
already been run? Possibly by redefining it to be empty?
I am trying trickery like just setting 'no_recursion=yes' just before
AC_OUTPUT to suppress the recursion along with some checks to make
sure that subdirs hasn't changed in the meantime...

AC_CONFIG_SUBDIRS([sub1])
AC_CONFIG_SUBDIRS([sub2])
early_subdirs="$subdirs"
_AC_OUTPUT_SUBDIRS
dnl ...
dnl Arbitrary things
dnl ...
if test "$early_subdirs" != "$subdirs"; then
AC_MSG_ERROR([Sanity error: "$early_subdirs" became "$subdirs"])
fi
no_recursion=yes
AC_OUTPUT()

On a scale of hideous to grotesque, how bad is this approach?

- Rhys

Loading...