From 838238295952cc86e5ccfe59113e6c315cf640ec Mon Sep 17 00:00:00 2001 From: Stefano Lattarini Date: Sat, 10 Nov 2012 10:54:44 +0100 Subject: [PATCH] aclocal: trace AC_CONFIG_MACRO_DIR_TRACE This is now the documented way, and indeed the only correct way, to support AC_CONFIG_MACRO_DIR and AC_CONFIG_MACRO_DIRS in third-party tools. See autoconf commit v2.69-45-g5269030 of 2012-11-09, "AC_CONFIG_MACRO_DIRS: improve tracing and add sanity checks". * aclocal.in (trace_used_macros): Trace 'AC_CONFIG_MACRO_DIR_TRACE' rather than 'AC_CONFIG_MACRO_DIRS'. We still have to trace 'AC_CONFIG_MACRO_DIR' explicitly though, for compatibility with Autoconf versions before 2.70. * t/aclocal-macrodirs.tap: Enhance w.r.t. precedence of arguments in one and several AC_CONFIG_MACRO_DIRS calls. Signed-off-by: Stefano Lattarini --- aclocal.in | 23 ++++++++++++++++------- t/aclocal-macrodirs.tap | 45 +++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 57 insertions(+), 11 deletions(-) diff --git a/aclocal.in b/aclocal.in index 264ad75..d4e7000 100644 --- a/aclocal.in +++ b/aclocal.in @@ -738,8 +738,11 @@ sub trace_used_macros () 'AC_DEFUN_ONCE', 'AU_DEFUN', '_AM_AUTOCONF_VERSION', + # FIXME: We still need to trace AC_CONFIG_MACRO_DIR + # for compatibility with older autoconf. Remove this + # when we can assume Autoconf 2.70 or later. 'AC_CONFIG_MACRO_DIR', - 'AC_CONFIG_MACRO_DIRS')), + 'AC_CONFIG_MACRO_DIR_TRACE')), # Do not trace $1 for all other macros as we do # not need it and it might contains harmful # characters (like newlines). @@ -769,18 +772,24 @@ sub trace_used_macros () { $ac_version = $arg1; } - elsif ($macro eq 'AC_CONFIG_MACRO_DIR') + elsif ($macro eq 'AC_CONFIG_MACRO_DIR_TRACE') { - @ac_config_macro_dirs = ($arg1); + push @ac_config_macro_dirs, $arg1; } - elsif ($macro eq 'AC_CONFIG_MACRO_DIRS') + # FIXME: We still need to trace AC_CONFIG_MACRO_DIR + # for compatibility with older autoconf. Remove this + # when we can assume Autoconf 2.70 or later. + elsif ($macro eq 'AC_CONFIG_MACRO_DIR') { - # Empty leading/trailing fields might be produced by split, - # hence the grep is really needed. - push @ac_config_macro_dirs, grep (/./, (split /\s+/, $arg1)); + @ac_config_macro_dirs = ($arg1); } } + # FIXME: in Autoconf >= 2.70, AC_CONFIG_MACRO_DIR calls + # AC_CONFIG_MACRO_DIR_TRACE behind the scenes, which could + # leave unwanted duplicates in @ac_config_macro_dirs. + @ac_config_macro_dirs = uniq @ac_config_macro_dirs; + $tracefh->close; return %traced; diff --git a/t/aclocal-macrodirs.tap b/t/aclocal-macrodirs.tap index a443e50..28abb7c 100755 --- a/t/aclocal-macrodirs.tap +++ b/t/aclocal-macrodirs.tap @@ -26,7 +26,7 @@ am_create_testdir=empty END } || skip_all_ "autoconf doesn't define the AC_CONFIG_MACRO_DIRS macro" -plan_ 13 +plan_ 14 ocwd=$(pwd) || fatal_ "getting current working directory" ACLOCAL_PATH=; unset ACLOCAL_PATH @@ -119,7 +119,7 @@ three_dirs_check () #--------------------------------------------------------------------------- -test_begin "AC_CONFIG_MACRO_DIRS: several arguments" +test_begin "AC_CONFIG_MACRO_DIRS several arguments" cat > configure.ac <<'END' AC_INIT([more-args], [0.2]) @@ -135,7 +135,7 @@ test_end #--------------------------------------------------------------------------- -test_begin "AC_CONFIG_MACRO_DIRS: several calls" +test_begin "AC_CONFIG_MACRO_DIRS several calls" cat > configure.ac <<'END' AC_INIT([more-calls], [2.0]) @@ -152,7 +152,7 @@ test_end #--------------------------------------------------------------------------- -test_begin "AC_CONFIG_MACRO_DIRS: extra whitespace" +test_begin "AC_CONFIG_MACRO_DIRS extra whitespace" bslash=\\ @@ -174,6 +174,43 @@ test_end #--------------------------------------------------------------------------- +test_begin "AC_CONFIG_MACRO_DIRS precedence" + +cat > configure.ac <<'END' +AC_INIT([more-calls], [2.0]) +AC_CONFIG_MACRO_DIRS([dir1]) +AC_CONFIG_MACRO_DIRS([dir2 dir3]) +MY_FOO +MY_BAR +MY_BAZ +END + +mkdir dir1 dir2 dir3 +echo 'AC_DEFUN([MY_FOO], [OK-Foo])' > dir1/b.m4 +echo 'AC_DEFUN([MY_FOO], [KO-Foo])' > dir2/a.m4 +echo 'AC_DEFUN([MY_BAR], [OK-Bar])' > dir2/1.m4 +echo 'AC_DEFUN([MY_BAR], [KO-Bar])' > dir3/0.m4 +echo 'AC_DEFUN([MY_BAZ], [OK-Baz])' > dir3/x.m4 + +$ACLOCAL \ + && $FGREP 'm4_include([dir1/b.m4])' aclocal.m4 \ + && $FGREP 'm4_include([dir2/1.m4])' aclocal.m4 \ + && $FGREP 'm4_include([dir3/x.m4])' aclocal.m4 \ + && test $($FGREP -c 'm4_include([dir1' aclocal.m4) -eq 1 \ + && test $($FGREP -c 'm4_include([dir2' aclocal.m4) -eq 1 \ + && test $($FGREP -c 'm4_include([dir3' aclocal.m4) -eq 1 \ + && $AUTOCONF \ + && not $EGREP 'MY_(FOO|BAR|BAZ)' configure \ + && $FGREP 'OK-Foo' configure \ + && $FGREP 'OK-Bar' configure \ + && $FGREP 'OK-Baz' configure \ + && not $FGREP 'KO-' configure \ + || r='not ok' + +test_end + +#--------------------------------------------------------------------------- + test_begin "AC_CONFIG_MACRO_DIRS interaction with --install" cat > configure.ac << 'END' -- 2.7.4