automatic autotool invocation of aclocal

If your autoconfiscated project uses local autoconf macros, then the initial bootstrapping will involve running `aclocal -I path/to/local/m4/macros'.

This is all fine and dandy, but during development the autotools might have to regenerate the aclocal.m4 file. When this happens, aclocal will be run without the -I flag, resulting in undefined macros errors. How to fix them?

The fix consists of adding the following substitution to your

AC_SUBST(ACLOCAL_AMFLAGS, "-I path/to/local/m4/macros")

This will ensure that we aclocal is automatically invoked by make, it will be called with the specified -I flag.

However, I've grown used to running autoreconf instead of rerunning the bootstrap script or running each command individually.
Looking at the autoreconf script itself, I noticed that it scans the top-level for the following regexp:


and passes whatever is assigned to it as an argument to aclocal when autoreconfiguring.

Therefore, it is sufficient to add

ACLOCAL_AMFLAGS = -I path/to/local/m4/macros

to the top-level to have the autotools intelligently autoreconfiscate your project. No need to add a substitution to

This second solution has the advantage of working with both the boot the automatic remake and with autoreconf.