Merge branch 'yacc-quote-fix'
[automake.git] / tests / remake9c.test
blob7a27acc4ec35256ddc2f9a91ad760625c34d6a90
1 #! /bin/sh
2 # Copyright (C) 2010-2012 Free Software Foundation, Inc.
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2, or (at your option)
7 # any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
17 # Test remake rules when acinclude.m4 or its prerequisites change.
18 # Keep in sync with the other sister tests `remake9*.test'.
20 . ./defs || Exit 1
22 magic1=::MagicStringOne::
23 magic2=__MagicStringTwo__
25 if using_gmake; then
26 remake_() { $MAKE nil; }
27 else
28 remake_() { $MAKE Makefile && $MAKE foo.sh; }
31 cat >> configure.in <<END
32 FINGERPRINT='my_fingerprint'
33 AC_SUBST([FINGERPRINT])
34 AC_CONFIG_FILES([foo.sh:foo.in], [chmod a+x foo.sh])
35 AC_OUTPUT
36 END
38 cat > Makefile.am <<'END'
39 nil:
40 .PHONY: nil
42 # The right way to extend an autogenerated aclocal.m4 is to provide
43 # an acinclude.m4 file.
44 $(srcdir)/acinclude.m4: $(srcdir)/tweak-acinclude-m4
45 $(SHELL) $(srcdir)/tweak-acinclude-m4 <$@ >$@-t
46 mv -f $@-t $@
47 touch $@
48 EXTRA_DIST = $(srcdir)/tweak-acinclude-m4
50 # Used by "make distcheck" later.
51 check-local:
52 test x'$(FINGERPRINT)' = x'DummyValue'
53 test x"`./foo.sh`" = x"DummyValue"
54 END
56 cat > foo.in <<END
57 #!/bin/sh
58 echo '@FINGERPRINT@'
59 END
61 echo "AC_DEFUN([my_fingerprint], [BadBadBad])" > acinclude.m4
63 echo : > tweak-acinclude-m4 # It is a no-op by default.
65 $sleep # So that generated autotools files will be newer than prerequisites.
66 $ACLOCAL
67 $AUTOCONF
68 $AUTOMAKE
70 for vpath in : false; do
72 if $vpath; then
73 mkdir build
74 cd build
75 srcdir=..
76 else
77 srcdir=.
80 $srcdir/configure
81 $MAKE # Should be a no-op.
83 $sleep
84 echo "AC_DEFUN([my_fingerprint], [$magic1])" > $srcdir/acinclude.m4
85 remake_
86 $FGREP FINGERPRINT Makefile # For debugging.
87 $FGREP $magic1 Makefile
88 test x"`./foo.sh`" = x"$magic1"
90 $sleep
91 echo "echo 'AC_DEFUN([my_fingerprint], [$magic2])'" \
92 > $srcdir/tweak-acinclude-m4
93 remake_
94 $FGREP FINGERPRINT Makefile # For debugging.
95 $FGREP $magic1 Makefile && Exit 1
96 $FGREP $magic2 Makefile
97 test x"`./foo.sh`" = x"$magic2"
99 $sleep
100 echo : > $srcdir/tweak-acinclude-m4 # Make it a no-op again.
101 echo "AC_DEFUN([my_fingerprint], [DummyValue])" > $srcdir/acinclude.m4
102 using_gmake || remake_
103 $MAKE distcheck
104 $FGREP $magic1 Makefile && Exit 1 # Sanity check.
105 $FGREP $magic2 Makefile && Exit 1 # Likewise.
107 $MAKE distclean
109 cd $srcdir
111 done