doc: typos in test file.
[automake.git] / t / remake-after-makefile-am.sh
blob45fb8032cdd7f7685d014fc247fecaa1bca3c4a0
1 #! /bin/sh
2 # Copyright (C) 2010-2024 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 <https://www.gnu.org/licenses/>.
17 # Test remake rules when Makefile.am or its prerequisites change.
18 # Keep in sync with the other sister tests 'remake-after-*.sh'.
20 . test-init.sh
22 if using_gmake; then
23 remake_() { $MAKE nil; }
24 else
25 remake_() { $MAKE Makefile && $MAKE foo.sh; }
28 magic1=::MagicStringOne::
29 magic2=__MagicStringTwo__
31 cat >> configure.ac <<END
32 AC_OUTPUT
33 END
35 cat > Makefile.am <<'END'
36 FINGERPRINT = BadBadBad
38 all-local: nil
39 nil: foo.sh
40 .PHONY: nil
42 $(srcdir)/Makefile.am: $(srcdir)/tweak-makefile-am
43 $(SHELL) $(srcdir)/tweak-makefile-am <$@ >$@-t
44 mv -f $@-t $@
45 EXTRA_DIST = $(srcdir)/tweak-makefile-am
47 foo.sh: Makefile
48 rm -f $@ $@-t
49 echo '#!/bin/sh' > $@-t
50 echo "echo '$(FINGERPRINT)'" >> $@-t
51 chmod a+x $@-t && mv -f $@-t $@
52 CLEANFILES = foo.sh
54 # Used by "make distcheck" later.
55 check-local:
56 test x'$(FINGERPRINT)' = x'DummyValue'
57 test x"`./foo.sh`" = x"DummyValue"
58 END
60 echo cat > tweak-makefile-am # It is a no-op by default.
62 $ACLOCAL
63 $AUTOCONF
64 $AUTOMAKE
66 for vpath in : false; do
68 if $vpath; then
69 mkdir build
70 cd build
71 srcdir=..
72 else
73 srcdir=.
76 $srcdir/configure
77 $MAKE # Should be a no-op.
79 $sleep
80 sed "s/^\\(FINGERPRINT\\) *=.*/\\1 = $magic1/" $srcdir/Makefile.am >t
81 mv -f t $srcdir/Makefile.am
82 remake_
83 $FGREP FINGERPRINT Makefile # For debugging.
84 $FGREP $magic1 Makefile
85 test x"$(./foo.sh)" = x"$magic1"
87 $sleep
88 echo 'sed "s/^\\(FINGERPRINT\\) *=.*/\\1 = '$magic2'/"' \
89 > $srcdir/tweak-makefile-am
90 remake_
91 $FGREP FINGERPRINT Makefile # For debugging.
92 $FGREP $magic1 Makefile && exit 1
93 $FGREP $magic2 Makefile
94 test x"$(./foo.sh)" = x"$magic2"
96 $sleep
97 echo cat > $srcdir/tweak-makefile-am # Make it a no-op again.
98 sed "s/^\\(FINGERPRINT\\) *=.*/\\1 = DummyValue/" $srcdir/Makefile.am >t
99 mv -f t $srcdir/Makefile.am
100 using_gmake || remake_
101 $MAKE distcheck
102 $FGREP $magic1 Makefile && exit 1 # Sanity check.
103 $FGREP $magic2 Makefile && exit 1 # Likewise.
105 $MAKE distclean
107 cd $srcdir
109 done