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)
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 that many different Yacc parsers (both C and C++) can co-exists
18 # in the same directory.
20 required
='cc c++ yacc'
23 cat >> configure.ac
<< 'END'
30 cat > Makefile.am
<< 'END'
31 AM_LFLAGS
= --never-interactive
33 bin_PROGRAMS
= c1 c2 cxx1 cxx2 cxx3
36 c1_SOURCES
= p.y p.h
1.c
40 cxx1_SOURCES
= parse.yy main1.cc parse.hh
42 cxx2_SOURCES
= parse2.y
++ main2.c
++
45 cxx3_SOURCES
= parse3.yxx main3.cxx
47 BUILT_SOURCES
= p.h parse.hh parse3.hxx
50 # The content of all the .c and .y files created below is valid C but
51 # deliberately invalid C++.
52 # Vice versa, the content of all the .c++, .cxx, .cc, .y++, .yxx and
53 # .yy files created below is valid C++ but deliberately invalid C.
57 #if (defined __cplusplus) && ((!defined __sun) || (defined __EXTERN_C__))
60 int yylex (void) { int new = 0; return new; }
61 void yyerror (const char *s) {}
62 #if (defined __cplusplus) && ((!defined __sun) || (defined __EXTERN_C__))
74 extern int yyparse (void);
78 return yyparse () + new;
84 extern int yyparse (void);
89 return yyparse () + new;
93 cat > parse.yy
<<'END'
95 // Include C header to provide global symbols that flex assumes.
96 // https://bugs.gnu.org/20031
98 // Valid C++, but deliberately invalid C.
104 #if (defined __cplusplus) && ((!defined __sun) || (defined __EXTERN_C__))
107 int yylex (void) { return 0; }
108 void yyerror (const char *s) {}
109 #if (defined __cplusplus) && ((!defined __sun) || (defined __EXTERN_C__))
119 cat > parse2.y
++ <<'END'
122 int yylex (void) { return 0; }
123 void yyerror (const char *s) {}
130 cat > main1.cc
<<'END'
133 int main (int argc, char **argv)
136 return yyparse () + FOOBAR;
140 cat > main2.c
++ <<'END'
142 int main (int argc, char **argv)
149 edit
() { sed -e 's/FOOBAR/BAZQUUX/' -e 's/"parse\.hh"/"parse3.hxx"/'; }
150 edit
<parse.yy
>parse3.yxx
151 edit
<main1.cc
>main3.cxx
157 # Try a VPATH and by default serial build first, and then an in-tree
158 # and by default parallel build.
162 if test $try -eq 0; then
163 # VPATH serial build.
167 debug_info
="ls -l . $srcdir"
169 elif test $try -eq 1; then
170 # In-tree parallel build.
175 # Degree of parallelism already specified by the user: do
179 # Some make implementations (e.g., HP-UX) don't grok '-j',
180 # some require no space between '-j' and the number of jobs
181 # (e.g., older GNU make versions), and some *do* require a
182 # space between '-j' and the number of jobs (e.g., Solaris
183 # dmake). We need a runtime test to see what works.
184 echo 'all:' > Makefile
185 for run_make
in "$MAKE -j3" "$MAKE -j 3" "$MAKE"; do
191 echo "$me: invalid value of \$try '$try'" >&2
210 test -f cxx2-parse2.c
++
212 test ! -e cxx2-parse2.h
++
214 # Minimal checks about recovering from header removal.
215 rm -f p.h parse.hh parse3.hxx
216 $run_make p.h parse.hh