test: protect more yacc declarations against C vs. C++ linkage.
[automake.git] / t / lexvpath.sh
blob4958d279da9baa14bcb86969988ded4c630d07f3
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 # This test checks that dependent files are updated before including
18 # in the distribution. 'lexer.c' depends on 'lexer.l'. The latter is
19 # updated so that 'lexer.c' should be rebuild. Then we are running
20 # 'make' and 'make distdir' and check whether the version of 'lexer.c'
21 # to be distributed is up to date.
23 # Please keep this in sync with sister test 'yaccvapth.sh'.
25 required='cc lex'
26 . test-init.sh
28 cat > lexoutroot.in << 'END'
29 LEX_OUTPUT_ROOT='@LEX_OUTPUT_ROOT@'
30 END
32 cat >> configure.ac << 'END'
33 AC_CONFIG_FILES([lexoutroot])
34 AC_PROG_CC
35 AC_PROG_LEX
36 AC_OUTPUT
37 END
39 cat > Makefile.am << 'END'
40 AM_LFLAGS = --never-interactive
42 bin_PROGRAMS = foo
43 foo_SOURCES = lexer.l foo.c
44 LDADD = $(LEXLIB)
45 END
47 # Original lexer, with a "foobar" comment
48 cat > lexer.l << 'END'
50 "END" return EOF;
53 /*foobar*/
54 END
56 cat > foo.c << 'END'
57 int main (void)
59 return 0;
61 /* Avoid possible link errors. */
62 int yywrap (void)
64 return 1;
66 END
68 $ACLOCAL
69 $AUTOCONF
70 $AUTOMAKE -a
72 mkdir sub
74 # We must run configure early, to find out why $LEX_OUTPUT_ROOT is.
75 cd sub
76 ../configure
77 . ./lexoutroot
78 test -n "$LEX_OUTPUT_ROOT" # Sanity check.
79 cd ..
81 $LEX lexer.l
82 mv "$LEX_OUTPUT_ROOT".c lexer.c
84 cd sub
86 # Ensure that lexer.l will be newer than lexer.c.
87 $sleep
89 # New lexer, with 'fubar' comment.
90 cat > ../lexer.l << 'END'
92 "END" return EOF;
95 /*fubar*/
96 END
98 $MAKE
99 $MAKE distdir
100 $FGREP '/*fubar*/' $distdir/lexer.c
103 # Now check to make sure that 'make dist' will rebuilt the parser.
106 # Ensure that lexer.l will be newer than lexer.c.
107 $sleep
109 # New lexer, with 'maude' comment.
110 cat > ../lexer.l << 'END'
112 "END" return EOF;
115 /*maude*/
118 $MAKE distdir
119 $FGREP '/*maude*/' $distdir/lexer.c