2 # Copyright (C) 2010-2013 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)
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 basic remake rules for Makefiles with non-default names
18 # and/or with multiple sources.
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"'
38 skip_ "make doesn't support any \"include\" directive"
41 cat > configure.ac <<END
44 AC_CONFIG_FILES([zardoz])
45 AC_CONFIG_LINKS([Makefile:Makefile])
71 grep '^#H:' zardoz.in # For debugging.
73 $FGREP $magic1 zardoz.in
75 $MAKE distclean # This shouldn't remove Makefile.
82 sed "s/%MAGIC3%/$magic3/" >> Makefile <<'END'
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%'
94 ls -l ;: For debugging.
95 test x'$(FOO)' = x'dummy'
98 sed "s/^#H:.*/#H: $magic2/" zardoz.am > t
100 # Used by "make distcheck" below.
101 check-local: my-check
104 cat zardoz.am # For debugging.
110 $FGREP my-check zardoz # Sanity check.
111 $FGREP $magic1 zardoz zardoz.in && exit 1
112 $FGREP $magic2 zardoz
113 $FGREP $magic2 zardoz.in
118 sed 's/^\(AC_CONFIG_FILES\)(.*/\1([zardoz:top.in:quux.in:bot.in])/' \
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
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
138 rm -f zardoz.in zardoz.am # Get rid of them.
139 is_gmake || $MAKE zardoz
142 echo 'FOO = $(BAR)' >> quux.am
143 is_gmake || $MAKE zardoz