Brooks Moses <brooks <at> codesourcery.com> writes: > AC_INIT > AC_ARG_ENABLE(foo) > > if test "$enable_foo"; then > echo "enabled" > AC_PROG_CC([gcc]) > else > echo "disabled" > AC_PROG_CC > fi > ================================= > > This does not work correctly; > This is happening both with autoconf 2.59 and 2.61. I haven't checked > other versions. > > Is this a known bug? Is there a suggested workaround? This is a known 'feature' of autoconf. In general, invoking macros with side- effects inside of raw 'if' blocks is dangerous; there are two common failure scenarios - side effects happen regardless of whether the shell code containing the macro name is executed (because autoconf generates the side-effect code into a different m4 diversion), or, as in your case, side effects only happen on the first use of the macro (because autoconf AC_REQUIRE's the side-effect to avoid redundant output of one-shot initialization). You can try using AS_IF instead of raw shell 'if' for wrapping the AC_PROG_CC calls, since the purpose of AS_IF is to output a shell conditional AND correctly handle side effects of macros within that shell conditional. But in your case, the easiest thing to do is fix your autoconf.ac: AC_INIT AC_ARG_ENABLE(foo) AC_PROG_CC([gcc]) if test "$enable_foo"; then echo "enabled" else echo "disabled" fi -- Eric Blake _______________________________________________ Autoconf mailing list Autoconf@xxxxxxx http://lists.gnu.org/mailman/listinfo/autoconf