test: protect more yacc declarations against C vs. C++ linkage.
[automake.git] / t / remake-makefile-intree.sh
blobb394a8562748403ef7d7d0ba4a658821ef9760b3
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, for an *in-tree build*.
18 # This testcase checks dependency of generated Makefile from Makefile.am,
19 # configure.ac, acinclude.m4, aclocal.m4, and extra m4 files considered
20 # by aclocal.
21 # Keep this in sync with sister test 'remake-makefile-vpath.sh', which
22 # performs the same checks for a VPATH build.
24 . test-init.sh
26 mv -f configure.ac configure.stub
28 cat > Makefile.am <<'END'
29 all-local: foo
30 foo:
31 echo '!Foo!' >$@
32 check-local:
33 cat foo
34 grep '!Foo!' foo
35 CLEANFILES = foo
36 END
38 cat configure.stub - > configure.ac <<'END'
39 AC_OUTPUT
40 END
42 $ACLOCAL
43 $AUTOCONF
44 $AUTOMAKE
46 srcdir='.' # To make syncing with remake-makefile-vpath.sh easier.
48 $srcdir/configure
50 $MAKE
51 cat foo
52 grep '!Foo!' foo
53 $MAKE distcheck
55 rm -f foo
57 # Modify just Makefile.am.
59 $sleep
61 cat > $srcdir/Makefile.am <<'END'
62 all-local: bar
63 bar:
64 echo '!Baz!' >$@
65 check-local:
66 cat bar
67 grep '!Baz!' bar
68 test ! -r $(srcdir)/foo
69 test ! -r foo
70 CLEANFILES = bar
71 END
73 using_gmake || $MAKE Makefile
74 $MAKE
75 cat bar
76 grep '!Baz!' bar
77 test ! -e foo
78 $MAKE distcheck
80 rm -f bar
82 # Modify Makefile.am and configure.ac.
84 $sleep
86 cat > $srcdir/Makefile.am <<'END'
87 check-local:
88 cat quux
89 grep '!Zardoz!' quux
90 test ! -r $(srcdir)/bar
91 test ! -r bar
92 END
94 cat $srcdir/configure.stub - > $srcdir/configure.ac <<'END'
95 AC_CONFIG_FILES([quux])
96 AC_SUBST([QUUX], [Zardoz])
97 AC_OUTPUT
98 END
100 cat > $srcdir/quux.in <<'END'
101 !@QUUX@!
104 using_gmake || $MAKE Makefile
105 $MAKE
106 cat quux
107 grep '!Zardoz!' quux
108 test ! -e bar
109 $MAKE distcheck
111 rm -f quux
113 # Modify configure.ac and aclocal.m4 to add a directory of extra m4
114 # files considered by aclocal. Also update checks in Makefile.am.
115 # Note that we won't use this new directory of extra m4 files in the
116 # first rebuild below (but we will in the second).
118 $sleep
120 mkdir $srcdir/m4
122 cat > $srcdir/Makefile.am <<'END'
123 all-local: quux
124 check-local:
125 cat quux
126 grep '%Foo%' quux
127 test x'$(QUUX)' = x'%Foo%'
130 # Modify configure.ac and aclocal.m4.
132 $sleep
134 cat $srcdir/configure.stub - > $srcdir/configure.ac <<'END'
135 AC_CONFIG_MACRO_DIR([m4])
136 AC_CONFIG_FILES([quux])
137 MY_CUSTOM_MACRO
138 AC_OUTPUT
141 cat >> $srcdir/aclocal.m4 <<'END'
142 AC_DEFUN([MY_CUSTOM_MACRO], [AC_SUBST([QUUX], [%Foo%])])
145 $MAKE
146 cat quux
147 grep '%Foo%' quux
148 $MAKE distcheck
150 # Modify Makefile.am, remove aclocal.m4, and add a new m4 file to
151 # the directory of extra m4 files considered by aclocal. This new
152 # file should now provide a macro required by configure.ac and that
153 # was previously provided by aclocal.m4.
155 $sleep
157 sed 's/%Foo%/%Bar%/g' $srcdir/Makefile.am > t
158 mv -f t $srcdir/Makefile.am
159 cat $srcdir/Makefile.am
160 rm -f $srcdir/aclocal.m4
161 cat > $srcdir/m4/blah.m4 <<'END'
162 AC_DEFUN([MY_CUSTOM_MACRO], [AC_SUBST([QUUX], [%Bar%])])
165 $MAKE
166 cat quux
167 grep '%Bar%' quux
168 $MAKE distcheck
170 # Modify Makefile.am, remove all the extra m4 files to considered
171 # by aclocal, and add an acinclude.m4 file. This last file should
172 # now provide a macro required by configure.ac, and that was
173 # previously provided by the extra m4 files considered by aclocal.
175 $sleep
177 rm -f $srcdir/m4/*.m4
178 sed 's/%Bar%/%Quux%/g' $srcdir/Makefile.am > t
179 mv -f t $srcdir/Makefile.am
180 cat $srcdir/Makefile.am
181 cat > $srcdir/acinclude.m4 <<'END'
182 AC_DEFUN([MY_CUSTOM_MACRO], [AC_SUBST([QUUX], [%Quux%])])
185 $MAKE
186 cat quux
187 grep '%Quux%' quux
188 $MAKE distcheck