test: protect more yacc declarations against C vs. C++ linkage.
[automake.git] / t / remake-deleted-m4-file.sh
blobe1066d822143eedd6bcebb99624ee328d03733c2
1 #! /bin/sh
2 # Copyright (C) 2011-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 an m4 file gets removed and the macros it
18 # defined get inlined into the caller. Try with both an indirect
19 # call and a direct one. This can be seen as testing the "deleted
20 # header file" issue w.r.t. aclocal.m4 dependencies. See also
21 # related test 'aclocal-deleted-header.sh'.
23 . test-init.sh
25 cat >> configure.ac <<'END'
26 FOO_MACRO
27 AC_OUTPUT
28 END
30 cat > Makefile.am <<'END'
31 ACLOCAL_AMFLAGS = -I m4
32 .PHONY: test
33 test:
34 test '$(the_answer)' -eq 42
35 END
37 macro_value='the_answer=42; AC_SUBST([the_answer])'
39 mkdir m4
41 cat > m4/foo.m4 <<'END'
42 AC_DEFUN([FOO_MACRO], [BAR_MACRO])
43 END
45 cat > m4/bar.m4 <<END
46 AC_DEFUN([BAR_MACRO], [$macro_value])
47 END
49 $ACLOCAL -I m4
50 $AUTOCONF
51 $AUTOMAKE
53 ./configure
54 $MAKE test
56 $sleep
58 sed -e "s|BAR_MACRO|$macro_value|" m4/foo.m4 > t
59 mv -f t m4/foo.m4
60 rm -f m4/bar.m4
62 using_gmake || $MAKE Makefile
63 $MAKE test
65 $sleep
67 sed -e "s|FOO_MACRO|$macro_value|" configure.ac > t
68 mv -f t configure.ac
69 rm -f m4/foo.m4
71 using_gmake || $MAKE Makefile
72 $MAKE test