doc: typos in test file.
[automake.git] / t / remake-mild-stress.sh
blob00a94c3464a337eec5a5569ab6741be4fa8ecc13
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 basic remake rules for Makefiles with non-default names
18 # and/or with multiple sources.
20 . test-init.sh
22 magic1=::MagicStringOne::
23 magic2=__MagicStringTwo__
24 magic3=%%MagicStringThree%%
26 # See if the user's make implementation support an include directive.
27 # We need it in this test.
28 echo 'all:; @echo include is supported' > incl.mk
29 echo 'include incl.mk' > gnu-style.mk
30 echo '.include "incl.mk"' > bsd-style.mk
31 if $MAKE -f gnu-style.mk | grep 'include is supported'; then
32 echo "$me: GNU make include style supported"
33 include_zardoz='include zardoz'
34 elif $MAKE -f bsd-style.mk | grep 'include is supported'; then
35 echo "$me: BSD make include style supported"
36 include_zardoz='.include "zardoz"'
37 else
38 skip_ "make doesn't support any \"include\" directive"
41 cat > configure.ac <<END
42 AC_INIT([$me], [1.0])
43 AM_INIT_AUTOMAKE
44 AC_CONFIG_FILES([zardoz])
45 AC_CONFIG_LINKS([Makefile:Makefile])
46 AC_OUTPUT
47 END
49 cat > zardoz.am <<END
50 EXTRA_DIST = Makefile
51 #H: $magic1
52 END
54 cat > Makefile <<END
55 $include_zardoz
56 nil:
57 .PHONY: nil
58 END
60 $ACLOCAL
61 $AUTOCONF
62 $AUTOMAKE
64 ./configure
66 if using_gmake; then
67 $MAKE nil
68 else
69 $MAKE Makefile
71 grep '^#H:' zardoz.in # For debugging.
72 $FGREP $magic1 zardoz
73 $FGREP $magic1 zardoz.in
74 $MAKE distcheck
75 $MAKE distclean # This shouldn't remove Makefile.
76 ls -l
77 test -f Makefile
79 ./configure
81 $sleep
82 sed "s/%MAGIC3%/$magic3/" >> Makefile <<'END'
83 my-check:
84 ls -l . $(srcdir) ;: For debugging.
85 test -f $(srcdir)/quux.am
86 test -f $(srcdir)/quux.in
87 test -f $(srcdir)/bot.in
88 test -f $(srcdir)/top.in
89 test ! -r $(srcdir)/zardoz.am
90 test ! -r $(srcdir)/zardoz.in
91 grep FOO zardoz ;: For debugging.
92 test x'$(FOO)' = x'%MAGIC3%'
93 test:
94 ls -l ;: For debugging.
95 test x'$(FOO)' = x'dummy'
96 .PHONY: test my-check
97 END
98 sed "s/^#H:.*/#H: $magic2/" zardoz.am > t
99 cat >> t <<'END'
100 # Used by "make distcheck" below.
101 check-local: my-check
103 mv -f t zardoz.am
104 cat zardoz.am # For debugging.
105 if using_gmake; then
106 $MAKE nil
107 else
108 $MAKE zardoz
110 $FGREP my-check zardoz # Sanity check.
111 $FGREP $magic1 zardoz zardoz.in && exit 1
112 $FGREP $magic2 zardoz
113 $FGREP $magic2 zardoz.in
115 ./configure
117 $sleep
118 sed 's/^\(AC_CONFIG_FILES\)(.*/\1([zardoz:top.in:quux.in:bot.in])/' \
119 <configure.ac >t
120 mv -f t configure.ac
121 cat configure.ac # For debugging.
122 sed '/^#H:/d' zardoz.am > quux.am
123 echo 'FOO = dummy' >> quux.am
124 echo 'BAR = $(BAZ)' > top.in
125 echo "BAZ = $magic3" > bot.in
126 is_gmake || $MAKE zardoz
127 $MAKE test
128 $FGREP my-check zardoz # Sanity check.
129 $FGREP $magic3 quux.in && exit 1
130 $FGREP $magic3 zardoz
131 $FGREP $magic1 zardoz && exit 1
132 $FGREP $magic2 zardoz && exit 1
133 # After the remake above, the files 'zardoz.am' and 'zardoz.in'
134 # should be no more needed.
135 echo 'endif' > zardoz.am # Put in a syntax error.
136 is_gmake || $MAKE zardoz
137 $MAKE test
138 rm -f zardoz.in zardoz.am # Get rid of them.
139 is_gmake || $MAKE zardoz
140 $MAKE test
142 echo 'FOO = $(BAR)' >> quux.am
143 is_gmake || $MAKE zardoz
144 $MAKE distcheck