summaryrefslogtreecommitdiff
path: root/t/subpkg-macrodir.sh
diff options
context:
space:
mode:
authorStefano Lattarini <stefano.lattarini@gmail.com>2012-07-04 15:23:50 +0200
committerStefano Lattarini <stefano.lattarini@gmail.com>2012-11-10 10:04:17 +0100
commitd2155d50e6ef6d11845583af0113a717642f53df (patch)
treeb1237ba2408665404ef3c439a9c30e95daa9796f /t/subpkg-macrodir.sh
parent2296a5e1fbe39415111ad5fdce475fe49897233d (diff)
downloadautomake-d2155d50e6ef6d11845583af0113a717642f53df.tar.gz
aclocal: multiple local m4 macro dirs with AC_CONFIG_MACRO_DIRS
A new macro 'AC_CONFIG_MACRO_DIRS' has been recently introduced in autoconf (and is expected to appear in the autoconf 2.70 release), allowing us to declare several local m4 macro directories for a package. It can be done either passing several arguments to a single invocation: AC_CONFIG_MACRO_DIRS([dir1 dir2]) or issuing more invocations: AC_CONFIG_MACRO_DIRS([dir1]) AC_CONFIG_MACRO_DIRS([dir2]) or a combination of the two: AC_CONFIG_MACRO_DIRS([dir1 dir2]) AC_CONFIG_MACRO_DIRS([dir3]) This will allow projects to use several m4 macro local dirs, without the need to use ACLOCAL_AMFLAGS (which we want to make obsolete and finally remove). This is especially important for projects that are used as nested subpackages of larger projects. For more information and rationales, refer to these past discussions: <http://lists.gnu.org/archive/html/autoconf/2011-12/msg00037.html> <http://lists.gnu.org/archive/html/automake-patches/2012-07/msg00010.html> <http://lists.gnu.org/archive/html/autoconf-patches/2012-07/msg00000.html> <http://lists.gnu.org/archive/html/autoconf-patches/2012-07/msg00012.html> <http://thread.gmane.org/gmane.comp.sysutils.autoconf.patches/8037/> <http://thread.gmane.org/gmane.comp.sysutils.autoconf.patches/8087> <http://thread.gmane.org/gmane.comp.sysutils.automake.patches/8956> as well as to Automake commit v1.12.1-165-gcd1a9cc of 2012-07-03, "aclocal: deprecate ACLOCAL_AMFLAGS, trace AC_CONFIG_MACRO_DIR instead", autoconf commit v2.69-42-gd73770f of 2012-10-17, "AC_CONFIG_MACRO_DIRS: new macro, mostly for aclocal". * aclocal.in ($ac_config_macro_dir): Turn this global scalar it into ... (@ac_config_macro_dirs): ... this global array. (trace_used_macros): Update '@ac_config_macro_dirs' instead of re-defining '$ac_config_macro_dir'. Cater to calls the now-preferred macro 'AC_CONFIG_MACRO_DIRS' in addition to the "obsolescent" one AC_CONFIG_MACRO_DIR. (main loop): Append '@ac_config_macro_dirs', not '$ac_config_macro_dir', to '@user_includes'. * t/subpkg-macrodir.sh: New test. * t/aclocal-macrodirs.tap: Likewise. * t/list-of-tests.mk: Add them. * t/aclocal-macrodir.tap: Adjust and extend a little to keep it more in sync with 'aclocal-macrodirs.tap'. Signed-off-by: Stefano Lattarini <stefano.lattarini@gmail.com>
Diffstat (limited to 't/subpkg-macrodir.sh')
-rwxr-xr-xt/subpkg-macrodir.sh93
1 files changed, 93 insertions, 0 deletions
diff --git a/t/subpkg-macrodir.sh b/t/subpkg-macrodir.sh
new file mode 100755
index 000000000..275af0d64
--- /dev/null
+++ b/t/subpkg-macrodir.sh
@@ -0,0 +1,93 @@
+#! /bin/sh
+# Copyright (C) 2002-2012 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Subpackages that want to use m4 macros from their superpackages,
+# with AC_CONFIG_MACRO_DIRS.
+
+. test-init.sh
+
+{ $AUTOCONF -o /dev/null - <<END
+ AC_INIT([x], [0])
+ AC_CONFIG_MACRO_DIRS([.])
+END
+} || skip_ "autoconf doesn't define the AC_CONFIG_MACRO_DIRS macro"
+
+cat > configure.ac <<'END'
+AC_INIT([super], [1.0])
+AM_INIT_AUTOMAKE
+AC_CONFIG_MACRO_DIR([m4])
+AC_CONFIG_SUBDIRS([pkg])
+AX_BAR
+AX_FOO
+END
+
+mkdir m4
+
+cat > m4/foo.m4 <<'EOF'
+AC_DEFUN([AX_FOO], [
+ AC_CONFIG_FILES([Makefile])
+ AC_OUTPUT
+])
+EOF
+
+cat > m4/bar.m4 <<'EOF'
+AC_DEFUN([AX_BAR], [AC_SUBST([WHOMAI], [SuperPkg])])
+EOF
+
+cat > Makefile.am << 'END'
+test-whomai:
+ test '$(WHOAMI)' = SuperPkg
+check-local: test
+.PHONY: test
+END
+
+mkdir pkg
+
+cat > pkg/configure.ac <<'END'
+AC_INIT([super], [1.0])
+AM_INIT_AUTOMAKE
+AC_CONFIG_MACRO_DIRS([macros ../m4])
+AX_BAR
+AX_FOO
+END
+
+mkdir pkg/macros
+cat > pkg/macros/zardoz.m4 << 'END'
+AC_DEFUN([AX_BAR], [AC_SUBST([WHOMAI], [sub-pkg])])
+END
+
+cat > pkg/Makefile.am << 'END'
+test-whomai:
+ test '$(WHOAMI)' = sub-pkg
+check-local: test
+.PHONY: test
+END
+
+AUTOMAKE=$AUTOMAKE ACLOCAL=$ACLOCAL AUTOCONF=$AUTOCONF $AUTORECONF -vi
+
+$FGREP 'm4_include([m4/foo.m4])' aclocal.m4
+$FGREP 'm4_include([m4/bar.m4])' aclocal.m4
+$FGREP 'm4_include([../m4/foo.m4])' pkg/aclocal.m4
+$FGREP 'm4_include([macros/zardoz.m4])' pkg/aclocal.m4
+
+./configure
+
+$MAKE test
+(cd pkg && $MAKE test) || exit 1
+
+$MAKE distcheck
+
+: