test: protect more yacc declarations against C vs. C++ linkage.
[automake.git] / t / remake-renamed-m4-macro-and-file.sh
blob753a42f1fd4207825ec835e34484f9f3b5836041
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 renamed and *simultaneously*
18 # an m4 macro in it gets renamed. Kudos to Bruno Haible for thinking
19 # about this situation. See also related test 'aclocal-deleted-header.sh'.
21 . test-init.sh
23 cat >> configure.ac <<'END'
24 MY_MACRO
25 AC_OUTPUT
26 END
28 cat > Makefile.am <<'END'
29 ACLOCAL_AMFLAGS = -I m4
30 .PHONY: test
31 test:
32 test '$(the_answer)' -eq 42
33 END
35 mkdir m4
37 cat > m4/macros.m4 <<'END'
38 AC_DEFUN([MY_MACRO], [FOO_MACRO])
39 END
41 cat > m4/foo.m4 <<'END'
42 AC_DEFUN([FOO_MACRO], [the_answer=42; AC_SUBST([the_answer])])
43 END
45 $ACLOCAL -I m4
46 $AUTOCONF
47 $AUTOMAKE
49 ./configure
50 $MAKE test
52 # Rename only one file and one macro.
54 $sleep
55 sed -e 's/FOO_MACRO/BAR_MACRO/' m4/foo.m4 > m4/bar.m4
56 rm -f m4/foo.m4
57 sed -e 's/FOO_MACRO/BAR_MACRO/' m4/macros.m4 > t
58 mv -f t m4/macros.m4
59 using_gmake || $MAKE Makefile
60 $MAKE test
61 $MAKE distdir
62 ls -l $distdir $distdir/*
63 test -f $distdir/m4/bar.m4
64 test -f $distdir/m4/macros.m4
65 test ! -e $distdir/m4/foo.m4
67 # Rename both at once.
69 $sleep
70 sed -e 's/BAR_MACRO/QUUX_MACRO/' \
71 m4/bar.m4 > m4/quux.m4
72 sed -e 's/BAR_MACRO/QUUX_MACRO/' -e 's/MY_MACRO/A_MACRO/' \
73 m4/macros.m4 > m4/defs.m4
74 rm -f m4/macros.m4 m4/bar.m4
75 sed -e 's/BAR_MACRO/QUUX_MACRO/' -e 's/MY_MACRO/A_MACRO/' configure.ac > t
76 mv -f t configure.ac
77 using_gmake || $MAKE Makefile
78 $MAKE test
79 $MAKE distdir
80 ls -l $distdir $distdir/*
81 test -f $distdir/m4/quux.m4
82 test -f $distdir/m4/defs.m4
83 test ! -e $distdir/m4/bar.m4
84 test ! -e $distdir/m4/macros.m4