Hello Dave, * Dave Goodell wrote on Thu, Feb 10, 2011 at 10:02:12PM CET: > I'm extremely confused about some behavior I recently encountered > while adding AM_CONDITIONAL and AM_COND_IF to my project. For some > reason m4/autoconf don't want to expand AM_COND_IF when I use it in a > particular fashion. Here's my configure.in: > > ----8<---- > AC_INIT([foo],[1.0]) > AM_INIT_AUTOMAKE([-Wall -Werror foreign 1.11 subdir-objects]) > LT_INIT([]) > AC_PROG_CC > #begin > var="yes" > AM_CONDITIONAL([COND],[test "$var" = "yes"]) > dnl this makes m4 bail, claiming that AM_COND_IF is undefined > m4_foreach([subsys_i],[[subconfigure]],[m4_include(subsys_i[.m4])]) > #end > AC_OUTPUT([Makefile]) > ----8<---- > > and here's subconfigure.m4: > > ----8<---- > # begin subconfigure.m4 > # this AM_COND_IF doesn't get expanded for some reason... > AM_COND_IF([COND],[echo COND is true],[echo COND is false]) > # end subconfigure.m4 > ----8<---- leading to: > autoreconf: running: /Users/goodell/prefix/bin/autoconf --force > configure.in:8: error: possibly undefined macro: AM_COND_IF > If this token and others are legitimate, please use m4_pattern_allow. > See the Autoconf documentation. > autoreconf: /Users/goodell/prefix/bin/autoconf failed with exit status: 1 Yep. This is a limitation in aclocal. You know, aclocal is a bit dumb sometimes. It doesn't understand that subconfigure.m4 is included by your configure.ac, thus doesn't see that AM_COND_IF might be needed, thus doesn't copy the definition of that macro into aclocal.m4. Then later, autoconf will protest about the unknown macro as you saw. aclocal currently uses a regex to match m4_include lines against configure.ac lines. That of course fails when the argument to m4_include contains a macro itself (subsys_i in your case). The Right Fix[tm] would probably be to let aclocal use m4 tracing (or ditch aclocal). Not sure if that could be done safely, when macro definitions are missing however. A workaround is to add a dummy use of AM_COND_IF somewhere in your configure.ac, so that it is pulled in by aclocal. Hope that helps. Cheers, Ralf _______________________________________________ Autoconf mailing list Autoconf@xxxxxxx http://lists.gnu.org/mailman/listinfo/autoconf