automake-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 1/3] aclocal: handle ACLOCAL_PATH environment variable


From: Paolo Bonzini
Subject: [PATCH 1/3] aclocal: handle ACLOCAL_PATH environment variable
Date: Tue, 9 Nov 2010 20:14:38 +0100

This updated patch passes the tests suggested by Stefano.  Considering
that Automake will rarely if ever be invoked from outside, MSYS, I stuck
with the colon as the sole separator for ACLOCAL_PATH.

The test suites leaves the user's ACLOCAL_PATH in place, for consistency
with the treatment of ${prefix}/share/aclocal/dirlist in tests/defs.in,
but overrides it in the two dedicated tests.

I needed to tweak the tests/aclocal.in script to avoid passing the
srcdir to -I (which happens if building in srcdir).  Otherwise, the
assumptions of the precedence tests in acloca25.test are not respected.

* NEWS: Document new behavior.
* aclocal.in (parse_arguments): Parse ACLOCAL_PATH as a colon-separated
list of directories to be included in the search path.
* doc/automake.texi (Macro Search Path): Document new behavior and
the precedence rules for various elements of the search path.
* tests/Makefile.am (TESTS): Add new testcases.
* tests/acloca24.test: New testcase.
* tests/acloca25.test: New testcase.
* tests/aclocal.in: Special-case in-srcdir build, so that -I is not used
if it brings in unwanted m4 files.
---
 ChangeLog           |   14 ++++++++++
 NEWS                |    6 ++++
 aclocal.in          |   22 ++++++++++++---
 doc/automake.texi   |   15 ++++++++++
 tests/Makefile.am   |    2 +
 tests/Makefile.in   |    2 +
 tests/acloca24.test |   56 +++++++++++++++++++++++++++++++++++++++
 tests/acloca25.test |   72 +++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/aclocal.in    |   14 +++++++---
 9 files changed, 195 insertions(+), 8 deletions(-)
 create mode 100755 tests/acloca24.test
 create mode 100755 tests/acloca25.test

diff --git a/ChangeLog b/ChangeLog
index 5fff04a..fa43c14 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2010-11-09  Paolo Bonzini  <address@hidden>
+
+       aclocal: handle ACLOCAL_PATH environment variable.
+       * NEWS: Document new behavior.
+       * aclocal.in (parse_arguments): Parse ACLOCAL_PATH as a colon-separated
+       list of directories to be included in the search path.
+       * doc/automake.texi (Macro Search Path): Document new behavior and
+       the precedence rules for various elements of the search path.
+       * tests/Makefile.am (TESTS): Add new testcases.
+       * tests/acloca24.test: New testcase.
+       * tests/acloca25.test: New testcase.
+       * tests/aclocal.in: Special-case in-srcdir build, so that -I is not used
+       if it brings in unwanted m4 files.
+
 2010-11-01  Ralf Wildenhues  <address@hidden>
 
        Add FAQ entry for bug reporting instructions.
diff --git a/NEWS b/NEWS
index c64ec14..9dd7860 100644
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,11 @@
 New in 1.11a:
 
+* Changes to aclocal:
+
+  - aclocal now interprets the `ACLOCAL_PATH' environment variable as a
+    colon-separated list of additional directories to search after
+    ${prefix}/share/aclocal-VERSION and before ${prefix}/share/aclocal.
+
 * Changes to automake:
 
   - automake now generates silenced rules for texinfo outputs.
diff --git a/aclocal.in b/aclocal.in
index 4c81a47..942d8e3 100644
--- a/aclocal.in
+++ b/aclocal.in
@@ -53,9 +53,10 @@ $perl_threads = 0;
 # Include paths for searching macros.  We search macros in this order:
 # user-supplied directories first, then the directory containing the
 # automake macros, and finally the system-wide directories for
-# third-party macro.  @user_includes can be augmented with -I.
-# @system_includes can be augmented with the `dirlist' file.  Also
-# --acdir will reset both @automake_includes and @system_includes.
+# third-party macros.  @user_includes can be augmented with -I.
+# @system_includes can be augmented with the `dirlist' file or
+# ACLOCAL_PATH.  Also --acdir will reset both @automake_includes
+# and @system_includes.
 my @user_includes = ();
 my @automake_includes = ("@datadir@/aclocal-$APIVERSION");
 my @system_includes = ('@datadir@/aclocal');
@@ -1025,7 +1026,7 @@ sub parse_arguments ()
     }
   else
     {
-      # Finally, adds any directory listed in the `dirlist' file.
+      # Add any directory listed in the `dirlist' file.
       if (open (DIRLIST, "$system_includes[0]/dirlist"))
        {
          while (<DIRLIST>)
@@ -1043,6 +1044,19 @@ sub parse_arguments ()
          close (DIRLIST);
        }
     }
+  # Add any directory listed in the `ACLOCAL_PATH' environment
+  # variable.
+  if (defined $ENV{"ACLOCAL_PATH"})
+    {
+      # Directories in ACLOCAL_PATH should take precedence over system
+      # directories, so we use unshift.  However, directories that
+      # come first in ACLOCAL_PATH take precedence over directories
+      # coming later, which is why the result of split is reversed.
+      foreach my $dir (reverse split /:/, $ENV{"ACLOCAL_PATH"})
+        {
+          unshift (@system_includes, $dir) if $dir ne '' && -d $dir;
+        }
+    }
 }
 
 ################################################################
diff --git a/doc/automake.texi b/doc/automake.texi
index 7214e49..9c548fd 100644
--- a/doc/automake.texi
+++ b/doc/automake.texi
@@ -3361,6 +3361,21 @@ Macro Search Path
 copy of Automake in your account and want @command{aclocal} to look for
 macros installed at other places on the system.
 
address@hidden Modifying the Macro Search Path: @file{ACLOCAL_PATH}
address@hidden @env{ACLOCAL_PATH}
+
+The fourth and last mechanism to customize the macro search path is
+also the simplest.  Any directory included in the colon-separated
+environment variable @env{ACLOCAL_PATH} is added to the search path
+and takes precedence over system directories (including those found
+via @file{dirlist}), with the exception of the versioned directory
address@hidden@var{prefix}/share/address@hidden  However, directories
+passed via @option{-I} will take precedence over directories in
+ACLOCAL_PATH.
+
+Conversely to @file{dirlist}, @env{ACLOCAL_PATH} is useful if you are
+using a global copy of Automake and want @command{aclocal} to look for
+macros somewhere under your home directory.
 
 @node Extending aclocal
 @subsection Writing your own aclocal macros
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 6673293..75c9886 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -77,6 +77,8 @@ acloca20.test \
 acloca21.test \
 acloca22.test \
 acloca23.test \
+acloca24.test \
+acloca25.test \
 acoutnoq.test \
 acoutpt.test \
 acoutpt2.test \
diff --git a/tests/Makefile.in b/tests/Makefile.in
index 3bc699f..dbecd4d 100644
--- a/tests/Makefile.in
+++ b/tests/Makefile.in
@@ -317,6 +317,8 @@ acloca20.test \
 acloca21.test \
 acloca22.test \
 acloca23.test \
+acloca24.test \
+acloca25.test \
 acoutnoq.test \
 acoutpt.test \
 acoutpt2.test \
diff --git a/tests/acloca24.test b/tests/acloca24.test
new file mode 100755
index 0000000..fe83a6e
--- /dev/null
+++ b/tests/acloca24.test
@@ -0,0 +1,56 @@
+#! /bin/sh
+# Copyright (C) 2010 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/>.
+
+# Check basic ACLOCAL_PATH support.
+
+. ./defs || Exit 1
+
+set -e
+
+cat >> configure.in << 'END'
+am__FOO_MACRO
+am__BAR_MACRO
+am__BAZ_MACRO
+END
+
+mkdir mdir1 mdir2 mdir3
+
+cat > mdir1/foo.m4 << 'END'
+AC_DEFUN([am__FOO_MACRO], [===foo===])
+END
+
+cat > mdir2/bar.m4 << 'END'
+AC_DEFUN([am__BAR_MACRO], [:::bar:::])
+END
+
+cat > mdir3/baz.m4 << 'END'
+AC_DEFUN([am__BAZ_MACRO], [%%%baz%%%])
+END
+
+ACLOCAL_PATH=mdir1:./mdir2:`pwd`/mdir3 $ACLOCAL
+$AUTOCONF
+
+# there should be no m4_include in aclocal.m4, even though ACLOCAL_PATH
+# contains `mdir1' and `./mdir2' as relative directories.  Only -I
+# directories should be subject to file inclusion.
+$FGREP m4_include aclocal.m4 && Exit 1
+
+$EGREP 'am__(FOO|BAR|BAZ)_MACRO' configure && Exit 1
+$FGREP '===foo===' configure
+$FGREP ':::bar:::' configure
+$FGREP '%%%baz%%%' configure
+
+:
diff --git a/tests/acloca25.test b/tests/acloca25.test
new file mode 100755
index 0000000..14c8892
--- /dev/null
+++ b/tests/acloca25.test
@@ -0,0 +1,72 @@
+#! /bin/sh
+# Copyright (C) 2010 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/>.
+
+# Check precedence rules for ACLOCAL_PATH.
+
+. ./defs || Exit 1
+
+set -e
+
+cat > configure.in <<END
+AC_INIT([$me], [1.0])
+AM_INIT_AUTOMAKE([blablabla])
+FOO_MACRO
+BAR_MACRO
+END
+
+mkdir mdir1 mdir2 mdir3
+
+cat > mdir1/foo.m4 << 'END'
+AC_DEFUN([FOO_MACRO], [==PASS-FOO==])
+END
+
+cat > mdir2/foo.m4 << 'END'
+AC_DEFUN([FOO_MACRO], [!!FAIL-FOO!!])
+END
+
+cat > mdir1/bar.m4 << 'END'
+AC_DEFUN([BAR_MACRO], [//FAIL-BAR//])
+END
+
+cat > mdir3/baz.m4 << 'END'
+AC_DEFUN([BAR_MACRO], [~~PASS-BAR~~])
+END
+
+cat > mdir2/quux.m4 << 'END'
+AC_DEFUN([AM_INIT_AUTOMAKE], [%%$1%%])
+END
+
+ACLOCAL_PATH=mdir1:mdir2 $ACLOCAL -I mdir3
+$AUTOCONF
+
+# Directories coming first in ACLOCAL_PATH should take precedence.
+$FGREP '==PASS-FOO==' configure
+$FGREP '!!FAIL-FOO!!' configure && Exit 1
+# Directories from `-I' options should take precedence over directories
+# in ACLOCAL_PATH.
+$FGREP '~~PASS-BAR~~' configure
+$FGREP '//FAIL-BAR//' configure && Exit 1
+# Directories in ACLOCAL_PATH should take precedence over system
+# directories, typically ${prefix}/share/aclocal.  Note that directories
+# in ACLOCAL_PATH do _not_ take precedence over the internal automake
+# directory ${prefix}/share/aclocal-VERSION, and AM_INIT_AUTOMAKE would
+# normally be found there; however, the testsuite is run with --acdir,
+# so the place of ${srcdir}/m4 in the search path is exactly what
+# ACLOCAL_PATH overrides.
+$FGREP '%%blablabla%%' configure
+
+:
+
diff --git a/tests/aclocal.in b/tests/aclocal.in
index 35b1619..a285cf5 100644
--- a/tests/aclocal.in
+++ b/tests/aclocal.in
@@ -12,7 +12,13 @@ fi
 
 perllibdir="@abs_top_builddir@/address@hidden@@abs_top_srcdir@/lib"
 export perllibdir
-# Most of the files are in $srcdir/../m4.  However amversion.m4 is
-# generated in ../m4, so we include that directory in the search path too.
-exec "@abs_top_builddir@/aclocal" $ACLOCAL_TESTSUITE_FLAGS \
-     -I "@abs_top_builddir@/m4" "address@hidden@/m4" ${1+"$@"}
+if test "@abs_top_srcdir@" = "@abs_top_builddir@"; then
+  # Ensure @abs_top_srcdir@/m4 does not end up in the user search path.
+  exec "@abs_top_builddir@/aclocal" $ACLOCAL_TESTSUITE_FLAGS \
+       "address@hidden@/m4" ${1+"$@"}
+else
+  # Most of the files are in $srcdir/../m4.  However amversion.m4 is
+  # generated in ../m4, so we include that directory in the search path too.
+  exec "@abs_top_builddir@/aclocal" $ACLOCAL_TESTSUITE_FLAGS \
+       -I "@abs_top_builddir@/m4" "address@hidden@/m4" ${1+"$@"}
+fi
-- 
1.7.3.2





reply via email to

[Prev in Thread] Current Thread [Next in Thread]