Search code examples
gccmakefileconfigureautoconf

Missing autoconf macro doesn't throw an error, but ./configure does


How can I make autogen.sh error if AX_CHECK_COMPILE_FLAG is missing?

I could just wget the .m4 file into the source tree and include it, is that a better option than giving an error?

Here are the details:

I just added AX_CHECK_COMPILE_FLAG(...) to my configure.ac and ran ./autogen.sh, which succeeded.

Because autoconf-archive wasn't installed, ./configure gave this error:

./configure: 5358: Syntax error: word unexpected (expecting ")")

the ./configure line at 5358 looks like this below because the macro didn't exist, so bourne shell died with the error above.

AX_CHECK_COMPILE_FLAG(-fcx-fortran-rules, CFLAGS="$CFLAGS -fcx-fortran-rules")


Solution

  • As a rule, when I use macros in configure.ac whose name begins with neither AC_ nor AM_, I make sure that autoconf treats those macro names occuring in the generated configure file as an error.

    In your case, that would be

    m4_pattern_forbid([AX_CHECK_COMPILE_FLAG])dnl
    AX_CHECK_COMPILE_FLAG([...what...], [...ever...])
    AX_CHECK_COMPILE_FLAG([...and...], [...more...])