test: protect more yacc declarations against C vs. C++ linkage.
[automake.git] / t / yacc-vpath.sh
blob968c6d06b8a160fcfa52827fcc199e2d789b6121
1 #! /bin/sh
2 # Copyright (C) 2001-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 # This test checks that dependent files are updated before including
18 # in the distribution. 'parse.c' depends on 'parse.y'. The later is
19 # updated so that 'parse.c' should be rebuild. Then we are running
20 # 'make' and 'make distdir' and check whether the version of 'parse.c'
21 # to be distributed is up to date.
23 # Please keep this in sync with sister test 'yacc-d-vpath.sh'.
25 required='cc yacc'
26 . test-init.sh
28 cat >> configure.ac << 'END'
29 AC_PROG_CC
30 AC_PROG_YACC
31 AC_OUTPUT
32 END
34 cat > Makefile.am << 'END'
35 AM_LFLAGS = --never-interactive
37 bin_PROGRAMS = foo
38 foo_SOURCES = parse.y foo.c
39 END
41 # Original parser, with 'foobar'.
42 cat > parse.y << 'END'
44 int yylex () { return 0; }
45 void yyerror (const char *s) {}
48 foobar : 'f' 'o' 'o' 'b' 'a' 'r' {};
49 END
51 cat > foo.c << 'END'
52 int main () { return 0; }
53 END
55 $ACLOCAL
56 $AUTOCONF
57 $AUTOMAKE -a
59 $YACC parse.y
60 mv y.tab.c parse.c
62 mkdir sub
63 cd sub
64 ../configure
66 $sleep
68 # New parser, with 'fubar'.
69 cat > ../parse.y << 'END'
71 int yylex () { return 0; }
72 void yyerror (const char *s) {}
75 fubar : 'f' 'o' 'o' 'b' 'a' 'r' {};
76 END
78 $MAKE
79 $MAKE distdir
80 $FGREP fubar $distdir/parse.c
82 # Now check to make sure that 'make dist' will rebuild the parser.
84 $sleep
86 # New parser, with 'maude'.
87 cat > ../parse.y << 'END'
89 int yylex () { return 0; }
90 void yyerror (const char *s) {}
93 maude : 'm' 'a' 'u' 'd' 'e' {};
94 END
96 $MAKE distdir
97 $FGREP maude $distdir/parse.c