Subject: bug#21352: AC_CONFIG_MACRO_DIRS vs. ACLOCAL_FLAGS: different behavior wrt AM_COND_IF, aclocal fails

From: Christian Rössel <[email-masked]>
Date: Wed, 26 Aug 2015 17:09:00 +0200

automake 1.15/1.13.4 (other versions not tested)
autoconf 2.69

Dear all,

'AC_CONFIG_MACRO_DIRS([m4])' is supposed to replace 'ACLOCAL_FLAGS = -I 
m4'. Just using AC_CONFIG_MACRO_DIRS works fine unless I have a 
AM_COND_IF in configure.ac that references a <conditional> which is not 
defined in configure.ac but in a m4 file that lives in subdirectory m4. 
In this case aclocal (via autoreconf) fails with

> error: AM_COND_IF: no such condition "<conditional>"

When using 'ACLOCAL_FLAGS = -I m4', autoreconf succeeds.

The difference between AC_CONFIG_MACRO_DIRS and ACLOCAL_FLAGS when 
running autoreconf is that the latter passes '-I m4' to aclocal, the 
former doesn't (but still finds the macros in the m4 subdirectory). As 
ACLOCAL_AMFLAGS will be fully deprecated in Automake 2.0, 
AC_CONFIG_MACRO_DIRS/aclocal needs IMO to be fixed (unfortunately I 
can't help on that).

To reproduce:

$ cat > configure.ac <<'END'
AC_INIT([foo], [0])
AC_CONFIG_MACRO_DIRS([m4])
AM_INIT_AUTOMAKE([-Wall foreign])
MY_FEATURE
AM_COND_IF([HAVE_MY_FEATURE], [echo "bingo"])
AC_CONFIG_FILES(Makefile)
AC_OUTPUT
END

$ cat > Makefile.am <<'END'
#ACLOCAL_FLAGS = -I m4
END

$ mkdir m4
cat > m4/my_feature.m4 <<'END'
AC_DEFUN([MY_FEATURE], [
AM_CONDITIONAL([HAVE_MY_FEATURE], [test 1 -eq 1])])
END

$ autoreconf -v --install
autoreconf: Entering directory `.'
autoreconf: configure.ac: not using Gettext
autoreconf: running: aclocal
configure.ac:5: error: AM_COND_IF: no such condition "HAVE_MY_FEATURE"
/opt/packages/afs-dev/01/share/aclocal-1.13/cond-if.m4:23: AM_COND_IF is 
expanded from...
configure.ac:5: the top level
autom4te: /opt/packages/afs-dev/01/bin/m4 failed with exit status: 1
aclocal: error: echo failed with exit status: 1
autoreconf: aclocal failed with exit status: 1

Best regards,
Christian
--