automake-patches
[Top][All Lists]
Advanced

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

Re: [PATCH] Extend checks on remake rules.


From: Stefano Lattarini
Subject: Re: [PATCH] Extend checks on remake rules.
Date: Thu, 16 Dec 2010 01:27:10 +0100
User-agent: KMail/1.13.3 (Linux/2.6.30-2-686; KDE/4.4.4; i686; ; )

Hi Ralf, and thanks for the review.

Find replies to your inline comments below.

On Wednesday 15 December 2010, Ralf Wildenhues wrote:
> * Stefano Lattarini wrote on Mon, Dec 06, 2010 at 08:34:04PM CET:
> > On Sunday 05 December 2010, Ralf Wildenhues wrote:
> > > Some of the tests look like they are testing the same things really
> > > as other new or existing tests.
> > >
> > Maybe, but I prefer to have some overlaps between different tests rather
> > than a lack in coverage.  Also, different tests might check the same
> > feature in slightly different situations, so that the overlapping is only
> > partial anyway, and the increase in coverage is real (albeit small).
> 
> Hmm, ok.
> 
> > > Can you explain them (ideally, the
> > > comment at the start of the test should be unique for each test so
> > > we can infer from that that each of the tests is actually required)?
> > >
> > I've tried to improve some heading comments (see the attached
> > squash-in); please tell me if now they seem clearer now.  Also,
> > Maybe I should expand comments in tests remake9*.tes toot, but
> > I haven't yet figured it out how to do so without being quite
> > verbose.  Hmm, but maybe here being verbose is the right thing
> > to do after all...  WDYT?
> 
> I like the new comments better, thanks.
> 
> > In the process, I've also made a couple of small improvements and
> > fixes to remake8{a,b}.test; please check them out and tell me if
> > you're OK with them.
> 
> See inline comments.  Patch is ok after addressing them.
> 
> Thanks,
> Ralf
> 
> > Subject: [PATCH] Tests: extend checks on remake rules.
> > 
> > This adds proper semantical tests (i.e. run make to check the
> > rebuild rules are correctly triggered) in addition to tentative
> > grepping of the generated Makefile.in(s).
> > 
> > * tests/remake.test: Enable `errexit' shell flag, and related
> > changes.  Modernize `configure.in'.  Add trailing `:' command.
> > In heading comments, add reference to sister test remake1a.test.
> > * tests/remake3.test: Likewise (but with sister test being
> > remake3a.test).
> > * tests/remake2.test: Make grepping of `Makefile.in' slighty
> 
> slightly
> 
Fixed.  Apparently, there was a mismatch between the git log entry
and the ChangeLog entry.  I fixed that too.

> > stricter.
> > * tests/remake5.test: Also run the `distcheck' target.  Add
> > trailing `:' command.  Use proper m4 quoting in configure.in.
> > * tests/remake4.test: Prefer `$me' over hard-coded test name.
> > * tests/remake7.test: Use the `configure.in' stub created by
> > ./defs, rather than writing it from scratch.
> > * tests/remake6.test: Likewise.  Also, add trailing `:' command,
> > and ensure verbose printing of captured make output.
> > * tests/remake1a.test: New test, sister of remake.test.
> > * tests/remake3a.test: New test, sister of remake3.test.
> > * tests/remake8a.test: New test.
> > * tests/remake8b.test: New test.
> > * tests/remake9a.test: Likewise.
> > * tests/remake9b.test: Likewise.
> > * tests/remake9c.test: Likewise.
> > * tests/remake9d.test: Likewise.
> > * tests/remake10a.test: Likewise.
> > * tests/remake10b.test: Likewise.
> > * tests/remake10c.test: Likewise.
> > * tests/remake11.test: Likewise.
> > * tests/remake12.test: Likewise.
> > * tests/Makefile.am (TESTS): Updated.
> 
> 
> > --- /dev/null
> > +++ b/tests/remake10a.test
> > @@ -0,0 +1,108 @@
> 
> > +# Test remake rules for m4 files included (also recursively) by
> > +# configure.ac.
> > +# Keep in sync with sister tests `remake10b.test' and `remake10c.test'.
> > +
> > +required=GNUmake
> > +. ./defs || Exit 1
> > +
> > +set -e
> > +
> > +hash1=7532aa4708e8320c8c7098a5e3a1ec88aafb074f
> > +hash2=99368830db9954b4d9fecd04d3996d9acea7129f
> > +hash3=36fe4f389c0a835dfcdb0f58a8909eab43189af1
> 
> By the way, why all these hash values (here and in other tests)?
>
To easily get strings to grep for without risking false positives.
I got the hashes from commits in the Automake git repo (basically
random and fairly recent). (but *see below*)

> Is there any significance to their values?
>
No, they are just "magic strings".  I don't perceive this as a
problem, since I use them only through their "symbolic names"
($hash1, $hash2, $hash3) in the rest of the tests.  Maybe using
names like "$magic1" etc. would have been still better, but
that's mostly bikeshedding. (but *see below*)

> Why not some less random string?
>
> And in other tests, you use %GrepMe%, !Foo! and other magic strings.
>
You're right here, I should just stick to a single kind of magic
string, and use it consistently (better if only through "symbolic
names").

OK, so in the end I've amended the patch to use "real magic strings"
instead of hashes.  See the attached "squash-in-2.patch".

JFTR, these are the commands I used to obtain that squash-in:
  $ grep '\<hash[0-9]\>' remake*.test # for a preliminary visual check
  $ sed -i 's/\<hash\([0-9]\)\>/magic\1/g' remake*.test
  $ grep 'magic[0-9]=' remake*.test # one more visual check won't hurt
  $ sed -i 's/^magic1=.*/magic1=::MagicStringOne::/' remake*.test
  $ sed -i 's/^magic2=.*/magic2=__MagicStringTwo__/' remake*.test
  $ sed -i 's/^magic3=.*/magic3=%%MagicStringThree%%/' remake*.test
  $ ... # other minor editings by hand

> Why all the variation in these?  That makes the tests harder to read.
>
I'd rather not change the use of magic strings on the other remake
tests, unless you insist.  The test remak3a.test is IMHO simple enough
not to cause confusion, and changing the tests remake8{a,b}.test would
be quite cumbersome.

> > +cat >> configure.in <<END
> > +m4_include([foo.m4])
> > +AC_SUBST([am_fingerprint], [m4_fingerprint])
> 
> Why invade both Automake and M4sh namespaces here?
>
Hmmm... no good reason indeed  Using `FINGERPRINT' and `my_fingerprint' 
instead of resp. `am_fingerprint' and `m4_fingerprint' should be clearer
and safer.  I've amended all the remake9*.test and remake10*.test tests
accordingly.  See the attached "squash-in-1.patch".

> > +AC_OUTPUT
> > +END
> > +
> > +cat > Makefile.am <<'END'
> > +.PHONY: nil
> > +nil:
> > +## Used by "make distcheck" later.
> > +check-local:
> > +   test -f $(top_srcdir)/foo.m4
> > +   test ! -r $(top_srcdir)/bar.m4
> > +   test x'$(am_fingerprint)' = x'DummyValue'
> 
> Why do you quote DummyValue here?
>
Partly for symmetry with the left side, and partly (especially I'd say)
to make the leading `x' stick out better as "not a part of the expected
value".

> The leading x should not be needed on either side.
>
True, "should not" -- but I got in the habit of always using it, even
where technically not needed, rather then risking to forgot it one time
when it's really required.

> (several instances below)
>
Should I remove them? (sorry if I ask, but the "should" above does
not make it clear if you're asking to remove them or just noting that
they are not really required).

> > +END
> > +
> > +echo 'm4_define([m4_fingerprint], [BadBadBad])' > foo.m4
> > +
> > +$sleep # so that generated autotools files will be older than prerequisites
> 
> s/older/newer/ ?
> 
> More instances below.  Copy and paste bad.  ;-)
>
Oops.  Fixed.

> > --- /dev/null
> > +++ b/tests/remake10c.test
> > @@ -0,0 +1,112 @@
> 
> > +# Test remake rules for m4 files included (also recursively) by
> > +# aclocal.m4.
> > +# Keep in sync with sister tests `remake10a.test' and `remake10b.test'.
> > +
> > +required=GNUmake
> > +. ./defs || Exit 1
> > +
> > +set -e
> > +
> > +hash1=7532aa4708e8320c8c7098a5e3a1ec88aafb074f
> > +hash2=99368830db9954b4d9fecd04d3996d9acea7129f
> > +hash3=36fe4f389c0a835dfcdb0f58a8909eab43189af1
> > +
> > +cat >> configure.in <<END
> > +am_fingerprint='AM_FINGERPRINT'
> > +AC_SUBST([am_fingerprint])
> > +AC_OUTPUT
> > +END
> > +
> > +cat > Makefile.am <<'END'
> > +ACLOCAL_AMFLAGS = -I m4
> > +.PHONY: nil
> > +nil:
> > +## Used by "make distcheck" later.
> > +check-local:
> > +   test -f $(top_srcdir)/m4/foo.m4
> > +   test ! -r $(top_srcdir)/m4/bar.m4
> > +   test x'$(am_fingerprint)' = x'DummyValue'
> > +END
> > +
> > +mkdir m4
> > +echo 'AC_DEFUN([AM_FINGERPRINT], [BadBadBad])' > m4/foo.m4
> 
> Invasion of Automake namespace.
>
Fixed (see also above Re: am_fingerprint and m4_fingerprint).

> > --- /dev/null
> > +++ b/tests/remake8a.test
> > @@ -0,0 +1,193 @@
> 
> > +# Test basic remake rules for Makefiles, for an *in-tree build*.
> > +# This testcase checks dependency of generated Makefile from Makefile.am,
> > +# configure.ac, acinclude.m4, aclocal.m4, and extra m4 files considered
> > +# by aclocal.
> > +# Keep this in sync with sister test `remake8b.test', which performs the
> > +# same checks for a VPATH build.
> 
> Why not do both in one test?  You do that elsewhere already.
>
To be honest, I'd like to separate in-tree and VPATH checks for other tests
too, but then we'd end up with remake9a.test, remake9a-vpath.test, ...
A bit of an overkill I must admit.  So I contented myself with doing the
separation for the test remake8.

> Oh well.  The lots of duplication is a bit not so nice for
> maintenance (and for review; and karma) ...
> 
> > +required=GNUmake
> > +. ./defs || Exit 1
> > +
> > +set -e
> > +
> > ...

-*-*-*-

Attached is also the amended patch.  I will push in 72 hours if there
are no more objections (and if all my testing on Linux and Solaris
succeeds).

Regards,
   Stefano
From 49ec3ad2cb63033024d0d7f7eb02a936a999f2eb Mon Sep 17 00:00:00 2001
From: Stefano Lattarini <address@hidden>
Date: Wed, 15 Dec 2010 22:46:23 +0100
Subject: [PATCH 2/3] squash-in 1

---
 tests/remake10a.test |   24 ++++++++++++------------
 tests/remake10b.test |   22 +++++++++++-----------
 tests/remake10c.test |   26 +++++++++++++-------------
 tests/remake9a.test  |   20 ++++++++++----------
 tests/remake9b.test  |   18 +++++++++---------
 tests/remake9c.test  |   22 +++++++++++-----------
 tests/remake9d.test  |   20 ++++++++++----------
 7 files changed, 76 insertions(+), 76 deletions(-)

diff --git a/tests/remake10a.test b/tests/remake10a.test
index 67b9e14..4fe259a 100755
--- a/tests/remake10a.test
+++ b/tests/remake10a.test
@@ -29,7 +29,7 @@ hash3=36fe4f389c0a835dfcdb0f58a8909eab43189af1
 
 cat >> configure.in <<END
 m4_include([foo.m4])
-AC_SUBST([am_fingerprint], [m4_fingerprint])
+AC_SUBST([FINGERPRINT], [my_fingerprint])
 AC_OUTPUT
 END
 
@@ -40,12 +40,12 @@ nil:
 check-local:
        test -f $(top_srcdir)/foo.m4
        test ! -r $(top_srcdir)/bar.m4
-       test x'$(am_fingerprint)' = x'DummyValue'
+       test x'$(FINGERPRINT)' = x'DummyValue'
 END
 
-echo 'm4_define([m4_fingerprint], [BadBadBad])' > foo.m4
+echo 'm4_define([my_fingerprint], [BadBadBad])' > foo.m4
 
-$sleep # so that generated autotools files will be older than prerequisites
+$sleep # so that generated autotools files will be newer than prerequisites
 $ACLOCAL
 $AUTOCONF
 $AUTOMAKE
@@ -64,36 +64,36 @@ for vpath in : false; do
   $MAKE # should be no-op
 
   $sleep
-  echo "m4_define([m4_fingerprint], [$hash1])" > $top_srcdir/foo.m4
+  echo "m4_define([my_fingerprint], [$hash1])" > $top_srcdir/foo.m4
   $MAKE nil
-  $FGREP am_fingerprint Makefile # for debugging
+  $FGREP FINGERPRINT Makefile # for debugging
   $FGREP $hash1 Makefile
 
   $sleep
-  echo "m4_define([m4_fingerprint], [$hash2])" > $top_srcdir/foo.m4
+  echo "m4_define([my_fingerprint], [$hash2])" > $top_srcdir/foo.m4
   $MAKE nil
-  $FGREP am_fingerprint Makefile # for debugging
+  $FGREP FINGERPRINT Makefile # for debugging
   $FGREP $hash1 Makefile && Exit 1
   $FGREP $hash2 Makefile
 
   $sleep
   echo "m4_include([bar.m4])" > $top_srcdir/foo.m4
-  echo "m4_define([m4_fingerprint], [$hash3])" > $top_srcdir/bar.m4
+  echo "m4_define([my_fingerprint], [$hash3])" > $top_srcdir/bar.m4
   $MAKE nil
-  $FGREP am_fingerprint Makefile # for debugging
+  $FGREP FINGERPRINT Makefile # for debugging
   $FGREP $hash1 Makefile && Exit 1
   $FGREP $hash2 Makefile && Exit 1
   $FGREP $hash3 Makefile
 
   $sleep
-  echo "m4_define([m4_fingerprint], [$hash1])" > $top_srcdir/bar.m4
+  echo "m4_define([my_fingerprint], [$hash1])" > $top_srcdir/bar.m4
   $MAKE nil
   $FGREP $hash2 Makefile && Exit 1
   $FGREP $hash3 Makefile && Exit 1
   $FGREP $hash1 Makefile
 
   $sleep
-  echo "m4_define([m4_fingerprint], [DummyValue])" > $top_srcdir/foo.m4
+  echo "m4_define([my_fingerprint], [DummyValue])" > $top_srcdir/foo.m4
   $MAKE distcheck
   $FGREP $hash1 Makefile && Exit 1 # sanity check
   $FGREP $hash2 Makefile && Exit 1 # likewise
diff --git a/tests/remake10b.test b/tests/remake10b.test
index 2e81db6..896c138 100755
--- a/tests/remake10b.test
+++ b/tests/remake10b.test
@@ -39,12 +39,12 @@ include foo.am
 check-local:
        test -f $(top_srcdir)/foo.am
        test ! -r $(top_srcdir)/bar.am
-       test x'$(am_fingerprint)' = x'DummyValue'
+       test x'$(FINGERPRINT)' = x'DummyValue'
 END
 
-echo 'am_fingerprint = BadBadBad' > foo.am
+echo 'FINGERPRINT = BadBadBad' > foo.am
 
-$sleep # so that generated autotools files will be older than prerequisites
+$sleep # so that generated autotools files will be newer than prerequisites
 $ACLOCAL
 $AUTOCONF
 $AUTOMAKE
@@ -63,36 +63,36 @@ for vpath in : false; do
   $MAKE # should be no-op
 
   $sleep
-  echo "am_fingerprint = $hash1" > $top_srcdir/foo.am
+  echo "FINGERPRINT = $hash1" > $top_srcdir/foo.am
   $MAKE nil
-  $FGREP am_fingerprint Makefile # for debugging
+  $FGREP FINGERPRINT Makefile # for debugging
   $FGREP $hash1 Makefile
 
   $sleep
-  echo "am_fingerprint = $hash2" > $top_srcdir/foo.am
+  echo "FINGERPRINT = $hash2" > $top_srcdir/foo.am
   $MAKE nil
-  $FGREP am_fingerprint Makefile # for debugging
+  $FGREP FINGERPRINT Makefile # for debugging
   $FGREP $hash1 Makefile && Exit 1
   $FGREP $hash2 Makefile
 
   $sleep
   echo 'include $(top_srcdir)/bar.am' > $top_srcdir/foo.am
-  echo "am_fingerprint = $hash3" > $top_srcdir/bar.am
+  echo "FINGERPRINT = $hash3" > $top_srcdir/bar.am
   $MAKE nil
-  $FGREP am_fingerprint Makefile # for debugging
+  $FGREP FINGERPRINT Makefile # for debugging
   $FGREP $hash1 Makefile && Exit 1
   $FGREP $hash2 Makefile && Exit 1
   $FGREP $hash3 Makefile
 
   $sleep
-  echo "am_fingerprint = $hash1" > $top_srcdir/bar.am
+  echo "FINGERPRINT = $hash1" > $top_srcdir/bar.am
   $MAKE nil
   $FGREP $hash2 Makefile && Exit 1
   $FGREP $hash3 Makefile && Exit 1
   $FGREP $hash1 Makefile
 
   $sleep
-  echo "am_fingerprint = DummyValue" > $top_srcdir/foo.am
+  echo "FINGERPRINT = DummyValue" > $top_srcdir/foo.am
   $MAKE distcheck
   $FGREP $hash1 Makefile && Exit 1 # sanity check
   $FGREP $hash2 Makefile && Exit 1 # likewise
diff --git a/tests/remake10c.test b/tests/remake10c.test
index 98c13c5..56f7443 100755
--- a/tests/remake10c.test
+++ b/tests/remake10c.test
@@ -28,8 +28,8 @@ hash2=99368830db9954b4d9fecd04d3996d9acea7129f
 hash3=36fe4f389c0a835dfcdb0f58a8909eab43189af1
 
 cat >> configure.in <<END
-am_fingerprint='AM_FINGERPRINT'
-AC_SUBST([am_fingerprint])
+FINGERPRINT='my_fingerprint'
+AC_SUBST([FINGERPRINT])
 AC_OUTPUT
 END
 
@@ -41,13 +41,13 @@ nil:
 check-local:
        test -f $(top_srcdir)/m4/foo.m4
        test ! -r $(top_srcdir)/m4/bar.m4
-       test x'$(am_fingerprint)' = x'DummyValue'
+       test x'$(FINGERPRINT)' = x'DummyValue'
 END
 
 mkdir m4
-echo 'AC_DEFUN([AM_FINGERPRINT], [BadBadBad])' > m4/foo.m4
+echo 'AC_DEFUN([my_fingerprint], [BadBadBad])' > m4/foo.m4
 
-$sleep # so that generated autotools files will be older than prerequisites
+$sleep # so that generated autotools files will be newer than prerequisites
 $ACLOCAL -I m4
 $AUTOCONF
 $AUTOMAKE
@@ -66,36 +66,36 @@ for vpath in : false; do
   $MAKE # should be no-op
 
   $sleep
-  echo "AC_DEFUN([AM_FINGERPRINT], [$hash1])" > $top_srcdir/m4/foo.m4
+  echo "AC_DEFUN([my_fingerprint], [$hash1])" > $top_srcdir/m4/foo.m4
   $MAKE nil
-  $FGREP am_fingerprint Makefile # for debugging
+  $FGREP FINGERPRINT Makefile # for debugging
   $FGREP $hash1 Makefile
 
   $sleep
-  echo "AC_DEFUN([AM_FINGERPRINT], [$hash2])" > $top_srcdir/m4/foo.m4
+  echo "AC_DEFUN([my_fingerprint], [$hash2])" > $top_srcdir/m4/foo.m4
   $MAKE nil
-  $FGREP am_fingerprint Makefile # for debugging
+  $FGREP FINGERPRINT Makefile # for debugging
   $FGREP $hash1 Makefile && Exit 1
   $FGREP $hash2 Makefile
 
   $sleep
   echo "m4_include([m4/bar.m4])" > $top_srcdir/m4/foo.m4
-  echo "AC_DEFUN([AM_FINGERPRINT], [$hash3])" > $top_srcdir/m4/bar.m4
+  echo "AC_DEFUN([my_fingerprint], [$hash3])" > $top_srcdir/m4/bar.m4
   $MAKE nil
-  $FGREP am_fingerprint Makefile # for debugging
+  $FGREP FINGERPRINT Makefile # for debugging
   $FGREP $hash1 Makefile && Exit 1
   $FGREP $hash2 Makefile && Exit 1
   $FGREP $hash3 Makefile
 
   $sleep
-  echo "AC_DEFUN([AM_FINGERPRINT], [$hash1])" > $top_srcdir/m4/bar.m4
+  echo "AC_DEFUN([my_fingerprint], [$hash1])" > $top_srcdir/m4/bar.m4
   $MAKE nil
   $FGREP $hash2 Makefile && Exit 1
   $FGREP $hash3 Makefile && Exit 1
   $FGREP $hash1 Makefile
 
   $sleep
-  echo "AC_DEFUN([AM_FINGERPRINT], [DummyValue])" > $top_srcdir/m4/foo.m4
+  echo "AC_DEFUN([my_fingerprint], [DummyValue])" > $top_srcdir/m4/foo.m4
   echo "AC_DEFUN([AM_UNUSED], [NoSuchMacro])" > $top_srcdir/m4/bar.m4
   $MAKE nil # required to work around limitation of GNU make 3.82
   $MAKE distcheck
diff --git a/tests/remake9a.test b/tests/remake9a.test
index 1d714dd..3dd8a20 100755
--- a/tests/remake9a.test
+++ b/tests/remake9a.test
@@ -26,8 +26,8 @@ hash1=7532aa4708e8320c8c7098a5e3a1ec88aafb074f
 hash2=99368830db9954b4d9fecd04d3996d9acea7129f
 
 cat >> configure.in <<END
-am_fingerprint=BadBadBad
-AC_SUBST([am_fingerprint])
+FINGERPRINT=BadBadBad
+AC_SUBST([FINGERPRINT])
 AC_CONFIG_FILES([foo.sh:foo.in], [chmod a+x foo.sh])
 AC_OUTPUT
 END
@@ -43,18 +43,18 @@ EXTRA_DIST = $(srcdir)/tweak-configure-in
 
 # Used by "make distcheck" later.
 check-local:
-       test x'$(am_fingerprint)' = x'DummyValue'
+       test x'$(FINGERPRINT)' = x'DummyValue'
        test x"`./foo.sh`" = x"DummyValue"
 END
 
 cat > foo.in <<END
 #!/bin/sh
-echo '@am_fingerprint@'
+echo '@FINGERPRINT@'
 END
 
 echo cat > tweak-configure-in # no-op by default
 
-$sleep # so that generated autotools files will be older than prerequisites
+$sleep # so that generated autotools files will be newer than prerequisites
 $ACLOCAL
 $AUTOCONF
 $AUTOMAKE
@@ -73,25 +73,25 @@ for vpath in : false; do
   $MAKE # should be no-op
 
   $sleep
-  sed "s/^\\(am_fingerprint\\)=.*/\\1=$hash1/" $srcdir/configure.in >t
+  sed "s/^\\(FINGERPRINT\\)=.*/\\1=$hash1/" $srcdir/configure.in >t
   mv -f t $srcdir/configure.in
   $MAKE nil
-  $FGREP am_fingerprint Makefile # for debugging
+  $FGREP FINGERPRINT Makefile # for debugging
   $FGREP $hash1 Makefile
   test x"`./foo.sh`" = x"$hash1"
 
   $sleep
-  echo 'sed "s/^\\(am_fingerprint\\)=.*/\\1='$hash2'/"' \
+  echo 'sed "s/^\\(FINGERPRINT\\)=.*/\\1='$hash2'/"' \
     > $srcdir/tweak-configure-in
   $MAKE nil
-  $FGREP am_fingerprint Makefile # for debugging
+  $FGREP FINGERPRINT Makefile # for debugging
   $FGREP $hash1 Makefile && Exit 1
   $FGREP $hash2 Makefile
   test x"`./foo.sh`" = x"$hash2"
 
   $sleep
   echo cat > $srcdir/tweak-configure-in # no-op again
-  sed "s/^\\(am_fingerprint\\)=.*/\\1=DummyValue/" $srcdir/configure.in >t
+  sed "s/^\\(FINGERPRINT\\)=.*/\\1=DummyValue/" $srcdir/configure.in >t
   mv -f t $srcdir/configure.in
   $MAKE distcheck
   $FGREP $hash1 Makefile && Exit 1 # sanity check
diff --git a/tests/remake9b.test b/tests/remake9b.test
index 041db04..6038a49 100755
--- a/tests/remake9b.test
+++ b/tests/remake9b.test
@@ -30,7 +30,7 @@ AC_OUTPUT
 END
 
 cat > Makefile.am <<'END'
-am_fingerprint = BadBadBad
+FINGERPRINT = BadBadBad
 
 all-local: nil
 nil: foo.sh
@@ -44,19 +44,19 @@ EXTRA_DIST = $(srcdir)/tweak-makefile-am
 foo.sh: Makefile
        rm -f $@ address@hidden
        echo '#!/bin/sh' > address@hidden
-       echo "echo '$(am_fingerprint)'" >> address@hidden
+       echo "echo '$(FINGERPRINT)'" >> address@hidden
        chmod a+x address@hidden && mv -f address@hidden $@
 CLEANFILES = foo.sh
 
 # Used by "make distcheck" later.
 check-local:
-       test x'$(am_fingerprint)' = x'DummyValue'
+       test x'$(FINGERPRINT)' = x'DummyValue'
        test x"`./foo.sh`" = x"DummyValue"
 END
 
 echo cat > tweak-makefile-am # no-op by default
 
-$sleep # so that generated autotools files will be older than prerequisites
+$sleep # so that generated autotools files will be newer than prerequisites
 $ACLOCAL
 $AUTOCONF
 $AUTOMAKE
@@ -75,25 +75,25 @@ for vpath in : false; do
   $MAKE # should be no-op
 
   $sleep
-  sed "s/^\\(am_fingerprint\\) *=.*/\\1 = $hash1/" $srcdir/Makefile.am >t
+  sed "s/^\\(FINGERPRINT\\) *=.*/\\1 = $hash1/" $srcdir/Makefile.am >t
   mv -f t $srcdir/Makefile.am
   $MAKE nil
-  $FGREP am_fingerprint Makefile # for debugging
+  $FGREP FINGERPRINT Makefile # for debugging
   $FGREP $hash1 Makefile
   test x"`./foo.sh`" = x"$hash1"
 
   $sleep
-  echo 'sed "s/^\\(am_fingerprint\\) *=.*/\\1 = '$hash2'/"' \
+  echo 'sed "s/^\\(FINGERPRINT\\) *=.*/\\1 = '$hash2'/"' \
     > $srcdir/tweak-makefile-am
   $MAKE nil
-  $FGREP am_fingerprint Makefile # for debugging
+  $FGREP FINGERPRINT Makefile # for debugging
   $FGREP $hash1 Makefile && Exit 1
   $FGREP $hash2 Makefile
   test x"`./foo.sh`" = x"$hash2"
 
   $sleep
   echo cat > $srcdir/tweak-makefile-am # no-op again
-  sed "s/^\\(am_fingerprint\\) *=.*/\\1 = DummyValue/" $srcdir/Makefile.am >t
+  sed "s/^\\(FINGERPRINT\\) *=.*/\\1 = DummyValue/" $srcdir/Makefile.am >t
   mv -f t $srcdir/Makefile.am
   $MAKE distcheck
   $FGREP $hash1 Makefile && Exit 1 # sanity check
diff --git a/tests/remake9c.test b/tests/remake9c.test
index 19bd1f1..23600f4 100755
--- a/tests/remake9c.test
+++ b/tests/remake9c.test
@@ -26,8 +26,8 @@ hash1=7532aa4708e8320c8c7098a5e3a1ec88aafb074f
 hash2=99368830db9954b4d9fecd04d3996d9acea7129f
 
 cat >> configure.in <<END
-am_fingerprint='MY_FINGERPRINT'
-AC_SUBST([am_fingerprint])
+FINGERPRINT='my_fingerprint'
+AC_SUBST([FINGERPRINT])
 AC_CONFIG_FILES([foo.sh:foo.in], [chmod a+x foo.sh])
 AC_OUTPUT
 END
@@ -46,20 +46,20 @@ EXTRA_DIST = $(srcdir)/tweak-acinclude-m4
 
 # Used by "make distcheck" later.
 check-local:
-       test x'$(am_fingerprint)' = x'DummyValue'
+       test x'$(FINGERPRINT)' = x'DummyValue'
        test x"`./foo.sh`" = x"DummyValue"
 END
 
 cat > foo.in <<END
 #!/bin/sh
-echo '@am_fingerprint@'
+echo '@FINGERPRINT@'
 END
 
-echo "AC_DEFUN([MY_FINGERPRINT], [BadBadBad])" > acinclude.m4
+echo "AC_DEFUN([my_fingerprint], [BadBadBad])" > acinclude.m4
 
 echo : > tweak-acinclude-m4 # no-op by default
 
-$sleep # so that generated autotools files will be older than prerequisites
+$sleep # so that generated autotools files will be newer than prerequisites
 $ACLOCAL
 $AUTOCONF
 $AUTOMAKE
@@ -78,24 +78,24 @@ for vpath in : false; do
   $MAKE # should be no-op
 
   $sleep
-  echo "AC_DEFUN([MY_FINGERPRINT], [$hash1])" > $srcdir/acinclude.m4
+  echo "AC_DEFUN([my_fingerprint], [$hash1])" > $srcdir/acinclude.m4
   $MAKE nil
-  $FGREP am_fingerprint Makefile # for debugging
+  $FGREP FINGERPRINT Makefile # for debugging
   $FGREP $hash1 Makefile
   test x"`./foo.sh`" = x"$hash1"
 
   $sleep
-  echo "echo 'AC_DEFUN([MY_FINGERPRINT], [$hash2])'" \
+  echo "echo 'AC_DEFUN([my_fingerprint], [$hash2])'" \
     > $srcdir/tweak-acinclude-m4
   $MAKE nil
-  $FGREP am_fingerprint Makefile # for debugging
+  $FGREP FINGERPRINT Makefile # for debugging
   $FGREP $hash1 Makefile && Exit 1
   $FGREP $hash2 Makefile
   test x"`./foo.sh`" = x"$hash2"
 
   $sleep
   echo : > $srcdir/tweak-acinclude-m4 # no-op again
-  echo "AC_DEFUN([MY_FINGERPRINT], [DummyValue])" > $srcdir/acinclude.m4
+  echo "AC_DEFUN([my_fingerprint], [DummyValue])" > $srcdir/acinclude.m4
   $MAKE distcheck
   $FGREP $hash1 Makefile && Exit 1 # sanity check
   $FGREP $hash2 Makefile && Exit 1 # likewise
diff --git a/tests/remake9d.test b/tests/remake9d.test
index 4a44fba..52975e4 100755
--- a/tests/remake9d.test
+++ b/tests/remake9d.test
@@ -26,8 +26,8 @@ hash1=7532aa4708e8320c8c7098a5e3a1ec88aafb074f
 hash2=99368830db9954b4d9fecd04d3996d9acea7129f
 
 cat >> configure.in <<END
-am_fingerprint='MY_FINGERPRINT'
-AC_SUBST([am_fingerprint])
+FINGERPRINT='my_fingerprint'
+AC_SUBST([FINGERPRINT])
 AC_CONFIG_FILES([foo.sh:foo.in], [chmod a+x foo.sh])
 AC_OUTPUT
 END
@@ -45,18 +45,18 @@ EXTRA_DIST = $(srcdir)/tweak-aclocal-m4
 
 # Used by "make distcheck" later.
 check-local:
-       test x'$(am_fingerprint)' = x'DummyValue'
+       test x'$(FINGERPRINT)' = x'DummyValue'
        test x"`./foo.sh`" = x"DummyValue"
 END
 
 cat > foo.in <<END
 #!/bin/sh
-echo '@am_fingerprint@'
+echo '@FINGERPRINT@'
 END
 
 echo cat > tweak-aclocal-m4 # no-op by default
 
-$sleep # so that generated autotools files will be older than prerequisites
+$sleep # so that generated autotools files will be newer than prerequisites
 $ACLOCAL
 # Cheatingly mark aclocal.m4 as non auto-generated.
 sed '/^ *#.*generated automatically/d' aclocal.m4 > t
@@ -78,24 +78,24 @@ for vpath in : false; do
   $MAKE # should be no-op
 
   $sleep
-  echo "AC_DEFUN([MY_FINGERPRINT], [$hash1])dnl %%%" >> $srcdir/aclocal.m4
+  echo "AC_DEFUN([my_fingerprint], [$hash1])dnl %%%" >> $srcdir/aclocal.m4
   $MAKE nil
-  $FGREP am_fingerprint Makefile # for debugging
+  $FGREP FINGERPRINT Makefile # for debugging
   $FGREP $hash1 Makefile
   test x"`./foo.sh`" = x"$hash1"
 
   $sleep
-  echo "sed 's/.*dnl *%%%.*/AC_DEFUN([MY_FINGERPRINT], [$hash2])/'" \
+  echo "sed 's/.*dnl *%%%.*/AC_DEFUN([my_fingerprint], [$hash2])/'" \
     > $srcdir/tweak-aclocal-m4
   $MAKE nil
-  $FGREP am_fingerprint Makefile # for debugging
+  $FGREP FINGERPRINT Makefile # for debugging
   $FGREP $hash1 Makefile && Exit 1
   $FGREP $hash2 Makefile
   test x"`./foo.sh`" = x"$hash2"
 
   $sleep
   echo cat > $srcdir/tweak-aclocal-m4 # no-op again
-  echo 'AC_DEFUN([MY_FINGERPRINT], [DummyValue])' >> $srcdir/aclocal.m4
+  echo 'AC_DEFUN([my_fingerprint], [DummyValue])' >> $srcdir/aclocal.m4
   $MAKE distcheck
   $FGREP $hash1 Makefile && Exit 1 # sanity check
   $FGREP $hash2 Makefile && Exit 1 # likewise
-- 
1.7.1

From 9065c5873d4fcfad238892156eb155be8e6e07d0 Mon Sep 17 00:00:00 2001
From: Stefano Lattarini <address@hidden>
Date: Wed, 15 Dec 2010 23:52:29 +0100
Subject: [PATCH 3/3] squash-in 2

---
 tests/remake10a.test |   38 +++++++++++++++++++-------------------
 tests/remake10b.test |   38 +++++++++++++++++++-------------------
 tests/remake10c.test |   38 +++++++++++++++++++-------------------
 tests/remake11.test  |   14 +++++++-------
 tests/remake12.test  |   32 ++++++++++++++++----------------
 tests/remake9a.test  |   22 +++++++++++-----------
 tests/remake9b.test  |   22 +++++++++++-----------
 tests/remake9c.test  |   22 +++++++++++-----------
 tests/remake9d.test  |   22 +++++++++++-----------
 9 files changed, 124 insertions(+), 124 deletions(-)

diff --git a/tests/remake10a.test b/tests/remake10a.test
index 4fe259a..516b25c 100755
--- a/tests/remake10a.test
+++ b/tests/remake10a.test
@@ -23,9 +23,9 @@ required=GNUmake
 
 set -e
 
-hash1=7532aa4708e8320c8c7098a5e3a1ec88aafb074f
-hash2=99368830db9954b4d9fecd04d3996d9acea7129f
-hash3=36fe4f389c0a835dfcdb0f58a8909eab43189af1
+magic1=::MagicStringOne::
+magic2=__MagicStringTwo__
+magic3=%%MagicStringThree%%
 
 cat >> configure.in <<END
 m4_include([foo.m4])
@@ -64,40 +64,40 @@ for vpath in : false; do
   $MAKE # should be no-op
 
   $sleep
-  echo "m4_define([my_fingerprint], [$hash1])" > $top_srcdir/foo.m4
+  echo "m4_define([my_fingerprint], [$magic1])" > $top_srcdir/foo.m4
   $MAKE nil
   $FGREP FINGERPRINT Makefile # for debugging
-  $FGREP $hash1 Makefile
+  $FGREP $magic1 Makefile
 
   $sleep
-  echo "m4_define([my_fingerprint], [$hash2])" > $top_srcdir/foo.m4
+  echo "m4_define([my_fingerprint], [$magic2])" > $top_srcdir/foo.m4
   $MAKE nil
   $FGREP FINGERPRINT Makefile # for debugging
-  $FGREP $hash1 Makefile && Exit 1
-  $FGREP $hash2 Makefile
+  $FGREP $magic1 Makefile && Exit 1
+  $FGREP $magic2 Makefile
 
   $sleep
   echo "m4_include([bar.m4])" > $top_srcdir/foo.m4
-  echo "m4_define([my_fingerprint], [$hash3])" > $top_srcdir/bar.m4
+  echo "m4_define([my_fingerprint], [$magic3])" > $top_srcdir/bar.m4
   $MAKE nil
   $FGREP FINGERPRINT Makefile # for debugging
-  $FGREP $hash1 Makefile && Exit 1
-  $FGREP $hash2 Makefile && Exit 1
-  $FGREP $hash3 Makefile
+  $FGREP $magic1 Makefile && Exit 1
+  $FGREP $magic2 Makefile && Exit 1
+  $FGREP $magic3 Makefile
 
   $sleep
-  echo "m4_define([my_fingerprint], [$hash1])" > $top_srcdir/bar.m4
+  echo "m4_define([my_fingerprint], [$magic1])" > $top_srcdir/bar.m4
   $MAKE nil
-  $FGREP $hash2 Makefile && Exit 1
-  $FGREP $hash3 Makefile && Exit 1
-  $FGREP $hash1 Makefile
+  $FGREP $magic2 Makefile && Exit 1
+  $FGREP $magic3 Makefile && Exit 1
+  $FGREP $magic1 Makefile
 
   $sleep
   echo "m4_define([my_fingerprint], [DummyValue])" > $top_srcdir/foo.m4
   $MAKE distcheck
-  $FGREP $hash1 Makefile && Exit 1 # sanity check
-  $FGREP $hash2 Makefile && Exit 1 # likewise
-  $FGREP $hash3 Makefile && Exit 1 # likewise
+  $FGREP $magic1 Makefile && Exit 1 # sanity check
+  $FGREP $magic2 Makefile && Exit 1 # likewise
+  $FGREP $magic3 Makefile && Exit 1 # likewise
 
   $MAKE distclean
 
diff --git a/tests/remake10b.test b/tests/remake10b.test
index 896c138..7a163a8 100755
--- a/tests/remake10b.test
+++ b/tests/remake10b.test
@@ -23,9 +23,9 @@ required=GNUmake
 
 set -e
 
-hash1=7532aa4708e8320c8c7098a5e3a1ec88aafb074f
-hash2=99368830db9954b4d9fecd04d3996d9acea7129f
-hash3=36fe4f389c0a835dfcdb0f58a8909eab43189af1
+magic1=::MagicStringOne::
+magic2=__MagicStringTwo__
+magic3=%%MagicStringThree%%
 
 cat >> configure.in <<'END'
 AC_OUTPUT
@@ -63,40 +63,40 @@ for vpath in : false; do
   $MAKE # should be no-op
 
   $sleep
-  echo "FINGERPRINT = $hash1" > $top_srcdir/foo.am
+  echo "FINGERPRINT = $magic1" > $top_srcdir/foo.am
   $MAKE nil
   $FGREP FINGERPRINT Makefile # for debugging
-  $FGREP $hash1 Makefile
+  $FGREP $magic1 Makefile
 
   $sleep
-  echo "FINGERPRINT = $hash2" > $top_srcdir/foo.am
+  echo "FINGERPRINT = $magic2" > $top_srcdir/foo.am
   $MAKE nil
   $FGREP FINGERPRINT Makefile # for debugging
-  $FGREP $hash1 Makefile && Exit 1
-  $FGREP $hash2 Makefile
+  $FGREP $magic1 Makefile && Exit 1
+  $FGREP $magic2 Makefile
 
   $sleep
   echo 'include $(top_srcdir)/bar.am' > $top_srcdir/foo.am
-  echo "FINGERPRINT = $hash3" > $top_srcdir/bar.am
+  echo "FINGERPRINT = $magic3" > $top_srcdir/bar.am
   $MAKE nil
   $FGREP FINGERPRINT Makefile # for debugging
-  $FGREP $hash1 Makefile && Exit 1
-  $FGREP $hash2 Makefile && Exit 1
-  $FGREP $hash3 Makefile
+  $FGREP $magic1 Makefile && Exit 1
+  $FGREP $magic2 Makefile && Exit 1
+  $FGREP $magic3 Makefile
 
   $sleep
-  echo "FINGERPRINT = $hash1" > $top_srcdir/bar.am
+  echo "FINGERPRINT = $magic1" > $top_srcdir/bar.am
   $MAKE nil
-  $FGREP $hash2 Makefile && Exit 1
-  $FGREP $hash3 Makefile && Exit 1
-  $FGREP $hash1 Makefile
+  $FGREP $magic2 Makefile && Exit 1
+  $FGREP $magic3 Makefile && Exit 1
+  $FGREP $magic1 Makefile
 
   $sleep
   echo "FINGERPRINT = DummyValue" > $top_srcdir/foo.am
   $MAKE distcheck
-  $FGREP $hash1 Makefile && Exit 1 # sanity check
-  $FGREP $hash2 Makefile && Exit 1 # likewise
-  $FGREP $hash3 Makefile && Exit 1 # likewise
+  $FGREP $magic1 Makefile && Exit 1 # sanity check
+  $FGREP $magic2 Makefile && Exit 1 # likewise
+  $FGREP $magic3 Makefile && Exit 1 # likewise
 
   $MAKE distclean
 
diff --git a/tests/remake10c.test b/tests/remake10c.test
index 56f7443..8e44ccf 100755
--- a/tests/remake10c.test
+++ b/tests/remake10c.test
@@ -23,9 +23,9 @@ required=GNUmake
 
 set -e
 
-hash1=7532aa4708e8320c8c7098a5e3a1ec88aafb074f
-hash2=99368830db9954b4d9fecd04d3996d9acea7129f
-hash3=36fe4f389c0a835dfcdb0f58a8909eab43189af1
+magic1=::MagicStringOne::
+magic2=__MagicStringTwo__
+magic3=%%MagicStringThree%%
 
 cat >> configure.in <<END
 FINGERPRINT='my_fingerprint'
@@ -66,42 +66,42 @@ for vpath in : false; do
   $MAKE # should be no-op
 
   $sleep
-  echo "AC_DEFUN([my_fingerprint], [$hash1])" > $top_srcdir/m4/foo.m4
+  echo "AC_DEFUN([my_fingerprint], [$magic1])" > $top_srcdir/m4/foo.m4
   $MAKE nil
   $FGREP FINGERPRINT Makefile # for debugging
-  $FGREP $hash1 Makefile
+  $FGREP $magic1 Makefile
 
   $sleep
-  echo "AC_DEFUN([my_fingerprint], [$hash2])" > $top_srcdir/m4/foo.m4
+  echo "AC_DEFUN([my_fingerprint], [$magic2])" > $top_srcdir/m4/foo.m4
   $MAKE nil
   $FGREP FINGERPRINT Makefile # for debugging
-  $FGREP $hash1 Makefile && Exit 1
-  $FGREP $hash2 Makefile
+  $FGREP $magic1 Makefile && Exit 1
+  $FGREP $magic2 Makefile
 
   $sleep
   echo "m4_include([m4/bar.m4])" > $top_srcdir/m4/foo.m4
-  echo "AC_DEFUN([my_fingerprint], [$hash3])" > $top_srcdir/m4/bar.m4
+  echo "AC_DEFUN([my_fingerprint], [$magic3])" > $top_srcdir/m4/bar.m4
   $MAKE nil
   $FGREP FINGERPRINT Makefile # for debugging
-  $FGREP $hash1 Makefile && Exit 1
-  $FGREP $hash2 Makefile && Exit 1
-  $FGREP $hash3 Makefile
+  $FGREP $magic1 Makefile && Exit 1
+  $FGREP $magic2 Makefile && Exit 1
+  $FGREP $magic3 Makefile
 
   $sleep
-  echo "AC_DEFUN([my_fingerprint], [$hash1])" > $top_srcdir/m4/bar.m4
+  echo "AC_DEFUN([my_fingerprint], [$magic1])" > $top_srcdir/m4/bar.m4
   $MAKE nil
-  $FGREP $hash2 Makefile && Exit 1
-  $FGREP $hash3 Makefile && Exit 1
-  $FGREP $hash1 Makefile
+  $FGREP $magic2 Makefile && Exit 1
+  $FGREP $magic3 Makefile && Exit 1
+  $FGREP $magic1 Makefile
 
   $sleep
   echo "AC_DEFUN([my_fingerprint], [DummyValue])" > $top_srcdir/m4/foo.m4
   echo "AC_DEFUN([AM_UNUSED], [NoSuchMacro])" > $top_srcdir/m4/bar.m4
   $MAKE nil # required to work around limitation of GNU make 3.82
   $MAKE distcheck
-  $FGREP $hash1 Makefile && Exit 1 # sanity check
-  $FGREP $hash2 Makefile && Exit 1 # likewise
-  $FGREP $hash3 Makefile && Exit 1 # likewise
+  $FGREP $magic1 Makefile && Exit 1 # sanity check
+  $FGREP $magic2 Makefile && Exit 1 # likewise
+  $FGREP $magic3 Makefile && Exit 1 # likewise
 
   $MAKE distclean
 
diff --git a/tests/remake11.test b/tests/remake11.test
index 7754867..e7a8982 100755
--- a/tests/remake11.test
+++ b/tests/remake11.test
@@ -26,10 +26,10 @@ set -e
 
 ocwd=`pwd` || Exit 1
 
-hash1=7532aa4708e8320c8c7098a5e3a1ec88aafb074f
-hash2=99368830db9954b4d9fecd04d3996d9acea7129f
+magic1=::MagicStringOne::
+magic2=__MagicStringTwo__
 
-echo "AC_SUBST([FOO], [$hash1])" >> configure.in
+echo "AC_SUBST([FOO], [$magic1])" >> configure.in
 
 echo "@FOO@" > bar.in
 echo "AC_CONFIG_FILES([bar])" >> configure.in
@@ -63,11 +63,11 @@ $AUTOCONF
 ./configure
 
 for f in configure config.status $makefiles_list $bar_list; do
-  $FGREP "$hash1" $f
+  $FGREP "$magic1" $f
 done
 
 $sleep
-sed "s/$hash1/$hash2/" configure.in >configure.tmp
+sed "s/$magic1/$magic2/" configure.in >configure.tmp
 mv -f configure.tmp configure.in
 
 cd "$bottom"
@@ -75,9 +75,9 @@ $MAKE
 cd "$ocwd"
 
 for f in configure config.status $makefiles_list $bar_list; do
-  $FGREP "$hash2" $f
+  $FGREP "$magic2" $f
 done
-$FGREP "$hash1" configure config.status $makefiles_list $bar_list && Exit 1
+$FGREP "$magic1" configure config.status $makefiles_list $bar_list && Exit 1
 
 $MAKE distcheck
 
diff --git a/tests/remake12.test b/tests/remake12.test
index f031a96..a4e8b1a 100755
--- a/tests/remake12.test
+++ b/tests/remake12.test
@@ -22,9 +22,9 @@ required=GNUmake
 
 set -e
 
-hash1=7532aa4708e8320c8c7098a5e3a1ec88aafb074f
-hash2=99368830db9954b4d9fecd04d3996d9acea7129f
-hash3=36fe4f389c0a835dfcdb0f58a8909eab43189af1
+magic1=::MagicStringOne::
+magic2=__MagicStringTwo__
+magic3=%%MagicStringThree%%
 
 cat > configure.in <<END
 AC_INIT([$me], [1.0])
@@ -36,7 +36,7 @@ END
 
 cat > zardoz.am <<END
 EXTRA_DIST = Makefile
-#H: $hash1
+#H: $magic1
 END
 
 cat > Makefile <<END
@@ -53,8 +53,8 @@ $AUTOMAKE
 
 $MAKE nil
 grep '^#H:' zardoz.in # for debugging
-$FGREP $hash1 zardoz
-$FGREP $hash1 zardoz.in
+$FGREP $magic1 zardoz
+$FGREP $magic1 zardoz.in
 $MAKE distcheck
 $MAKE distclean # this shouldn't remove Makefile
 ls -l
@@ -63,7 +63,7 @@ test -f Makefile
 ./configure
 
 $sleep
-sed "s/%HASH3%/$hash3/" >> Makefile <<'END'
+sed "s/%MAGIC3%/$magic3/" >> Makefile <<'END'
 my-check:
        ls -l . $(srcdir) ;: for debugging
        test -f $(srcdir)/quux.am
@@ -73,7 +73,7 @@ my-check:
        test ! -r $(srcdir)/zardoz.am
        test ! -r $(srcdir)/zardoz.in
        grep FOO zardoz ;: for debugging
-       test x'$(FOO)' = x'%HASH3%'
+       test x'$(FOO)' = x'%MAGIC3%'
 test:
        ls -l ;: for debugging
        test x'$(FOO)' = x'dummy'
 .PHONY: test my-check
 END
-sed "s/^#H:.*/#H: $hash2/" zardoz.am > t
+sed "s/^#H:.*/#H: $magic2/" zardoz.am > t
 cat >> t <<'END'
 # used by "make distcheck" below
 check-local: my-check
@@ -88,9 +88,9 @@ mv -f t zardoz.am
 cat zardoz.am # for debugging
 $MAKE nil
 $FGREP my-check zardoz # sanity check
-$FGREP $hash1 zardoz zardoz.in && Exit 1
-$FGREP $hash2 zardoz
-$FGREP $hash2 zardoz.in
+$FGREP $magic1 zardoz zardoz.in && Exit 1
+$FGREP $magic2 zardoz
+$FGREP $magic2 zardoz.in
 
 ./configure
 
@@ -102,13 +102,13 @@ cat configure.in # for debugging
 sed '/^#H:/d' zardoz.am > quux.am
 echo 'FOO = dummy' >> quux.am
 echo 'BAR = $(BAZ)' > top.in
-echo "BAZ = $hash3" > bot.in
+echo "BAZ = $magic3" > bot.in
 $MAKE test
 $FGREP my-check zardoz # sanity check
-$FGREP $hash3 quux.in && Exit 1
-$FGREP $hash3 zardoz
-$FGREP $hash1 zardoz && Exit 1
-$FGREP $hash2 zardoz && Exit 1
+$FGREP $magic3 quux.in && Exit 1
+$FGREP $magic3 zardoz
+$FGREP $magic1 zardoz && Exit 1
+$FGREP $magic2 zardoz && Exit 1
 # After the remake above, the files `zardoz.am' and `zardoz.in'
 # should be no more needed
 echo 'endif' > zardoz.am # put in syntax error
diff --git a/tests/remake9a.test b/tests/remake9a.test
index 3dd8a20..55e15ae 100755
--- a/tests/remake9a.test
+++ b/tests/remake9a.test
@@ -22,8 +22,8 @@ required=GNUmake
 
 set -e
 
-hash1=7532aa4708e8320c8c7098a5e3a1ec88aafb074f
-hash2=99368830db9954b4d9fecd04d3996d9acea7129f
+magic1=::MagicStringOne::
+magic2=__MagicStringTwo__
 
 cat >> configure.in <<END
 FINGERPRINT=BadBadBad
@@ -73,29 +73,29 @@ for vpath in : false; do
   $MAKE # should be no-op
 
   $sleep
-  sed "s/^\\(FINGERPRINT\\)=.*/\\1=$hash1/" $srcdir/configure.in >t
+  sed "s/^\\(FINGERPRINT\\)=.*/\\1=$magic1/" $srcdir/configure.in >t
   mv -f t $srcdir/configure.in
   $MAKE nil
   $FGREP FINGERPRINT Makefile # for debugging
-  $FGREP $hash1 Makefile
-  test x"`./foo.sh`" = x"$hash1"
+  $FGREP $magic1 Makefile
+  test x"`./foo.sh`" = x"$magic1"
 
   $sleep
-  echo 'sed "s/^\\(FINGERPRINT\\)=.*/\\1='$hash2'/"' \
+  echo 'sed "s/^\\(FINGERPRINT\\)=.*/\\1='$magic2'/"' \
     > $srcdir/tweak-configure-in
   $MAKE nil
   $FGREP FINGERPRINT Makefile # for debugging
-  $FGREP $hash1 Makefile && Exit 1
-  $FGREP $hash2 Makefile
-  test x"`./foo.sh`" = x"$hash2"
+  $FGREP $magic1 Makefile && Exit 1
+  $FGREP $magic2 Makefile
+  test x"`./foo.sh`" = x"$magic2"
 
   $sleep
   echo cat > $srcdir/tweak-configure-in # no-op again
   sed "s/^\\(FINGERPRINT\\)=.*/\\1=DummyValue/" $srcdir/configure.in >t
   mv -f t $srcdir/configure.in
   $MAKE distcheck
-  $FGREP $hash1 Makefile && Exit 1 # sanity check
-  $FGREP $hash2 Makefile && Exit 1 # likewise
+  $FGREP $magic1 Makefile && Exit 1 # sanity check
+  $FGREP $magic2 Makefile && Exit 1 # likewise
 
   $MAKE distclean
 
diff --git a/tests/remake9b.test b/tests/remake9b.test
index 6038a49..680718c 100755
--- a/tests/remake9b.test
+++ b/tests/remake9b.test
@@ -22,8 +22,8 @@ required=GNUmake
 
 set -e
 
-hash1=7532aa4708e8320c8c7098a5e3a1ec88aafb074f
-hash2=99368830db9954b4d9fecd04d3996d9acea7129f
+magic1=::MagicStringOne::
+magic2=__MagicStringTwo__
 
 cat >> configure.in <<END
 AC_OUTPUT
@@ -75,29 +75,29 @@ for vpath in : false; do
   $MAKE # should be no-op
 
   $sleep
-  sed "s/^\\(FINGERPRINT\\) *=.*/\\1 = $hash1/" $srcdir/Makefile.am >t
+  sed "s/^\\(FINGERPRINT\\) *=.*/\\1 = $magic1/" $srcdir/Makefile.am >t
   mv -f t $srcdir/Makefile.am
   $MAKE nil
   $FGREP FINGERPRINT Makefile # for debugging
-  $FGREP $hash1 Makefile
-  test x"`./foo.sh`" = x"$hash1"
+  $FGREP $magic1 Makefile
+  test x"`./foo.sh`" = x"$magic1"
 
   $sleep
-  echo 'sed "s/^\\(FINGERPRINT\\) *=.*/\\1 = '$hash2'/"' \
+  echo 'sed "s/^\\(FINGERPRINT\\) *=.*/\\1 = '$magic2'/"' \
     > $srcdir/tweak-makefile-am
   $MAKE nil
   $FGREP FINGERPRINT Makefile # for debugging
-  $FGREP $hash1 Makefile && Exit 1
-  $FGREP $hash2 Makefile
-  test x"`./foo.sh`" = x"$hash2"
+  $FGREP $magic1 Makefile && Exit 1
+  $FGREP $magic2 Makefile
+  test x"`./foo.sh`" = x"$magic2"
 
   $sleep
   echo cat > $srcdir/tweak-makefile-am # no-op again
   sed "s/^\\(FINGERPRINT\\) *=.*/\\1 = DummyValue/" $srcdir/Makefile.am >t
   mv -f t $srcdir/Makefile.am
   $MAKE distcheck
-  $FGREP $hash1 Makefile && Exit 1 # sanity check
-  $FGREP $hash2 Makefile && Exit 1 # likewise
+  $FGREP $magic1 Makefile && Exit 1 # sanity check
+  $FGREP $magic2 Makefile && Exit 1 # likewise
 
   $MAKE distclean
 
diff --git a/tests/remake9c.test b/tests/remake9c.test
index 23600f4..94d8c74 100755
--- a/tests/remake9c.test
+++ b/tests/remake9c.test
@@ -22,8 +22,8 @@ required=GNUmake
 
 set -e
 
-hash1=7532aa4708e8320c8c7098a5e3a1ec88aafb074f
-hash2=99368830db9954b4d9fecd04d3996d9acea7129f
+magic1=::MagicStringOne::
+magic2=__MagicStringTwo__
 
 cat >> configure.in <<END
 FINGERPRINT='my_fingerprint'
@@ -78,27 +78,27 @@ for vpath in : false; do
   $MAKE # should be no-op
 
   $sleep
-  echo "AC_DEFUN([my_fingerprint], [$hash1])" > $srcdir/acinclude.m4
+  echo "AC_DEFUN([my_fingerprint], [$magic1])" > $srcdir/acinclude.m4
   $MAKE nil
   $FGREP FINGERPRINT Makefile # for debugging
-  $FGREP $hash1 Makefile
-  test x"`./foo.sh`" = x"$hash1"
+  $FGREP $magic1 Makefile
+  test x"`./foo.sh`" = x"$magic1"
 
   $sleep
-  echo "echo 'AC_DEFUN([my_fingerprint], [$hash2])'" \
+  echo "echo 'AC_DEFUN([my_fingerprint], [$magic2])'" \
     > $srcdir/tweak-acinclude-m4
   $MAKE nil
   $FGREP FINGERPRINT Makefile # for debugging
-  $FGREP $hash1 Makefile && Exit 1
-  $FGREP $hash2 Makefile
-  test x"`./foo.sh`" = x"$hash2"
+  $FGREP $magic1 Makefile && Exit 1
+  $FGREP $magic2 Makefile
+  test x"`./foo.sh`" = x"$magic2"
 
   $sleep
   echo : > $srcdir/tweak-acinclude-m4 # no-op again
   echo "AC_DEFUN([my_fingerprint], [DummyValue])" > $srcdir/acinclude.m4
   $MAKE distcheck
-  $FGREP $hash1 Makefile && Exit 1 # sanity check
-  $FGREP $hash2 Makefile && Exit 1 # likewise
+  $FGREP $magic1 Makefile && Exit 1 # sanity check
+  $FGREP $magic2 Makefile && Exit 1 # likewise
 
   $MAKE distclean
 
diff --git a/tests/remake9d.test b/tests/remake9d.test
index 52975e4..02ccb2f 100755
--- a/tests/remake9d.test
+++ b/tests/remake9d.test
@@ -22,8 +22,8 @@ required=GNUmake
 
 set -e
 
-hash1=7532aa4708e8320c8c7098a5e3a1ec88aafb074f
-hash2=99368830db9954b4d9fecd04d3996d9acea7129f
+magic1=::MagicStringOne::
+magic2=__MagicStringTwo__
 
 cat >> configure.in <<END
 FINGERPRINT='my_fingerprint'
@@ -78,27 +78,27 @@ for vpath in : false; do
   $MAKE # should be no-op
 
   $sleep
-  echo "AC_DEFUN([my_fingerprint], [$hash1])dnl %%%" >> $srcdir/aclocal.m4
+  echo "AC_DEFUN([my_fingerprint], [$magic1])dnl %%%" >> $srcdir/aclocal.m4
   $MAKE nil
   $FGREP FINGERPRINT Makefile # for debugging
-  $FGREP $hash1 Makefile
-  test x"`./foo.sh`" = x"$hash1"
+  $FGREP $magic1 Makefile
+  test x"`./foo.sh`" = x"$magic1"
 
   $sleep
-  echo "sed 's/.*dnl *%%%.*/AC_DEFUN([my_fingerprint], [$hash2])/'" \
+  echo "sed 's/.*dnl *%%%.*/AC_DEFUN([my_fingerprint], [$magic2])/'" \
     > $srcdir/tweak-aclocal-m4
   $MAKE nil
   $FGREP FINGERPRINT Makefile # for debugging
-  $FGREP $hash1 Makefile && Exit 1
-  $FGREP $hash2 Makefile
-  test x"`./foo.sh`" = x"$hash2"
+  $FGREP $magic1 Makefile && Exit 1
+  $FGREP $magic2 Makefile
+  test x"`./foo.sh`" = x"$magic2"
 
   $sleep
   echo cat > $srcdir/tweak-aclocal-m4 # no-op again
   echo 'AC_DEFUN([my_fingerprint], [DummyValue])' >> $srcdir/aclocal.m4
   $MAKE distcheck
-  $FGREP $hash1 Makefile && Exit 1 # sanity check
-  $FGREP $hash2 Makefile && Exit 1 # likewise
+  $FGREP $magic1 Makefile && Exit 1 # sanity check
+  $FGREP $magic2 Makefile && Exit 1 # likewise
 
   $MAKE distclean
 
-- 
1.7.1

From b9f8c4c4a8442e5ce57f4d08502ebe8fb6b7d337 Mon Sep 17 00:00:00 2001
From: Stefano Lattarini <address@hidden>
Date: Fri, 13 Aug 2010 11:50:31 +0200
Subject: [PATCH] Tests: extend checks on remake rules.

This adds proper semantical tests (i.e. run make to check the
rebuild rules are correctly triggered) in addition to tentative
grepping of the generated Makefile.in(s).

* tests/remake.test: Enable `errexit' shell flag, and related
changes.  Modernize `configure.in'.  Add trailing `:' command.
Improve heading comments, and add a reference to new sister test
remake1a.test.
* tests/remake3.test: Likewise (but with sister test being
remake3a.test).
* tests/remake2.test: Improve heading comments.  Enable `errexit'
shell flag, and related changes.  Modernize `configure.in'.  Make
grepping of `Makefile.in' slightly stricter.  Add trailing `:'
command.
* tests/remake5.test: Also run the `distcheck' target.  Add
trailing `:' command.  Use proper m4 quoting in configure.in.
* tests/remake4.test: Prefer `$me' over hard-coded test name.
* tests/remake7.test: Use the `configure.in' stub created by
./defs, rather than writing it from scratch.
* tests/remake6.test: Likewise.  Also, add trailing `:' command,
and ensure verbose printing of captured make output.
* tests/remake1a.test: New test, sister of remake.test.
* tests/remake3a.test: New test, sister of remake3.test.
* tests/remake8a.test: New test.
* tests/remake8b.test: Likewise.
* tests/remake9a.test: Likewise.
* tests/remake9b.test: Likewise.
* tests/remake9c.test: Likewise.
* tests/remake9d.test: Likewise.
* tests/remake10a.test: Likewise.
* tests/remake10b.test: Likewise.
* tests/remake10c.test: Likewise.
* tests/remake11.test: Likewise.
* tests/remake12.test: Likewise.
* tests/Makefile.am (TESTS): Updated.
---
 ChangeLog            |   38 ++++++++++
 tests/Makefile.am    |   13 ++++
 tests/Makefile.in    |   13 ++++
 tests/remake.test    |   24 ++++--
 tests/remake10a.test |  108 ++++++++++++++++++++++++++++
 tests/remake10b.test |  107 +++++++++++++++++++++++++++
 tests/remake10c.test |  112 +++++++++++++++++++++++++++++
 tests/remake11.test  |   84 +++++++++++++++++++++
 tests/remake12.test  |  122 +++++++++++++++++++++++++++++++
 tests/remake1a.test  |   57 +++++++++++++++
 tests/remake2.test   |   26 +++++---
 tests/remake3.test   |   21 ++++--
 tests/remake3a.test  |   75 +++++++++++++++++++
 tests/remake4.test   |    6 +-
 tests/remake5.test   |    9 ++-
 tests/remake6.test   |   20 +++---
 tests/remake7.test   |   11 ++--
 tests/remake8a.test  |  193 +++++++++++++++++++++++++++++++++++++++++++++++++
 tests/remake8b.test  |  195 ++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/remake9a.test  |  106 +++++++++++++++++++++++++++
 tests/remake9b.test  |  108 ++++++++++++++++++++++++++++
 tests/remake9c.test  |  109 ++++++++++++++++++++++++++++
 tests/remake9d.test  |  109 ++++++++++++++++++++++++++++
 23 files changed, 1623 insertions(+), 43 deletions(-)
 create mode 100755 tests/remake10a.test
 create mode 100755 tests/remake10b.test
 create mode 100755 tests/remake10c.test
 create mode 100755 tests/remake11.test
 create mode 100755 tests/remake12.test
 create mode 100755 tests/remake1a.test
 create mode 100755 tests/remake3a.test
 create mode 100755 tests/remake8a.test
 create mode 100755 tests/remake8b.test
 create mode 100755 tests/remake9a.test
 create mode 100755 tests/remake9b.test
 create mode 100755 tests/remake9c.test
 create mode 100755 tests/remake9d.test

diff --git a/ChangeLog b/ChangeLog
index 5afdc53..d605b22 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,41 @@
+2010-12-06  Stefano Lattarini  <address@hidden>
+
+       Tests: extend checks on remake rules.
+       This adds proper semantical tests (i.e. run make to check the
+       rebuild rules are correctly triggered) in addition to tentative
+       grepping of the generated Makefile.in(s).
+       * tests/remake.test: Enable `errexit' shell flag, and related
+       changes.  Modernize `configure.in'.  Add trailing `:' command.
+       Improve heading comments, and add a reference to new sister test
+       remake1a.test.
+       * tests/remake3.test: Likewise (but with sister test being
+       remake3a.test).
+       * tests/remake2.test: Improve heading comments.  Enable `errexit'
+       shell flag, and related changes.  Modernize `configure.in'.  Make
+       grepping of `Makefile.in' slightly stricter.  Add trailing `:'
+       command.
+       * tests/remake5.test: Also run the `distcheck' target.  Add
+       trailing `:' command.  Use proper m4 quoting in configure.in.
+       * tests/remake4.test: Prefer `$me' over hard-coded test name.
+       * tests/remake7.test: Use the `configure.in' stub created by
+       ./defs, rather than writing it from scratch.
+       * tests/remake6.test: Likewise.  Also, add trailing `:' command,
+       and ensure verbose printing of captured make output.
+       * tests/remake1a.test: New test, sister of remake.test.
+       * tests/remake3a.test: New test, sister of remake3.test.
+       * tests/remake8a.test: New test.
+       * tests/remake8b.test: Likewise.
+       * tests/remake9a.test: Likewise.
+       * tests/remake9b.test: Likewise.
+       * tests/remake9c.test: Likewise.
+       * tests/remake9d.test: Likewise.
+       * tests/remake10a.test: Likewise.
+       * tests/remake10b.test: Likewise.
+       * tests/remake10c.test: Likewise.
+       * tests/remake11.test: Likewise.
+       * tests/remake12.test: Likewise.
+       * tests/Makefile.am (TESTS): Updated.
+
 2010-12-10  Ralf Wildenhues  <address@hidden>
 
        Avoid running installed automake from 'libtool --help'.
diff --git a/tests/Makefile.am b/tests/Makefile.am
index dab04e3..8b81932 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -614,12 +614,25 @@ python12.test \
 recurs.test \
 recurs2.test \
 remake.test \
+remake1a.test \
 remake2.test \
 remake3.test \
+remake3a.test \
 remake4.test \
 remake5.test \
 remake6.test \
 remake7.test \
+remake8a.test \
+remake8b.test \
+remake9a.test \
+remake9b.test \
+remake9c.test \
+remake9d.test \
+remake10a.test \
+remake10b.test \
+remake10c.test \
+remake11.test \
+remake12.test \
 regex.test \
 req.test \
 reqd.test \
diff --git a/tests/Makefile.in b/tests/Makefile.in
index de21f43..0d494e7 100644
--- a/tests/Makefile.in
+++ b/tests/Makefile.in
@@ -881,12 +881,25 @@ python12.test \
 recurs.test \
 recurs2.test \
 remake.test \
+remake1a.test \
 remake2.test \
 remake3.test \
+remake3a.test \
 remake4.test \
 remake5.test \
 remake6.test \
 remake7.test \
+remake8a.test \
+remake8b.test \
+remake9a.test \
+remake9b.test \
+remake9c.test \
+remake9d.test \
+remake10a.test \
+remake10b.test \
+remake10c.test \
+remake11.test \
+remake12.test \
 regex.test \
 req.test \
 reqd.test \
diff --git a/tests/remake.test b/tests/remake.test
index 9c86b1b..4d3036b 100755
--- a/tests/remake.test
+++ b/tests/remake.test
@@ -1,5 +1,6 @@
 #! /bin/sh
-# Copyright (C) 1996, 2000, 2001, 2002  Free Software Foundation, Inc.
+# Copyright (C) 1996, 2000, 2001, 2002, 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
@@ -14,20 +15,27 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-# Make sure remaking rules in subdir are correctly generated.
+# Weak "grepping" test trying to ensure that remaking rules in a subdir
+# are correctly generated.
+# See also sister functional test `remake1a.test'.
 
 . ./defs || Exit 1
 
-cat > configure.in << 'END'
-AC_INIT
-AM_INIT_AUTOMAKE(nonesuch, nonesuch)
-AC_OUTPUT(sub/Makefile)
+set -e
+
+cat > configure.in <<END
+AC_INIT([$me], [1.0])
+AM_INIT_AUTOMAKE
+AC_CONFIG_FILES([sub/Makefile])
+AC_OUTPUT
 END
 
 mkdir sub
 : > sub/Makefile.am
 
-$ACLOCAL || Exit 1
-$AUTOMAKE || Exit 1
+$ACLOCAL
+$AUTOMAKE
 
 grep '^Makefile' sub/Makefile.in
+
+:
diff --git a/tests/remake10a.test b/tests/remake10a.test
new file mode 100755
index 0000000..cda72b0
--- /dev/null
+++ b/tests/remake10a.test
@@ -0,0 +1,108 @@
+#! /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/>.
+
+# Test remake rules for m4 files included (also recursively) by
+# configure.ac.
+# Keep in sync with sister tests `remake10b.test' and `remake10c.test'.
+
+required=GNUmake
+. ./defs || Exit 1
+
+set -e
+
+magic1=::MagicStringOne::
+magic2=__MagicStringTwo__
+magic3=%%MagicStringThree%%
+
+cat >> configure.in <<END
+m4_include([foo.m4])
+AC_SUBST([FINGERPRINT], [my_fingerprint])
+AC_OUTPUT
+END
+
+cat > Makefile.am <<'END'
+.PHONY: nil
+nil:
+## Used by "make distcheck" later.
+check-local:
+       test -f $(top_srcdir)/foo.m4
+       test ! -r $(top_srcdir)/bar.m4
+       test x'$(FINGERPRINT)' = x'DummyValue'
+END
+
+echo 'm4_define([my_fingerprint], [BadBadBad])' > foo.m4
+
+$sleep # so that generated autotools files will be newer than prerequisites
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+for vpath in : false; do
+
+  if $vpath; then
+    mkdir build
+    cd build
+    top_srcdir=..
+  else
+    top_srcdir=.
+  fi
+
+  $top_srcdir/configure
+  $MAKE # should be no-op
+
+  $sleep
+  echo "m4_define([my_fingerprint], [$magic1])" > $top_srcdir/foo.m4
+  $MAKE nil
+  $FGREP FINGERPRINT Makefile # for debugging
+  $FGREP $magic1 Makefile
+
+  $sleep
+  echo "m4_define([my_fingerprint], [$magic2])" > $top_srcdir/foo.m4
+  $MAKE nil
+  $FGREP FINGERPRINT Makefile # for debugging
+  $FGREP $magic1 Makefile && Exit 1
+  $FGREP $magic2 Makefile
+
+  $sleep
+  echo "m4_include([bar.m4])" > $top_srcdir/foo.m4
+  echo "m4_define([my_fingerprint], [$magic3])" > $top_srcdir/bar.m4
+  $MAKE nil
+  $FGREP FINGERPRINT Makefile # for debugging
+  $FGREP $magic1 Makefile && Exit 1
+  $FGREP $magic2 Makefile && Exit 1
+  $FGREP $magic3 Makefile
+
+  $sleep
+  echo "m4_define([my_fingerprint], [$magic1])" > $top_srcdir/bar.m4
+  $MAKE nil
+  $FGREP $magic2 Makefile && Exit 1
+  $FGREP $magic3 Makefile && Exit 1
+  $FGREP $magic1 Makefile
+
+  $sleep
+  echo "m4_define([my_fingerprint], [DummyValue])" > $top_srcdir/foo.m4
+  $MAKE distcheck
+  $FGREP $magic1 Makefile && Exit 1 # sanity check
+  $FGREP $magic2 Makefile && Exit 1 # likewise
+  $FGREP $magic3 Makefile && Exit 1 # likewise
+
+  $MAKE distclean
+
+  cd $top_srcdir
+
+done
+
+:
diff --git a/tests/remake10b.test b/tests/remake10b.test
new file mode 100755
index 0000000..53a7d13
--- /dev/null
+++ b/tests/remake10b.test
@@ -0,0 +1,107 @@
+#! /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/>.
+
+# Test remake rules for am files included (also recursively) by
+# Makefile.am.
+# Keep in sync with sister tests `remake10a.test' and `remake10c.test'.
+
+required=GNUmake
+. ./defs || Exit 1
+
+set -e
+
+magic1=::MagicStringOne::
+magic2=__MagicStringTwo__
+magic3=%%MagicStringThree%%
+
+cat >> configure.in <<'END'
+AC_OUTPUT
+END
+
+cat > Makefile.am <<'END'
+.PHONY: nil
+nil:
+include foo.am
+## Used by "make distcheck" later.
+check-local:
+       test -f $(top_srcdir)/foo.am
+       test ! -r $(top_srcdir)/bar.am
+       test x'$(FINGERPRINT)' = x'DummyValue'
+END
+
+echo 'FINGERPRINT = BadBadBad' > foo.am
+
+$sleep # so that generated autotools files will be newer than prerequisites
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+for vpath in : false; do
+
+  if $vpath; then
+    mkdir build
+    cd build
+    top_srcdir=..
+  else
+    top_srcdir=.
+  fi
+
+  $top_srcdir/configure
+  $MAKE # should be no-op
+
+  $sleep
+  echo "FINGERPRINT = $magic1" > $top_srcdir/foo.am
+  $MAKE nil
+  $FGREP FINGERPRINT Makefile # for debugging
+  $FGREP $magic1 Makefile
+
+  $sleep
+  echo "FINGERPRINT = $magic2" > $top_srcdir/foo.am
+  $MAKE nil
+  $FGREP FINGERPRINT Makefile # for debugging
+  $FGREP $magic1 Makefile && Exit 1
+  $FGREP $magic2 Makefile
+
+  $sleep
+  echo 'include $(top_srcdir)/bar.am' > $top_srcdir/foo.am
+  echo "FINGERPRINT = $magic3" > $top_srcdir/bar.am
+  $MAKE nil
+  $FGREP FINGERPRINT Makefile # for debugging
+  $FGREP $magic1 Makefile && Exit 1
+  $FGREP $magic2 Makefile && Exit 1
+  $FGREP $magic3 Makefile
+
+  $sleep
+  echo "FINGERPRINT = $magic1" > $top_srcdir/bar.am
+  $MAKE nil
+  $FGREP $magic2 Makefile && Exit 1
+  $FGREP $magic3 Makefile && Exit 1
+  $FGREP $magic1 Makefile
+
+  $sleep
+  echo "FINGERPRINT = DummyValue" > $top_srcdir/foo.am
+  $MAKE distcheck
+  $FGREP $magic1 Makefile && Exit 1 # sanity check
+  $FGREP $magic2 Makefile && Exit 1 # likewise
+  $FGREP $magic3 Makefile && Exit 1 # likewise
+
+  $MAKE distclean
+
+  cd $top_srcdir
+
+done
+
+:
diff --git a/tests/remake10c.test b/tests/remake10c.test
new file mode 100755
index 0000000..96e2c0d
--- /dev/null
+++ b/tests/remake10c.test
@@ -0,0 +1,112 @@
+#! /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/>.
+
+# Test remake rules for m4 files included (also recursively) by
+# aclocal.m4.
+# Keep in sync with sister tests `remake10a.test' and `remake10b.test'.
+
+required=GNUmake
+. ./defs || Exit 1
+
+set -e
+
+magic1=::MagicStringOne::
+magic2=__MagicStringTwo__
+magic3=%%MagicStringThree%%
+
+cat >> configure.in <<END
+FINGERPRINT='my_fingerprint'
+AC_SUBST([FINGERPRINT])
+AC_OUTPUT
+END
+
+cat > Makefile.am <<'END'
+ACLOCAL_AMFLAGS = -I m4
+.PHONY: nil
+nil:
+## Used by "make distcheck" later.
+check-local:
+       test -f $(top_srcdir)/m4/foo.m4
+       test ! -r $(top_srcdir)/m4/bar.m4
+       test x'$(FINGERPRINT)' = x'DummyValue'
+END
+
+mkdir m4
+echo 'AC_DEFUN([my_fingerprint], [BadBadBad])' > m4/foo.m4
+
+$sleep # so that generated autotools files will be newer than prerequisites
+$ACLOCAL -I m4
+$AUTOCONF
+$AUTOMAKE
+
+for vpath in : false; do
+
+  if $vpath; then
+    mkdir build
+    cd build
+    top_srcdir=..
+  else
+    top_srcdir=.
+  fi
+
+  $top_srcdir/configure
+  $MAKE # should be no-op
+
+  $sleep
+  echo "AC_DEFUN([my_fingerprint], [$magic1])" > $top_srcdir/m4/foo.m4
+  $MAKE nil
+  $FGREP FINGERPRINT Makefile # for debugging
+  $FGREP $magic1 Makefile
+
+  $sleep
+  echo "AC_DEFUN([my_fingerprint], [$magic2])" > $top_srcdir/m4/foo.m4
+  $MAKE nil
+  $FGREP FINGERPRINT Makefile # for debugging
+  $FGREP $magic1 Makefile && Exit 1
+  $FGREP $magic2 Makefile
+
+  $sleep
+  echo "m4_include([m4/bar.m4])" > $top_srcdir/m4/foo.m4
+  echo "AC_DEFUN([my_fingerprint], [$magic3])" > $top_srcdir/m4/bar.m4
+  $MAKE nil
+  $FGREP FINGERPRINT Makefile # for debugging
+  $FGREP $magic1 Makefile && Exit 1
+  $FGREP $magic2 Makefile && Exit 1
+  $FGREP $magic3 Makefile
+
+  $sleep
+  echo "AC_DEFUN([my_fingerprint], [$magic1])" > $top_srcdir/m4/bar.m4
+  $MAKE nil
+  $FGREP $magic2 Makefile && Exit 1
+  $FGREP $magic3 Makefile && Exit 1
+  $FGREP $magic1 Makefile
+
+  $sleep
+  echo "AC_DEFUN([my_fingerprint], [DummyValue])" > $top_srcdir/m4/foo.m4
+  echo "AC_DEFUN([AM_UNUSED], [NoSuchMacro])" > $top_srcdir/m4/bar.m4
+  $MAKE nil # required to work around limitation of GNU make 3.82
+  $MAKE distcheck
+  $FGREP $magic1 Makefile && Exit 1 # sanity check
+  $FGREP $magic2 Makefile && Exit 1 # likewise
+  $FGREP $magic3 Makefile && Exit 1 # likewise
+
+  $MAKE distclean
+
+  cd $top_srcdir
+
+done
+
+:
diff --git a/tests/remake11.test b/tests/remake11.test
new file mode 100755
index 0000000..7eaad6c
--- /dev/null
+++ b/tests/remake11.test
@@ -0,0 +1,84 @@
+#! /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/>.
+
+# Test remake rules in deeply nested subdirectories, and with a lot
+# of files.  This is basically a mild stress test, ensuring that rebuild
+# rules don't break in obvious ways in a slightly "heavier than usual"
+# setup.
+
+required=GNUmake
+. ./defs || Exit 1
+
+set -e
+
+ocwd=`pwd` || Exit 1
+
+magic1=::MagicStringOne::
+magic2=__MagicStringTwo__
+
+echo "AC_SUBST([FOO], [$magic1])" >> configure.in
+
+echo "@FOO@" > bar.in
+echo "AC_CONFIG_FILES([bar])" >> configure.in
+for i in 0 1 2 3 4 5 6 7 8 9; do
+  d=${d+"$d/"}sub$i
+  echo "SUBDIRS = sub$i" > Makefile.am
+  echo "AC_CONFIG_FILES([$d/Makefile])" >> "$ocwd"/configure.in
+  echo "AC_CONFIG_FILES([$d/bar])" >> "$ocwd"/configure.in
+  mkdir sub$i
+  cd sub$i
+  echo "$d: @FOO@" > bar.in
+done
+echo AC_OUTPUT >> "$ocwd"/configure.in
+: > Makefile.am
+unset d i
+bottom=`pwd`
+
+cd "$ocwd"
+
+makefiles_am_list=`find . -name Makefile.am | LC_ALL=C sort`
+makefiles_list=`echo "$makefiles_am_list" | sed 's/\.am$//'`
+bar_in_list=`find . -name bar.in | LC_ALL=C sort`
+bar_list=`echo "$bar_in_list" | sed 's/\.in$//'`
+
+cat configure.in # useful for debugging
+
+$ACLOCAL
+$AUTOMAKE
+$AUTOCONF
+
+./configure
+
+for f in configure config.status $makefiles_list $bar_list; do
+  $FGREP "$magic1" $f
+done
+
+$sleep
+sed "s/$magic1/$magic2/" configure.in >configure.tmp
+mv -f configure.tmp configure.in
+
+cd "$bottom"
+$MAKE
+cd "$ocwd"
+
+for f in configure config.status $makefiles_list $bar_list; do
+  $FGREP "$magic2" $f
+done
+$FGREP "$magic1" configure config.status $makefiles_list $bar_list && Exit 1
+
+$MAKE distcheck
+
+:
diff --git a/tests/remake12.test b/tests/remake12.test
new file mode 100755
index 0000000..63ea39d
--- /dev/null
+++ b/tests/remake12.test
@@ -0,0 +1,122 @@
+#! /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/>.
+
+# Test basic remake rules for Makefiles with non-default names
+# and/or with multiple sources.
+
+required=GNUmake
+. ./defs || Exit 1
+
+set -e
+
+magic1=::MagicStringOne::
+magic2=__MagicStringTwo__
+magic3=%%MagicStringThree%%
+
+cat > configure.in <<END
+AC_INIT([$me], [1.0])
+AM_INIT_AUTOMAKE
+AC_CONFIG_FILES([zardoz])
+AC_CONFIG_LINKS([Makefile:Makefile])
+AC_OUTPUT
+END
+
+cat > zardoz.am <<END
+EXTRA_DIST = Makefile
+#H: $magic1
+END
+
+cat > Makefile <<END
+include zardoz
+nil:
+.PHONY: nil
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+./configure
+
+$MAKE nil
+grep '^#H:' zardoz.in # for debugging
+$FGREP $magic1 zardoz
+$FGREP $magic1 zardoz.in
+$MAKE distcheck
+$MAKE distclean # this shouldn't remove Makefile
+ls -l
+test -f Makefile
+
+./configure
+
+$sleep
+sed "s/%MAGIC3%/$magic3/" >> Makefile <<'END'
+my-check:
+       ls -l . $(srcdir) ;: for debugging
+       test -f $(srcdir)/quux.am
+       test -f $(srcdir)/quux.in
+       test -f $(srcdir)/bot.in
+       test -f $(srcdir)/top.in
+       test ! -r $(srcdir)/zardoz.am
+       test ! -r $(srcdir)/zardoz.in
+       grep FOO zardoz ;: for debugging
+       test x'$(FOO)' = x'%MAGIC3%'
+test:
+       ls -l ;: for debugging
+       test x'$(FOO)' = x'dummy'
+.PHONY: test my-check
+END
+sed "s/^#H:.*/#H: $magic2/" zardoz.am > t
+cat >> t <<'END'
+# used by "make distcheck" below
+check-local: my-check
+END
+mv -f t zardoz.am
+cat zardoz.am # for debugging
+$MAKE nil
+$FGREP my-check zardoz # sanity check
+$FGREP $magic1 zardoz zardoz.in && Exit 1
+$FGREP $magic2 zardoz
+$FGREP $magic2 zardoz.in
+
+./configure
+
+$sleep
+sed 's/^\(AC_CONFIG_FILES\)(.*/\1([zardoz:top.in:quux.in:bot.in])/' \
+  <configure.in >t
+mv -f t configure.in
+cat configure.in # for debugging
+sed '/^#H:/d' zardoz.am > quux.am
+echo 'FOO = dummy' >> quux.am
+echo 'BAR = $(BAZ)' > top.in
+echo "BAZ = $magic3" > bot.in
+$MAKE test
+$FGREP my-check zardoz # sanity check
+$FGREP $magic3 quux.in && Exit 1
+$FGREP $magic3 zardoz
+$FGREP $magic1 zardoz && Exit 1
+$FGREP $magic2 zardoz && Exit 1
+# After the remake above, the files `zardoz.am' and `zardoz.in'
+# should be no more needed
+echo 'endif' > zardoz.am # put in syntax error
+$MAKE test
+rm -f zardoz.in zardoz.am # get rid of them
+$MAKE test
+
+echo 'FOO = $(BAR)' >> quux.am
+$MAKE distcheck
+
+:
diff --git a/tests/remake1a.test b/tests/remake1a.test
new file mode 100755
index 0000000..ce80c19
--- /dev/null
+++ b/tests/remake1a.test
@@ -0,0 +1,57 @@
+#! /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/>.
+
+# Make sure remaking rules in subdir are correctly generated.
+# See also sister "grepping" test `remake.test'.
+
+. ./defs || Exit 1
+
+fingerprint='=/FiNgErPrInT/='
+
+set -e
+
+cat > configure.in <<END
+AC_INIT([$me], [1.0])
+AM_INIT_AUTOMAKE
+AC_CONFIG_FILES([sub/Makefile])
+AC_OUTPUT
+END
+
+mkdir sub
+: > sub/Makefile.am
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+./configure
+
+# Rebuild rules should work even if there is no top-level
+# makefiles, if we are careful enough to trigger them only
+# in proper subdirs
+$sleep
+echo "# $fingerprint" > sub/Makefile.am
+cd sub
+$MAKE Makefile
+cd ..
+# Check that no spurious Makefile has been created in the
+# top-level directory.
+test ! -r Makefile
+# Check that the Makefile in the subdirectory has been properly
+# updated.
+$FGREP "$fingerprint" sub/Makefile
+
+:
diff --git a/tests/remake2.test b/tests/remake2.test
index 3b63dea..452e951 100755
--- a/tests/remake2.test
+++ b/tests/remake2.test
@@ -1,5 +1,6 @@
 #! /bin/sh
-# Copyright (C) 1996, 1997, 2000, 2001, 2002  Free Software Foundation, Inc.
+# Copyright (C) 1996, 1997, 2000, 2001, 2002, 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
@@ -14,20 +15,27 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-# Make sure remaking rules in subdir are correct.
+# Weak "grepping" test trying to ensure that remaking rules in subdir
+# are correct even when there is no upper-level Makefile.
+# TODO: we should really add also functional tests for this!
 
 . ./defs || Exit 1
 
-cat > configure.in << 'END'
-AC_INIT
-AM_INIT_AUTOMAKE(nonesuch, nonesuch)
-AC_OUTPUT(sub/Makefile)
+set -e
+
+cat > configure.in <<END
+AC_INIT([$me], [1.0])
+AM_INIT_AUTOMAKE
+AC_CONFIG_FILES([sub/Makefile])
+AC_OUTPUT
 END
 
 mkdir sub
 : > sub/Makefile.am
 
-$ACLOCAL || Exit 1
-$AUTOMAKE || Exit 1
+$ACLOCAL
+$AUTOMAKE
+
+grep '\$(AUTOMAKE).*sub/Makefile' sub/Makefile.in
 
-grep 'AUTOMAKE.*sub/Makefile' sub/Makefile.in
+:
diff --git a/tests/remake3.test b/tests/remake3.test
index 08ec16a..708dca8 100755
--- a/tests/remake3.test
+++ b/tests/remake3.test
@@ -1,5 +1,5 @@
 #! /bin/sh
-# Copyright (C) 2001, 2002  Free Software Foundation, Inc.
+# Copyright (C) 2001, 2002, 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
@@ -14,14 +14,17 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-# Make sure remaking rules work when there is no subdir Makefile.
+# Weak "grepping" test trying to ensure that remake rules work for files
+# in a subdirectory even when there is no Makefile for that subdirectory.
+# See also sister functional test `remake3a.test'.
 
 . ./defs || Exit 1
 
-cat > configure.in << 'END'
-AC_INIT
-AM_INIT_AUTOMAKE(nonesuch, nonesuch)
-AC_OUTPUT(Makefile sub/foo)
+set -e
+
+cat >> configure.in << 'END'
+AC_CONFIG_FILES([sub/foo])
+AC_OUTPUT
 END
 
 : > Makefile.am
@@ -29,7 +32,9 @@ END
 mkdir sub
 : > sub/foo.in
 
-$ACLOCAL || Exit 1
-$AUTOMAKE || Exit 1
+$ACLOCAL
+$AUTOMAKE
 
 grep '^sub/foo' Makefile.in
+
+:
diff --git a/tests/remake3a.test b/tests/remake3a.test
new file mode 100755
index 0000000..a58c462
--- /dev/null
+++ b/tests/remake3a.test
@@ -0,0 +1,75 @@
+#! /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/>.
+
+# Ensure that remake rules work for files in a subdirectory even when
+# there is no Makefile for that subdirectory.
+# See also sister "grepping" test `remake3.test'.
+
+. ./defs || Exit 1
+
+set -e
+
+cat >> configure.in << 'END'
+AC_CONFIG_FILES([sub/foo])
+AC_OUTPUT
+END
+
+cat > Makefile.am <<'END'
+all-local: sub/foo
+END
+
+mkdir sub
+: > sub/foo.in
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+# First a VPATH build.
+mkdir build
+cd build
+../configure
+$sleep
+test -f sub/foo
+test ! -s sub/foo
+echo '#GrepMe#' > ../sub/foo.in
+$MAKE
+grep '#GrepMe#' sub/foo
+
+cd ..
+
+# Now try an in-tree build.
+: > sub/foo.in # restore its original (empty) content
+./configure
+$sleep
+test -f sub/foo
+test ! -s sub/foo
+echo '#GrepMe#' > sub/foo.in
+$MAKE
+grep '#GrepMe#' sub/foo
+
+# Finally try to check the distribution.
+$sleep
+echo '%GrepMe%' > sub/foo.in
+cat >>Makefile.am <<END
+check-local:
+       grep '%GrepMe%' sub/foo
+END
+$MAKE
+grep "grep '%GrepMe%' sub/foo" Makefile.in # sanity check
+$MAKE distcheck
+
+:
diff --git a/tests/remake4.test b/tests/remake4.test
index d6dbed7..0621c90 100755
--- a/tests/remake4.test
+++ b/tests/remake4.test
@@ -1,5 +1,5 @@
 #! /bin/sh
-# Copyright (C) 2003  Free Software Foundation, Inc.
+# Copyright (C) 2003, 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
@@ -50,7 +50,9 @@ $MAKE
 $sleep
 touch aclocal.m4
 $MAKE distdir
-cd remake4-1.0
+cd $me-1.0
 test ! -f rebuild_ok
 ./configure
 $MAKE
+
+:
diff --git a/tests/remake5.test b/tests/remake5.test
index d353632..133f9a0 100755
--- a/tests/remake5.test
+++ b/tests/remake5.test
@@ -1,5 +1,5 @@
 #! /bin/sh
-# Copyright (C) 2003  Free Software Foundation, Inc.
+# Copyright (C) 2003, 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
@@ -25,7 +25,7 @@ set -e
 
 cat >>configure.in <<'EOF'
 AM_MAINTAINER_MODE
-m4_include(foo.m4)
+m4_include([foo.m4])
 if test ! -f rebuild_ok; then
   ACLOCAL=false
   AUTOMAKE=false
@@ -70,3 +70,8 @@ $sleep
 echo 'AC_SUBST([YIPPY_YIPPY_YEAH])' >foo.m4
 $MAKE
 grep YIPPY_YIPPY_YEAH Makefile
+
+# Try the distribution, for completeness.
+$MAKE distcheck
+
+:
diff --git a/tests/remake6.test b/tests/remake6.test
index a25e486..885bcb4 100755
--- a/tests/remake6.test
+++ b/tests/remake6.test
@@ -1,5 +1,5 @@
 #! /bin/sh
-# Copyright (C) 2008  Free Software Foundation, Inc.
+# Copyright (C) 2008, 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
@@ -17,12 +17,12 @@
 # Make sure remaking rules work when subdir Makefile.in has been removed.
 
 . ./defs || Exit 1
+
 set -e
 
-cat > configure.in << 'END'
-AC_INIT
-AM_INIT_AUTOMAKE(nonesuch, nonesuch)
-AC_OUTPUT(Makefile sub/Makefile)
+cat >> configure.in << 'END'
+AC_CONFIG_FILES([sub/Makefile])
+AC_OUTPUT
 END
 
 cat > Makefile.am <<'END'
@@ -42,23 +42,25 @@ $MAKE
 # only.
 
 rm -f Makefile.in
-$MAKE >stdout
+$MAKE >stdout || { cat stdout; Exit 1; }
 cat stdout
 test `grep -c " --run " stdout` -eq 1
 
 rm -f sub/Makefile.in
-$MAKE >stdout
+$MAKE >stdout || { cat stdout; Exit 1; }
 cat stdout
 test `grep -c " --run " stdout` -eq 1
 
 $sleep  # Let touched files appear newer.
 
 touch Makefile.am
-$MAKE >stdout
+$MAKE >stdout || { cat stdout; Exit 1; }
 cat stdout
 test `grep -c " --run " stdout` -eq 1
 
 touch sub/Makefile.am
-$MAKE >stdout
+$MAKE >stdout || { cat stdout; Exit 1; }
 cat stdout
 test `grep -c " --run " stdout` -eq 1
+
+:
diff --git a/tests/remake7.test b/tests/remake7.test
index 670f60b..66d4b9c 100755
--- a/tests/remake7.test
+++ b/tests/remake7.test
@@ -1,5 +1,5 @@
 #! /bin/sh
-# Copyright (C) 2008  Free Software Foundation, Inc.
+# Copyright (C) 2008, 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
@@ -17,12 +17,12 @@
 # Make sure remaking rules fail when they should.
 
 . ./defs || Exit 1
+
 set -e
 
-cat > configure.in << 'END'
-AC_INIT
-AM_INIT_AUTOMAKE(nonesuch, nonesuch)
-AC_OUTPUT(Makefile sub/Makefile)
+cat >> configure.in << 'END'
+AC_CONFIG_FILES([sub/Makefile])
+AC_OUTPUT
 END
 
 cat > Makefile.am <<'END'
@@ -67,4 +67,5 @@ $MAKE && Exit 1
 
 rm -f Makefile.in
 $MAKE && Exit 1
+
 :
diff --git a/tests/remake8a.test b/tests/remake8a.test
new file mode 100755
index 0000000..96fcc08
--- /dev/null
+++ b/tests/remake8a.test
@@ -0,0 +1,193 @@
+#! /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/>.
+
+# Test basic remake rules for Makefiles, for an *in-tree build*.
+# This testcase checks dependency of generated Makefile from Makefile.am,
+# configure.ac, acinclude.m4, aclocal.m4, and extra m4 files considered
+# by aclocal.
+# Keep this in sync with sister test `remake8b.test', which performs the
+# same checks for a VPATH build.
+
+required=GNUmake
+. ./defs || Exit 1
+
+set -e
+
+mv -f configure.in configure.stub
+
+cat > Makefile.am <<'END'
+all-local: foo
+foo:
+       echo '!Foo!' >$@
+check-local:
+       cat foo
+       grep '!Foo!' foo
+CLEANFILES = foo
+END
+
+cat configure.stub - > configure.in <<'END'
+AC_OUTPUT
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+srcdir='.' # to make syncing with remake8b.test easier.
+
+$srcdir/configure
+
+$MAKE
+cat foo
+grep '!Foo!' foo
+$MAKE distcheck
+
+rm -f foo
+
+# Modify just Makefile.am.
+
+$sleep
+
+cat > $srcdir/Makefile.am <<'END'
+all-local: bar
+bar:
+       echo '!Baz!' >$@
+check-local:
+       cat bar
+       grep '!Baz!' bar
+       test ! -r $(srcdir)/foo
+       test ! -r foo
+CLEANFILES = bar
+END
+
+$MAKE
+cat bar
+grep '!Baz!' bar
+test ! -r foo
+$MAKE distcheck
+
+rm -f bar
+
+# Modify Makefile.am and configure.in.
+
+$sleep
+
+cat > $srcdir/Makefile.am <<'END'
+all-local: quux
+check-local:
+       cat quux
+       grep '!Zardoz!' quux
+       test ! -r $(srcdir)/bar
+       test ! -r bar
+END
+
+cat $srcdir/configure.stub - > $srcdir/configure.in <<'END'
+AC_CONFIG_FILES([quux])
+AC_SUBST([QUUX], [Zardoz])
+AC_OUTPUT
+END
+
+cat > $srcdir/quux.in <<'END'
address@hidden@!
+END
+
+$MAKE
+cat quux
+grep '!Zardoz!' quux
+test ! -f bar
+$MAKE distcheck
+
+rm -f quux
+
+# Modify Makefile.am to add a directory of extra m4 files
+# considered by aclocal.
+
+$sleep
+
+mkdir $srcdir/m4
+
+cat > $srcdir/Makefile.am <<'END'
+ACLOCAL_AMFLAGS = -I m4
+all-local: quux
+check-local:
+       cat quux
+       grep '%Foo%' quux
+       test x'$(QUUX)' = x'%Foo%'
+END
+
+$MAKE # this should place aclocal flags in Makefile
+grep '.*-I m4' Makefile # sanity check
+
+# Modify configure.in and aclocal.m4.
+
+$sleep
+
+cat $srcdir/configure.stub - > $srcdir/configure.in <<'END'
+AC_CONFIG_FILES([quux])
+MY_CUSTOM_MACRO
+AC_OUTPUT
+END
+
+cat >> $srcdir/aclocal.m4 <<'END'
+AC_DEFUN([MY_CUSTOM_MACRO], [AC_SUBST([QUUX], [%Foo%])])
+END
+
+$MAKE
+cat quux
+grep '%Foo%' quux
+$MAKE distcheck
+
+# Modify Makefile.am, remove aclocal.m4, and add a new m4 file to
+# the directory of extra m4 files considered by aclocal.  This new
+# file should now provide a macro required by configure.in and that
+# was previously provided by aclocal.m4.
+
+$sleep
+
+sed 's/%Foo%/%Bar%/g' $srcdir/Makefile.am > t
+mv -f t $srcdir/Makefile.am
+cat $srcdir/Makefile.am
+rm -f $srcdir/aclocal.m4
+cat > $srcdir/m4/blah.m4 <<'END'
+AC_DEFUN([MY_CUSTOM_MACRO], [AC_SUBST([QUUX], [%Bar%])])
+END
+
+$MAKE
+cat quux
+grep '%Bar%' quux
+$MAKE distcheck
+
+# Modify Makefile.am, remove all the extra m4 files to considered
+# by aclocal, and add an acinclude.m4 file.  This last file should
+# now provide a macro required by configure.in, and that was
+# previously provided by the extra m4 files considered by aclocal.
+
+$sleep
+
+rm -f $srcdir/m4/*.m4
+sed 's/%Bar%/%Quux%/g' $srcdir/Makefile.am > t
+mv -f t $srcdir/Makefile.am
+cat $srcdir/Makefile.am
+cat > $srcdir/acinclude.m4 <<'END'
+AC_DEFUN([MY_CUSTOM_MACRO], [AC_SUBST([QUUX], [%Quux%])])
+END
+
+$MAKE
+cat quux
+grep '%Quux%' quux
+$MAKE distcheck
+
+:
diff --git a/tests/remake8b.test b/tests/remake8b.test
new file mode 100755
index 0000000..3861326
--- /dev/null
+++ b/tests/remake8b.test
@@ -0,0 +1,195 @@
+#! /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/>.
+
+# Test basic remake rules for Makefiles, for a *VPATH build*.
+# This testcase checks dependency of generated Makefile from Makefile.am,
+# configure.ac, acinclude.m4, aclocal.m4, and extra m4 files considered
+# by aclocal.
+# Keep this in sync with sister test `remake8a.test', which performs the
+# same checks for a in-tree build.
+
+required=GNUmake
+. ./defs || Exit 1
+
+set -e
+
+mv -f configure.in configure.stub
+
+cat > Makefile.am <<'END'
+all-local: foo
+foo:
+       echo '!Foo!' >$@
+check-local:
+       cat foo
+       grep '!Foo!' foo
+CLEANFILES = foo
+END
+
+cat configure.stub - > configure.in <<'END'
+AC_OUTPUT
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+mkdir build
+cd build
+srcdir='..' # to make syncing with remake8a.test easier.
+
+$srcdir/configure
+
+$MAKE
+cat foo
+grep '!Foo!' foo
+$MAKE distcheck
+
+rm -f foo
+
+# Modify just Makefile.am.
+
+$sleep
+
+cat > $srcdir/Makefile.am <<'END'
+all-local: bar
+bar:
+       echo '!Baz!' >$@
+check-local:
+       cat bar
+       grep '!Baz!' bar
+       test ! -r $(srcdir)/foo
+       test ! -r foo
+CLEANFILES = bar
+END
+
+$MAKE
+cat bar
+grep '!Baz!' bar
+test ! -r foo
+$MAKE distcheck
+
+rm -f bar
+
+# Modify Makefile.am and configure.in.
+
+$sleep
+
+cat > $srcdir/Makefile.am <<'END'
+all-local: quux
+check-local:
+       cat quux
+       grep '!Zardoz!' quux
+       test ! -r $(srcdir)/bar
+       test ! -r bar
+END
+
+cat $srcdir/configure.stub - > $srcdir/configure.in <<'END'
+AC_CONFIG_FILES([quux])
+AC_SUBST([QUUX], [Zardoz])
+AC_OUTPUT
+END
+
+cat > $srcdir/quux.in <<'END'
address@hidden@!
+END
+
+$MAKE
+cat quux
+grep '!Zardoz!' quux
+test ! -f bar
+$MAKE distcheck
+
+rm -f quux
+
+# Modify Makefile.am to add a directory of extra m4 files
+# considered by aclocal.
+
+$sleep
+
+mkdir $srcdir/m4
+
+cat > $srcdir/Makefile.am <<'END'
+ACLOCAL_AMFLAGS = -I m4
+all-local: quux
+check-local:
+       cat quux
+       grep '%Foo%' quux
+       test x'$(QUUX)' = x'%Foo%'
+END
+
+$MAKE # this should place aclocal flags in Makefile
+grep '.*-I m4' Makefile # sanity check
+
+# Modify configure.in and aclocal.m4.
+
+$sleep
+
+cat $srcdir/configure.stub - > $srcdir/configure.in <<'END'
+AC_CONFIG_FILES([quux])
+MY_CUSTOM_MACRO
+AC_OUTPUT
+END
+
+cat >> $srcdir/aclocal.m4 <<'END'
+AC_DEFUN([MY_CUSTOM_MACRO], [AC_SUBST([QUUX], [%Foo%])])
+END
+
+$MAKE
+cat quux
+grep '%Foo%' quux
+$MAKE distcheck
+
+# Modify Makefile.am, remove aclocal.m4, and add a new m4 file to
+# the directory of extra m4 files considered by aclocal.  This new
+# file should now provide a macro required by configure.in and that
+# was previously provided by aclocal.m4.
+
+$sleep
+
+sed 's/%Foo%/%Bar%/g' $srcdir/Makefile.am > t
+mv -f t $srcdir/Makefile.am
+cat $srcdir/Makefile.am
+rm -f $srcdir/aclocal.m4
+cat > $srcdir/m4/blah.m4 <<'END'
+AC_DEFUN([MY_CUSTOM_MACRO], [AC_SUBST([QUUX], [%Bar%])])
+END
+
+$MAKE
+cat quux
+grep '%Bar%' quux
+$MAKE distcheck
+
+# Modify Makefile.am, remove all the extra m4 files to considered
+# by aclocal, and add an acinclude.m4 file.  This last file should
+# now provide a macro required by configure.in, and that was
+# previously provided by the extra m4 files considered by aclocal.
+
+$sleep
+
+rm -f $srcdir/m4/*.m4
+sed 's/%Bar%/%Quux%/g' $srcdir/Makefile.am > t
+mv -f t $srcdir/Makefile.am
+cat $srcdir/Makefile.am
+cat > $srcdir/acinclude.m4 <<'END'
+AC_DEFUN([MY_CUSTOM_MACRO], [AC_SUBST([QUUX], [%Quux%])])
+END
+
+$MAKE
+cat quux
+grep '%Quux%' quux
+$MAKE distcheck
+
+:
diff --git a/tests/remake9a.test b/tests/remake9a.test
new file mode 100755
index 0000000..9cd2d9f
--- /dev/null
+++ b/tests/remake9a.test
@@ -0,0 +1,106 @@
+#! /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/>.
+
+# Test remake rules when configure.in or its prerequisites change.
+# Keep in sync with the other sister tests `remake9*.test'.
+
+required=GNUmake
+. ./defs || Exit 1
+
+set -e
+
+magic1=::MagicStringOne::
+magic2=__MagicStringTwo__
+
+cat >> configure.in <<END
+FINGERPRINT=BadBadBad
+AC_SUBST([FINGERPRINT])
+AC_CONFIG_FILES([foo.sh:foo.in], [chmod a+x foo.sh])
+AC_OUTPUT
+END
+
+cat > Makefile.am <<'END'
+nil:
+.PHONY: nil
+
+$(srcdir)/configure.in: $(srcdir)/tweak-configure-in
+       $(SHELL) $(srcdir)/tweak-configure-in <$@ >address@hidden
+       mv -f address@hidden $@
+EXTRA_DIST = $(srcdir)/tweak-configure-in
+
+# Used by "make distcheck" later.
+check-local:
+       test x'$(FINGERPRINT)' = x'DummyValue'
+       test x"`./foo.sh`" = x"DummyValue"
+END
+
+cat > foo.in <<END
+#!/bin/sh
+echo '@FINGERPRINT@'
+END
+
+echo cat > tweak-configure-in # no-op by default
+
+$sleep # so that generated autotools files will be newer than prerequisites
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+for vpath in : false; do
+
+  if $vpath; then
+    mkdir build
+    cd build
+    srcdir=..
+  else
+    srcdir=.
+  fi
+
+  $srcdir/configure
+  $MAKE # should be no-op
+
+  $sleep
+  sed "s/^\\(FINGERPRINT\\)=.*/\\1=$magic1/" $srcdir/configure.in >t
+  mv -f t $srcdir/configure.in
+  $MAKE nil
+  $FGREP FINGERPRINT Makefile # for debugging
+  $FGREP $magic1 Makefile
+  test x"`./foo.sh`" = x"$magic1"
+
+  $sleep
+  echo 'sed "s/^\\(FINGERPRINT\\)=.*/\\1='$magic2'/"' \
+    > $srcdir/tweak-configure-in
+  $MAKE nil
+  $FGREP FINGERPRINT Makefile # for debugging
+  $FGREP $magic1 Makefile && Exit 1
+  $FGREP $magic2 Makefile
+  test x"`./foo.sh`" = x"$magic2"
+
+  $sleep
+  echo cat > $srcdir/tweak-configure-in # no-op again
+  sed "s/^\\(FINGERPRINT\\)=.*/\\1=DummyValue/" $srcdir/configure.in >t
+  mv -f t $srcdir/configure.in
+  $MAKE distcheck
+  $FGREP $magic1 Makefile && Exit 1 # sanity check
+  $FGREP $magic2 Makefile && Exit 1 # likewise
+
+  $MAKE distclean
+
+  cd $srcdir
+
+done
+
+:
diff --git a/tests/remake9b.test b/tests/remake9b.test
new file mode 100755
index 0000000..636cc5f
--- /dev/null
+++ b/tests/remake9b.test
@@ -0,0 +1,108 @@
+#! /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/>.
+
+# Test remake rules when Makefile.am or its prerequisites change.
+# Keep in sync with the other sister tests `remake9*.test'.
+
+required=GNUmake
+. ./defs || Exit 1
+
+set -e
+
+magic1=::MagicStringOne::
+magic2=__MagicStringTwo__
+
+cat >> configure.in <<END
+AC_OUTPUT
+END
+
+cat > Makefile.am <<'END'
+FINGERPRINT = BadBadBad
+
+all-local: nil
+nil: foo.sh
+.PHONY: nil
+
+$(srcdir)/Makefile.am: $(srcdir)/tweak-makefile-am
+       $(SHELL) $(srcdir)/tweak-makefile-am <$@ >address@hidden
+       mv -f address@hidden $@
+EXTRA_DIST = $(srcdir)/tweak-makefile-am
+
+foo.sh: Makefile
+       rm -f $@ address@hidden
+       echo '#!/bin/sh' > address@hidden
+       echo "echo '$(FINGERPRINT)'" >> address@hidden
+       chmod a+x address@hidden && mv -f address@hidden $@
+CLEANFILES = foo.sh
+
+# Used by "make distcheck" later.
+check-local:
+       test x'$(FINGERPRINT)' = x'DummyValue'
+       test x"`./foo.sh`" = x"DummyValue"
+END
+
+echo cat > tweak-makefile-am # no-op by default
+
+$sleep # so that generated autotools files will be newer than prerequisites
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+for vpath in : false; do
+
+  if $vpath; then
+    mkdir build
+    cd build
+    srcdir=..
+  else
+    srcdir=.
+  fi
+
+  $srcdir/configure
+  $MAKE # should be no-op
+
+  $sleep
+  sed "s/^\\(FINGERPRINT\\) *=.*/\\1 = $magic1/" $srcdir/Makefile.am >t
+  mv -f t $srcdir/Makefile.am
+  $MAKE nil
+  $FGREP FINGERPRINT Makefile # for debugging
+  $FGREP $magic1 Makefile
+  test x"`./foo.sh`" = x"$magic1"
+
+  $sleep
+  echo 'sed "s/^\\(FINGERPRINT\\) *=.*/\\1 = '$magic2'/"' \
+    > $srcdir/tweak-makefile-am
+  $MAKE nil
+  $FGREP FINGERPRINT Makefile # for debugging
+  $FGREP $magic1 Makefile && Exit 1
+  $FGREP $magic2 Makefile
+  test x"`./foo.sh`" = x"$magic2"
+
+  $sleep
+  echo cat > $srcdir/tweak-makefile-am # no-op again
+  sed "s/^\\(FINGERPRINT\\) *=.*/\\1 = DummyValue/" $srcdir/Makefile.am >t
+  mv -f t $srcdir/Makefile.am
+  $MAKE distcheck
+  $FGREP $magic1 Makefile && Exit 1 # sanity check
+  $FGREP $magic2 Makefile && Exit 1 # likewise
+
+  $MAKE distclean
+
+  cd $srcdir
+
+done
+
+:
diff --git a/tests/remake9c.test b/tests/remake9c.test
new file mode 100755
index 0000000..4514371
--- /dev/null
+++ b/tests/remake9c.test
@@ -0,0 +1,109 @@
+#! /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/>.
+
+# Test remake rules when acinclude.m4 or its prerequisites change.
+# Keep in sync with the other sister tests `remake9*.test'.
+
+required=GNUmake
+. ./defs || Exit 1
+
+set -e
+
+magic1=::MagicStringOne::
+magic2=__MagicStringTwo__
+
+cat >> configure.in <<END
+FINGERPRINT='my_fingerprint'
+AC_SUBST([FINGERPRINT])
+AC_CONFIG_FILES([foo.sh:foo.in], [chmod a+x foo.sh])
+AC_OUTPUT
+END
+
+cat > Makefile.am <<'END'
+nil:
+.PHONY: nil
+
+# The right way to extend an autogenerated aclocal.m4 is to provide
+# an acinclude.m4 file.
+$(srcdir)/acinclude.m4: $(srcdir)/tweak-acinclude-m4
+       $(SHELL) $(srcdir)/tweak-acinclude-m4 <$@ >address@hidden
+       mv -f address@hidden $@
+       touch $@
+EXTRA_DIST = $(srcdir)/tweak-acinclude-m4
+
+# Used by "make distcheck" later.
+check-local:
+       test x'$(FINGERPRINT)' = x'DummyValue'
+       test x"`./foo.sh`" = x"DummyValue"
+END
+
+cat > foo.in <<END
+#!/bin/sh
+echo '@FINGERPRINT@'
+END
+
+echo "AC_DEFUN([my_fingerprint], [BadBadBad])" > acinclude.m4
+
+echo : > tweak-acinclude-m4 # no-op by default
+
+$sleep # so that generated autotools files will be newer than prerequisites
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+for vpath in : false; do
+
+  if $vpath; then
+    mkdir build
+    cd build
+    srcdir=..
+  else
+    srcdir=.
+  fi
+
+  $srcdir/configure
+  $MAKE # should be no-op
+
+  $sleep
+  echo "AC_DEFUN([my_fingerprint], [$magic1])" > $srcdir/acinclude.m4
+  $MAKE nil
+  $FGREP FINGERPRINT Makefile # for debugging
+  $FGREP $magic1 Makefile
+  test x"`./foo.sh`" = x"$magic1"
+
+  $sleep
+  echo "echo 'AC_DEFUN([my_fingerprint], [$magic2])'" \
+    > $srcdir/tweak-acinclude-m4
+  $MAKE nil
+  $FGREP FINGERPRINT Makefile # for debugging
+  $FGREP $magic1 Makefile && Exit 1
+  $FGREP $magic2 Makefile
+  test x"`./foo.sh`" = x"$magic2"
+
+  $sleep
+  echo : > $srcdir/tweak-acinclude-m4 # no-op again
+  echo "AC_DEFUN([my_fingerprint], [DummyValue])" > $srcdir/acinclude.m4
+  $MAKE distcheck
+  $FGREP $magic1 Makefile && Exit 1 # sanity check
+  $FGREP $magic2 Makefile && Exit 1 # likewise
+
+  $MAKE distclean
+
+  cd $srcdir
+
+done
+
+:
diff --git a/tests/remake9d.test b/tests/remake9d.test
new file mode 100755
index 0000000..b83dd89
--- /dev/null
+++ b/tests/remake9d.test
@@ -0,0 +1,109 @@
+#! /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/>.
+
+# Test remake rules when aclocal.m4 or its prerequisites change.
+# Keep in sync with the other sister tests `remake9*.test'.
+
+required=GNUmake
+. ./defs || Exit 1
+
+set -e
+
+magic1=::MagicStringOne::
+magic2=__MagicStringTwo__
+
+cat >> configure.in <<END
+FINGERPRINT='my_fingerprint'
+AC_SUBST([FINGERPRINT])
+AC_CONFIG_FILES([foo.sh:foo.in], [chmod a+x foo.sh])
+AC_OUTPUT
+END
+
+cat > Makefile.am <<'END'
+nil:
+.PHONY: nil
+
+# A non-autogenerated aclocal.m4 can be extended by hand.
+$(srcdir)/aclocal.m4: $(srcdir)/tweak-aclocal-m4
+       $(SHELL) $(srcdir)/tweak-aclocal-m4 <$@ >address@hidden
+       mv -f address@hidden $@
+       touch $@
+EXTRA_DIST = $(srcdir)/tweak-aclocal-m4
+
+# Used by "make distcheck" later.
+check-local:
+       test x'$(FINGERPRINT)' = x'DummyValue'
+       test x"`./foo.sh`" = x"DummyValue"
+END
+
+cat > foo.in <<END
+#!/bin/sh
+echo '@FINGERPRINT@'
+END
+
+echo cat > tweak-aclocal-m4 # no-op by default
+
+$sleep # so that generated autotools files will be newer than prerequisites
+$ACLOCAL
+# Cheatingly mark aclocal.m4 as non auto-generated.
+sed '/^ *#.*generated automatically/d' aclocal.m4 > t
+mv -f t aclocal.m4
+$AUTOCONF
+$AUTOMAKE
+
+for vpath in : false; do
+
+  if $vpath; then
+    mkdir build
+    cd build
+    srcdir=..
+  else
+    srcdir=.
+  fi
+
+  $srcdir/configure
+  $MAKE # should be no-op
+
+  $sleep
+  echo "AC_DEFUN([my_fingerprint], [$magic1])dnl %%%" >> $srcdir/aclocal.m4
+  $MAKE nil
+  $FGREP FINGERPRINT Makefile # for debugging
+  $FGREP $magic1 Makefile
+  test x"`./foo.sh`" = x"$magic1"
+
+  $sleep
+  echo "sed 's/.*dnl *%%%.*/AC_DEFUN([my_fingerprint], [$magic2])/'" \
+    > $srcdir/tweak-aclocal-m4
+  $MAKE nil
+  $FGREP FINGERPRINT Makefile # for debugging
+  $FGREP $magic1 Makefile && Exit 1
+  $FGREP $magic2 Makefile
+  test x"`./foo.sh`" = x"$magic2"
+
+  $sleep
+  echo cat > $srcdir/tweak-aclocal-m4 # no-op again
+  echo 'AC_DEFUN([my_fingerprint], [DummyValue])' >> $srcdir/aclocal.m4
+  $MAKE distcheck
+  $FGREP $magic1 Makefile && Exit 1 # sanity check
+  $FGREP $magic2 Makefile && Exit 1 # likewise
+
+  $MAKE distclean
+
+  cd $srcdir
+
+done
+
+:
-- 
1.7.1


reply via email to

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