Merge branch 'yacc-quote-fix'
[automake.git] / tests / remake9a.test
blob677b161aa205c129941a8046d4b4a1eab7647c0f
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 configure.in 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=BadBadBad
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 $(srcdir)/configure.in: $(srcdir)/tweak-configure-in
43 $(SHELL) $(srcdir)/tweak-configure-in <$@ >$@-t
44 mv -f $@-t $@
45 EXTRA_DIST = $(srcdir)/tweak-configure-in
47 # Used by "make distcheck" later.
48 check-local:
49 test x'$(FINGERPRINT)' = x'DummyValue'
50 test x"`./foo.sh`" = x"DummyValue"
51 END
53 cat > foo.in <<END
54 #!/bin/sh
55 echo '@FINGERPRINT@'
56 END
58 echo cat > tweak-configure-in # It is a no-op by default.
60 $sleep # So that generated autotools files will be newer than prerequisites.
61 $ACLOCAL
62 $AUTOCONF
63 $AUTOMAKE
65 for vpath in : false; do
67 if $vpath; then
68 mkdir build
69 cd build
70 srcdir=..
71 else
72 srcdir=.
75 $srcdir/configure
76 $MAKE # Should be a no-op.
78 $sleep
79 sed "s/^\\(FINGERPRINT\\)=.*/\\1=$magic1/" $srcdir/configure.in >t
80 mv -f t $srcdir/configure.in
81 remake_
82 $FGREP FINGERPRINT Makefile # For debugging.
83 $FGREP $magic1 Makefile
84 test x"`./foo.sh`" = x"$magic1"
86 $sleep
87 echo 'sed "s/^\\(FINGERPRINT\\)=.*/\\1='$magic2'/"' \
88 > $srcdir/tweak-configure-in
89 remake_
90 $FGREP FINGERPRINT Makefile # For debugging.
91 $FGREP $magic1 Makefile && Exit 1
92 $FGREP $magic2 Makefile
93 test x"`./foo.sh`" = x"$magic2"
95 $sleep
96 echo cat > $srcdir/tweak-configure-in # Make it a no-op again.
97 sed "s/^\\(FINGERPRINT\\)=.*/\\1=DummyValue/" $srcdir/configure.in >t
98 mv -f t $srcdir/configure.in
99 using_gmake || remake_
100 $MAKE distcheck
101 $FGREP $magic1 Makefile && Exit 1 # Sanity check.
102 $FGREP $magic2 Makefile && Exit 1 # Likewise.
104 $MAKE distclean
106 cd $srcdir
108 done