Search code examples
autotoolsautoconfautomakem4

autotools: how to include my own m4 macro in configure.ac


In my project I have folder m4. In this folder I have ax_cxx_version.m4 file which contains AX_CHECK_CXXFLAGS macro.

Then I'm including m4 folder in autoconf.ac:

AC_CONFIG_MACRO_DIR([m4])

and executing autoconf.

When I'm running configure script it's failing with flowing error:

checking complex usability... yes
checking complex presence... yes
checking for complex... yes
checking size of int64_t... 8
checking for long long int... yes
./configure: line 7235: syntax error near unexpected token `-std=c++0x'
./configure: line 7235: `AX_CHECK_CXXFLAGS(-std=c++0x -pedantic -Wall)'

If I add my macro to aclocal.m4 then everything works perfectly well.

What is the correct way to include my own macro?


Solution

  • The problem is that AC_CONFIG_MACRO_DIR is not actually setting up the include path, but it's letting aclocal generate the right file. But aclocal is part of automake, and if you're just executing autoconf it won't be called.

    You can start calling autoreconf instead of autoconf to regenerate your files, and that should do the trick. Or if you don't want to depend on automake, you can use a number of other tricks with m4_include.

    Relevant (written by me) documentation on the matter is available on Autotools Mythbuster.