automake-patches
[Top][All Lists]
Advanced

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

[PATCH] aclocal: handle ACLOCAL_PATH environment variable


From: Stefano Lattarini
Subject: [PATCH] aclocal: handle ACLOCAL_PATH environment variable
Date: Mon, 19 Sep 2011 18:05:39 +0200
User-agent: KMail/1.13.7 (Linux/2.6.30-2-686; KDE/4.6.5; i686; ; )

Resurrecting the old thread "Add ACLOCAL_PATH to aclocal"; references:
 <http://lists.gnu.org/archive/html/automake-patches/2010-11/msg00089.html>
 <http://thread.gmane.org/gmane.comp.sysutils.automake.patches/4972>

I really want the ACLOCAL_PATH feature to end up in 1.11.2, which I hope we
will be able to release in a few weeks.  The test cases I've added should
IMHO ough to show that the new feature is solid enough and interacts nicely
with the pre-existing aclocal features.  The documentation could probably
be improved, but that can easily be done at a later moment.

I'll push the attached patch in 72 hours if there is no review by then.

Paolo, since it's you who have written the previous version of this patch,
from which I've drawn heavily, are you ok to be listed as the main author
in the ChangeLog entry, and in the "Author" field of the git commit?

Thanks,
  Stefano
From e913815f1e074d358ee01ac774ea48f23f5c2133 Mon Sep 17 00:00:00 2001
Message-Id: <address@hidden>
From: Paolo Bonzini <address@hidden>
Date: Tue, 9 Nov 2010 20:14:38 +0100
Subject: [PATCH] aclocal: handle ACLOCAL_PATH environment variable

* aclocal.in (parse_ACLOCAL_PATH): New function, 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/aclocal-path.test: New test.
* tests/aclocal-path-install.test: Likewise.
* tests/aclocal-path-install-serial.test: Likewise.
* tests/aclocal-path-precedence.test: Likewise.
* tests/aclocal-path-nonexistent.test: Likewise.
* tests/Makefile.am (TESTS): Add them.
* NEWS: Update.
* tests/distcheck-missing-m4.test: Extend by also checking
interactions with ACLOCAL_PATH.
* tests/distcheck-outdated-m4.test: Likewise, and fix a couple
of botched comments since we are at it.
---
 ChangeLog                              |   21 +++++++
 NEWS                                   |    5 ++
 aclocal.in                             |   21 +++++++-
 doc/automake.texi                      |   24 ++++++++
 tests/Makefile.am                      |    5 ++
 tests/Makefile.in                      |    5 ++
 tests/aclocal-path-install-serial.test |   86 +++++++++++++++++++++++++++++
 tests/aclocal-path-install.test        |   55 +++++++++++++++++++
 tests/aclocal-path-nonexistent.test    |   36 ++++++++++++
 tests/aclocal-path-precedence.test     |   93 ++++++++++++++++++++++++++++++++
 tests/aclocal-path.test                |   58 ++++++++++++++++++++
 tests/distcheck-missing-m4.test        |   27 +++++++---
 tests/distcheck-outdated-m4.test       |   51 ++++++++++++++++-
 13 files changed, 474 insertions(+), 13 deletions(-)
 create mode 100755 tests/aclocal-path-install-serial.test
 create mode 100755 tests/aclocal-path-install.test
 create mode 100755 tests/aclocal-path-nonexistent.test
 create mode 100755 tests/aclocal-path-precedence.test
 create mode 100755 tests/aclocal-path.test

diff --git a/ChangeLog b/ChangeLog
index 8a697e6..ff242df 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,24 @@
+2011-09-19 Paolo Bonzini  <address@hidden>
+          Stefano Lattarini  <address@hidden>
+
+       aclocal: handle ACLOCAL_PATH environment variable
+       * aclocal.in (parse_ACLOCAL_PATH): New function, 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/aclocal-path.test: New test.
+       * tests/aclocal-path-install.test: Likewise.
+       * tests/aclocal-path-install-serial.test: Likewise.
+       * tests/aclocal-path-precedence.test: Likewise.
+       * tests/aclocal-path-nonexistent.test: Likewise.
+       * tests/Makefile.am (TESTS): Add them.
+       * NEWS: Update.
+       * tests/distcheck-missing-m4.test: Extend by also checking
+       interactions with ACLOCAL_PATH.
+       * tests/distcheck-outdated-m4.test: Likewise, and fix a couple
+       of botched comments since we are at it.
+
 2011-09-18  Stefano Lattarini  <address@hidden>
 
        java: complain if java_JAVA is used but $(javadir) is undefined
diff --git a/NEWS b/NEWS
index 9d3f46d..f9fa959 100644
--- a/NEWS
+++ b/NEWS
@@ -13,6 +13,11 @@ New in 1.11.0a:
   - The `--acdir' option is deprecated.  Now you should use th new options
     `--automake-acdir' and `--system-acdir' instead.
 
+  - The `ACLOCAL_PATH' environment variable is now interpreted as a
+    colon-separated list of additional directories to search after the
+    automake internal acdir (by default ${prefix}/share/aclocal-APIVERSION)
+    and before the system acdir (by default ${prefix}/share/aclocal).
+
 * Miscellaneous changes:
 
   - The `lzma' compression scheme and associated automake option `dist-lzma'
diff --git a/aclocal.in b/aclocal.in
index ce77e1d..2ae9a89 100644
--- a/aclocal.in
+++ b/aclocal.in
@@ -57,8 +57,9 @@ $perl_threads = 0;
 # third-party macros.
 # @user_includes can be augmented with -I.
 # @automake_includes can be reset with the `--automake-acdir' option.
-# @system_includes can be augmented with the `dirlist' file, and reset
-# with the `--system-acdir' option.
+# @system_includes can be augmented with the `dirlist' file or the
+# ACLOCAL_PATH environment variable, and reset with the `--system-acdir'
+# option.
 my @user_includes = ();
 my @automake_includes = ("@datadir@/aclocal-$APIVERSION");
 my @system_includes = ('@datadir@/aclocal');
@@ -1046,10 +1047,26 @@ sub parse_arguments ()
     }
 }
 
+# Add any directory listed in the `ACLOCAL_PATH' environment variable
+# to the list of system include directories.
+sub parse_ACLOCAL_PATH ()
+{
+  return if not 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;
+    }
+}
+
 ################################################################
 
 parse_WARNINGS;                    # Parse the WARNINGS environment variable.
 parse_arguments;
+parse_ACLOCAL_PATH;
 $configure_ac = require_configure_ac;
 
 # We may have to rerun aclocal if some file have been installed, but
diff --git a/doc/automake.texi b/doc/automake.texi
index bf2c872..44778c3 100644
--- a/doc/automake.texi
+++ b/doc/automake.texi
@@ -3430,6 +3430,30 @@ Similarly, @file{dirlist} can be handy if you have 
installed a local
 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
address@hidden Keep in sync with aclocal-path-precedence.test.
+and takes precedence over system directories (including those found via
address@hidden), with the exception of the versioned directory
address@hidden (@pxref{Macro Search Path}).  However, directories
+passed via @option{-I} will take precedence over directories in
address@hidden
+
address@hidden Keep in sync with aclocal-path-installed.test.
+Also note that, if the @option{--install} option is used, any @file{.m4}
+file containing a required macro that is found in a directory listed in
address@hidden will be installed locally.
address@hidden Keep in sync with aclocal-path-installed-serial.test.
+In this case, serial numbers in @file{.m4} are honoured too,
address@hidden
+
+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 6c7139d..1d258c9 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -74,6 +74,11 @@ acloca21.test \
 acloca22.test \
 aclocal-acdir.test \
 aclocal-print-acdir.test \
+aclocal-path.test \
+aclocal-path-install.test \
+aclocal-path-install-serial.test \
+aclocal-path-nonexistent.test \
+aclocal-path-precedence.test \
 acoutnoq.test \
 acoutpt.test \
 acoutpt2.test \
diff --git a/tests/Makefile.in b/tests/Makefile.in
index ab73658..7e9bc20 100644
--- a/tests/Makefile.in
+++ b/tests/Makefile.in
@@ -352,6 +352,11 @@ acloca21.test \
 acloca22.test \
 aclocal-acdir.test \
 aclocal-print-acdir.test \
+aclocal-path.test \
+aclocal-path-install.test \
+aclocal-path-install-serial.test \
+aclocal-path-nonexistent.test \
+aclocal-path-precedence.test \
 acoutnoq.test \
 acoutpt.test \
 acoutpt2.test \
diff --git a/tests/aclocal-path-install-serial.test 
b/tests/aclocal-path-install-serial.test
new file mode 100755
index 0000000..15b4204
--- /dev/null
+++ b/tests/aclocal-path-install-serial.test
@@ -0,0 +1,86 @@
+#! /bin/sh
+# Copyright (C) 2011 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/>.
+
+# ACLOCAL_PATH, acdir and `--install' interactions when serial number
+# are involved.
+
+am_create_testdir=empty
+. ./defs || Exit 1
+
+set -e
+
+cat > configure.in << 'END'
+AC_INIT
+AM_FOO
+END
+
+set_serial ()
+{
+  serial=$1 file=$2
+  sed '/^# serial/d' $file > t
+  case $serial in
+    none) mv -f t $file;;
+       *) (echo "# serial $serial" && cat t) > $file; rm -f t;;
+  esac
+  cat $file # For debugging.
+}
+
+win ()
+{
+  case $1 in
+    sdir) ok=sdir ko=pdir;;
+    pdir) ok=pdir ko=sdir;;
+       *) fatal_ "win(): invalud argument \`$1'";;
+  esac
+  rm -rf aclocal.m4 autom4te*.cache m4/*
+  $ACLOCAL -I m4 --install
+  test -f m4/foo.m4 # Sanity check.
+  $AUTOCONF
+  $FGREP "::$ok:"  m4/foo.m4
+  $FGREP "::$ok::" configure
+  $FGREP "::$ko::" m4/foo.m4 configure && Exit 1
+  :
+}
+
+mkdir sdir pdir m4
+
+ACLOCAL="$ACLOCAL --system-acdir=`pwd`/sdir"
+ACLOCAL_PATH=./pdir; export ACLOCAL_PATH
+
+cat > sdir/foo.m4 << 'END'
+AC_DEFUN([AM_FOO], [::sdir::])
+END
+cat > pdir/foo.m4 << 'END'
+AC_DEFUN([AM_FOO], [::pdir::])
+END
+
+set_serial 2 sdir/foo.m4
+set_serial 1 pdir/foo.m4
+win sdir
+
+set_serial 3.3 sdir/foo.m4
+set_serial 5.7 pdir/foo.m4
+win pdir
+
+set_serial 0    sdir/foo.m4
+set_serial none pdir/foo.m4
+win sdir
+
+set_serial none  sdir/foo.m4
+set_serial 1.2.3 pdir/foo.m4
+win pdir
+
+:
diff --git a/tests/aclocal-path-install.test b/tests/aclocal-path-install.test
new file mode 100755
index 0000000..5e46eb6
--- /dev/null
+++ b/tests/aclocal-path-install.test
@@ -0,0 +1,55 @@
+#! /bin/sh
+# Copyright (C) 2011 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/>.
+
+# ACLOCAL_PATH and `--install' interactions.
+
+am_create_testdir=empty
+. ./defs || Exit 1
+
+set -e
+
+cat > configure.in << 'END'
+AC_INIT
+AM_FOO
+END
+
+mkdir acdir pdir ldir
+
+ACLOCAL="$ACLOCAL --system-acdir=`pwd`/acdir"
+ACLOCAL_PATH=./pdir; export ACLOCAL_PATH
+
+cat > acdir/foo.m4 << 'END'
+AC_DEFUN([AM_FOO], [:])
+END
+
+cat > pdir/bar.m4 << 'END'
+AC_DEFUN([AM_BAR], [:])
+END
+
+# The `--install' option should never cause anything to be installed
+# in a directory specified in ACLOCAL_PATH.
+$ACLOCAL --install 2>stderr && { cat stderr >&2; Exit 1; }
+cat stderr >&2
+grep ' no -I was supplied' stderr
+test ! -f pdir/foo.m4
+
+# The `--install' option should cause a required macro found in a
+# directory specified in ACLOCAL_PATH to be installed locally.
+echo AM_BAR >> configure.in
+$ACLOCAL --install -I ldir
+diff pdir/bar.m4 ldir/bar.m4
+
+:
diff --git a/tests/aclocal-path-nonexistent.test 
b/tests/aclocal-path-nonexistent.test
new file mode 100755
index 0000000..e1157a1
--- /dev/null
+++ b/tests/aclocal-path-nonexistent.test
@@ -0,0 +1,36 @@
+#! /bin/sh
+# Copyright (C) 2011 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/>.
+
+# Non-existent directories in ACLOCAL_PATH are ok.
+
+am_create_testdir=empty
+. ./defs || Exit 1
+
+set -e
+
+cat > configure.in << 'END'
+AC_INIT
+AM_FOO
+END
+
+mkdir mdir
+echo 'AC_DEFUN([AM_FOO], [am--foo])' > mdir/foo.m4
+
+ACLOCAL_PATH=./nonesuch:./mdir:`pwd`/nonesuch2:nonesuch3 $ACLOCAL
+$AUTOCONF
+$FGREP 'am--foo' configure
+
+:
diff --git a/tests/aclocal-path-precedence.test 
b/tests/aclocal-path-precedence.test
new file mode 100755
index 0000000..0378fb2
--- /dev/null
+++ b/tests/aclocal-path-precedence.test
@@ -0,0 +1,93 @@
+#! /bin/sh
+# Copyright (C) 2011 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.
+
+am_create_testdir=empty
+. ./defs || Exit 1
+
+set -e
+
+cat >> configure.in << 'END'
+AC_INIT
+AM_INIT_AUTOMAKE([parallel-tests])
+FOO_MACRO
+BAR_MACRO
+AC_PROG_LIBTOOL
+AM_GNU_GETTEXT
+END
+
+mkdir mdir1 mdir2 mdir3 sysdir extradir
+
+cat > mdir1/foo1.m4 << 'END'
+AC_DEFUN([FOO_MACRO], [::pass-foo::])
+END
+
+cat > mdir2/foo2.m4 << 'END'
+AC_DEFUN([FOO_MACRO], [::fail-foo::])
+END
+
+cat > mdir1/baz.m4 << 'END'
+AC_DEFUN([BAR_MACRO], [::fail-bar::])
+END
+
+cat > mdir3/bar.m4 << 'END'
+AC_DEFUN([BAR_MACRO], [::pass-bar::])
+END
+
+cat > mdir2/quux.m4 << 'END'
+AC_DEFUN([AM_INIT_AUTOMAKE], [::fail-init::])
+AC_DEFUN([AC_PROG_LIBTOOL],  [::pass-libtool::])
+AC_DEFUN([AM_GNU_GETTEXT],   [::pass-gettext::])
+END
+
+cat > sysdir/libtool.m4 << 'END'
+AC_DEFUN([AC_PROG_LIBTOOL], [::fail-libtool::])
+END
+
+cat > extradir/gettext.m4 << 'END'
+AC_DEFUN([AM_GNU_GETTEXT], [::fail-gettext::])
+END
+
+echo ./extradir > sysdir/dirlist
+
+ACLOCAL_PATH=mdir1:mdir2 $ACLOCAL -I mdir3
+$AUTOCONF
+
+$FGREP '::' configure # For debugging.
+
+# Directories coming first in ACLOCAL_PATH should take precedence
+# over those coming later.
+$FGREP '::pass-foo::' configure
+
+# Directories from `-I' options should take precedence over directories
+# in ACLOCAL_PATH.
+$FGREP '::pass-bar::' configure
+
+# Directories in ACLOCAL_PATH should take precedence over system acdir
+# (typically `${prefix}/share/aclocal'), and any directory added through
+# the `dirlist' special file.
+$FGREP '::pass-gettext::' configure
+$FGREP '::pass-libtool::' configure
+
+# Directories in ACLOCAL_PATH shouldn't take precedence over the internal
+# automake acdir (typically `${prefix}/share/aclocal-${APIVERSION}').
+$FGREP 'am__api_version' configure
+
+# A final sanity check.
+$FGREP '::fail' configure && Exit 1
+
+:
diff --git a/tests/aclocal-path.test b/tests/aclocal-path.test
new file mode 100755
index 0000000..16fd3f9
--- /dev/null
+++ b/tests/aclocal-path.test
@@ -0,0 +1,58 @@
+#! /bin/sh
+# Copyright (C) 2011 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.
+
+am_create_testdir=empty
+. ./defs || Exit 1
+
+set -e
+
+cat > configure.in << 'END'
+AC_INIT
+AM_FOO_MACRO
+AM_BAR_MACRO
+AM_BAZ_MACRO
+END
+
+mkdir mdir1 mdir2 mdir3
+
+cat > mdir1/foo.m4 << 'END'
+AC_DEFUN([AM_FOO_MACRO], [am--foo])
+END
+
+cat > mdir2/bar.m4 << 'END'
+AC_DEFUN([AM_BAR_MACRO], [am--bar])
+END
+
+cat > mdir3/baz.m4 << 'END'
+AC_DEFUN([AM_BAZ_MACRO], [am--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 'am--foo' configure
+$FGREP 'am--bar' configure
+$FGREP 'am--baz' configure
+
+:
diff --git a/tests/distcheck-missing-m4.test b/tests/distcheck-missing-m4.test
index f4e0eda..1a2b62f 100755
--- a/tests/distcheck-missing-m4.test
+++ b/tests/distcheck-missing-m4.test
@@ -39,9 +39,10 @@ AC_OUTPUT
 MY_FOO
 MY_BAR
 MY_BAZ
+MY_ZAR
 END
 
-mkdir m4 acdir acdir1 acdir2
+mkdir m4 acdir acdir1 acdir2 pth
 
 cat > acdir/dirlist << END
 $cwd/acdir1
@@ -52,21 +53,25 @@ echo 'AC_DEFUN([MY_FOO], [:])' > m4/foo.m4
 echo 'AC_DEFUN([MY_BAR], [:])' > acdir1/bar.m4
 echo 'AC_DEFUN([MY_BAZ], [:])' > acdir1/baz.m4
 echo 'AC_DEFUN([MY_QUX], [:])' > acdir2/qux.m4
+echo 'AC_DEFUN([MY_ZAR], [:])' > pth/zar.m4
+echo 'AC_DEFUN([MY_BLA], [:])' > pth/bla.m4
 
 ACLOCAL="$ACLOCAL --system-acdir=$cwd/acdir"; export ACLOCAL
+ACLOCAL_PATH=$cwd/pth; export ACLOCAL_PATH
 
 # We don't use `--install' here.  Our distcheck-hook should catch this.
 $ACLOCAL -I m4
 $AUTOCONF
-$EGREP 'MY_(FOO|BAR|BAZ)' configure && Exit 1 # Sanity check.
+$EGREP 'MY_(FOO|BAR|BAZ|ZAR)' configure && Exit 1 # Sanity check.
 $AUTOMAKE
 
 ./configure
 
 $MAKE distcheck >output 2>&1 && { cat output; Exit 1; }
 cat output
-$EGREP "required m4 file.*not distributed.* bar.m4( |$)" output
-$EGREP "required m4 file.*not distributed.* baz.m4( |$)" output
+for x in bar baz zar; do
+  $EGREP "required m4 file.*not distributed.* $x.m4( |$)" output
+done
 # Check that we don't fail for spurious errors.
 $EGREP -i 'mkdir:|autom4te.*\.cache|:.*(permission|denied)' output && Exit 1
 
@@ -74,28 +79,34 @@ $EGREP -i 'mkdir:|autom4te.*\.cache|:.*(permission|denied)' 
output && Exit 1
 $ACLOCAL -I m4 --install
 test -f m4/bar.m4 # Sanity check.
 test -f m4/baz.m4 # Likewise.
+test -f m4/zar.m4 # Likewise.
 using_gmake || $MAKE Makefile
 $MAKE distcheck
 
-# We start to use a new "third-party" macro from a new .m4 file, but forget
+# We start to use new "third-party" macros from new .m4 files, but forget
 # to re-run "aclocal --install" by hand, relying on automatic remake rules.
 # Our distcheck-hook should catch this too.
-echo MY_QUX >> configure.in
+cat >> configure.in << 'END'
+MY_QUX
+MY_BLA
+END
 
 $MAKE
-$EGREP 'MY_(FOO|BAR|BAZ|QUX)' configure && Exit 1 # Sanity check.
+$EGREP 'MY_(FOO|BAR|BAZ|QUX|ZAR|BLA)' configure && Exit 1 # Sanity check.
 
 $MAKE distcheck >output 2>&1 && { cat output; Exit 1; }
 cat output
 $EGREP "required m4 file.*not distributed.* qux.m4( |$)" output
+$EGREP "required m4 file.*not distributed.* bla.m4( |$)" output
 # Check that we don't fail for spurious errors.
 $EGREP -i 'mkdir:|autom4te.*\.cache|permission|denied' output && Exit 1
 # Check that we don't complain for files that should have been found.
-grep " ba[rz].m4" output && Exit 1
+$FGREP " (bar|baz|zar).m4" output && Exit 1
 
 # Now we again use `--install', and "make distcheck" should pass.
 $ACLOCAL -I m4 --install
 test -f m4/qux.m4 # Sanity check.
+test -f m4/bla.m4 # Likewise.
 using_gmake || $MAKE Makefile
 $MAKE distcheck
 
diff --git a/tests/distcheck-outdated-m4.test b/tests/distcheck-outdated-m4.test
index 74f2922..7a3ade8 100755
--- a/tests/distcheck-outdated-m4.test
+++ b/tests/distcheck-outdated-m4.test
@@ -50,7 +50,8 @@ END
 
 ACLOCAL="$ACLOCAL --system-acdir=$cwd/acdir"; export ACLOCAL
 
-# We don't use `--install' here.  Our distcheck-hook should catch this.
+# The use of `--install' here won't help when the installed file `.m4'
+# will become out-of-date w.r.t. the one in the system acdir.
 $ACLOCAL -I m4 --install
 $AUTOCONF
 $AUTOMAKE
@@ -77,10 +78,54 @@ cat output
 $EGREP "required m4 file.* outdated.* baz.m4( |$)" output
 # Check that we don't fail for spurious errors.
 $EGREP -i 'mkdir:|autom4te.*\.cache|permission|denied' output && Exit 1
-# Check that we don't complain for files that should have been found.
+# Check that we don't complain for files that aren't outdated.
 $EGREP " (foo|bar).m4" output && Exit 1
 
-# Now we again use `--install', and "make distcheck" should pass.
+# Now we again use `--install' explicitly, and "make distcheck"
+# should pass.
+$ACLOCAL -I m4 --install
+using_gmake || $MAKE Makefile
+$MAKE distcheck
+
+# Similar to what have been done above, but this time we:
+#  - use ACLOCAL_PATH, and
+#  - do not add the use of a new macro.
+
+echo MY_FNORD >> configure.in
+
+mkdir pth
+cat > pth/fnord.m4 << 'END'
+# serial 1
+AC_DEFUN([MY_FNORD], [:])
+END
+
+ACLOCAL_PATH="$cwd/pth"; export ACLOCAL_PATH
+
+# The explicit use of `--install' here won't help when the installed file
+# `.m4' will become out-of-date w.r.t. the one in the system acdir.
+$ACLOCAL -I m4 --install
+using_gmake || $MAKE Makefile
+$MAKE distcheck
+
+# Only increase serial number, without changing the other contents; this
+# is deliberate.
+cat > pth/fnord.m4 << 'END'
+# serial 2
+AC_DEFUN([MY_FNORD], [:])
+END
+
+$MAKE # Rebuild configure and makefiles.
+$MAKE distcheck >output 2>&1 && { cat output; Exit 1; }
+cat output
+
+$EGREP "required m4 file.* outdated.* fnord.m4( |$)" output
+# Check that we don't fail for spurious errors.
+$EGREP -i 'mkdir:|autom4te.*\.cache|permission|denied' output && Exit 1
+# Check that we don't complain for files that aren't outdated.
+$EGREP " (foo|bar|baz).m4" output && Exit 1
+
+# Now we again use `--install' explicitly, and "make distcheck"
+# should pass.
 $ACLOCAL -I m4 --install
 using_gmake || $MAKE Makefile
 $MAKE distcheck
-- 
1.7.2.3


reply via email to

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