test: protect more yacc declarations against C vs. C++ linkage.
[automake.git] / t / cond35.sh
blob79d8d53076657920190bf17d31f5b72187ec5fb4
1 #!/bin/sh
2 # Copyright (C) 2004-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 # Check rules output for parser defined conditionally.
18 # Report from Roman Fietze.
20 required='cc lex yacc'
21 . test-init.sh
23 cat >>configure.ac <<'EOF'
24 AM_CONDITIONAL([CASE_A], [test -z "$case_B"])
25 AC_PROG_CC
26 AM_PROG_LEX
27 AC_PROG_YACC
28 AC_OUTPUT
29 EOF
31 cat > Makefile.am <<'EOF'
32 AM_YFLAGS = -d
33 AM_LFLAGS = --never-interactive
35 BUILT_SOURCES = tparse.h
37 if CASE_A
38 bin_PROGRAMS = ta
39 ta_SOURCES = ta.c tparse.h tscan.l tparse.y
40 ta_LDADD = $(LEXLIB)
41 else
42 bin_PROGRAMS = tb
43 tb_SOURCES = tb.c tparse.h tscan.l tparse.y
44 tb_LDADD = $(LEXLIB)
45 endif
48 test-ta:
49 test -f ta$(EXEEXT)
50 test-tb:
51 test -f tb$(EXEEXT)
52 EOF
54 $ACLOCAL
55 $AUTOCONF
56 $AUTOMAKE --add-missing
58 $FGREP 'tparse.h' Makefile.in # For debugging.
59 test $($FGREP -c 'tparse.h:' Makefile.in) -eq 1
61 cat > tscan.l << 'END'
63 "END" return EOF;
65 /* Avoid possible link errors. */
66 int yywrap (void)
68 return 1;
70 END
72 cat > tparse.y << 'END'
74 extern int yylex(void);
76 void yyerror (const char *s) {}
78 %token EOF
80 foobar : 'f' 'o' 'o' 'b' 'a' 'r' EOF {};
81 END
83 cat > ta.c << 'END'
84 int main (void)
86 return 0;
88 END
90 cp ta.c tb.c
92 ./configure
93 $MAKE
94 $MAKE test-ta
96 ./configure case_B=yes
97 $MAKE
98 $MAKE test-tb