doc: typos in test file.
[automake.git] / t / yacc-clean-cxx.sh
blob6af2047c0bb2f515b84f1a9cb899d5fcbfb18ebb
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 # Check that C++ source and header files derived from non-distributed
18 # Yacc sources are cleaned by "make clean", while C++ source and
19 # header files derived from distributed Yacc sources are cleaned by
20 # "make maintainer-clean".
21 # See also sister test 'yacc-clean.sh'.
23 required='c++ yacc'
24 . test-init.sh
26 cat >> configure.ac << 'END'
27 AC_PROG_CXX
28 AC_PROG_YACC
29 AC_CONFIG_FILES([sub1/Makefile sub2/Makefile])
30 AC_OUTPUT
31 END
33 cat > Makefile.am << 'END'
34 # Use two subdirectories, one to test with '-d' in YFLAGS, the
35 # other one to test with empty YFLAGS.
36 SUBDIRS = sub1 sub2
37 END
39 mkdir sub1 sub2
41 cat > sub1/Makefile.am << 'END'
42 AM_LFLAGS = --never-interactive
44 bin_PROGRAMS = foo bar baz qux
46 foo_SOURCES = mainfoo.cc parsefoo.yxx
48 bar_SOURCES = mainbar.cpp parsebar.yy
49 bar_YFLAGS = $(AM_YFLAGS)
51 baz_SOURCES = mainbaz.c++
52 nodist_baz_SOURCES = parsebaz.y++
54 qux_SOURCES = mainqux.cxx
55 nodist_qux_SOURCES = parsequx.ypp
56 qux_YFLAGS = $(AM_YFLAGS)
58 parsebaz.y++ parsequx.ypp:
59 cp $(srcdir)/parsefoo.yxx $@
61 CLEANFILES = parsebaz.y++ parsequx.ypp
62 END
64 cat > sub2/Makefile.am << 'END'
65 include $(top_srcdir)/sub1/Makefile.am
66 AM_YFLAGS = -d
67 END
69 cat > sub1/parsefoo.yxx << 'END'
71 // This file should contain valid C++ but invalid C.
72 #include <cstdio>
73 #if (defined __cplusplus) && ((!defined __sun) || (defined __EXTERN_C__))
74 extern "C" {
75 #endif
77 // "std::" qualification required by Sun C++ 5.9.
78 int yylex (void) { return std::getchar (); }
79 void yyerror (const char *s) {}
80 #if (defined __cplusplus) && ((!defined __sun) || (defined __EXTERN_C__))
82 #endif
86 x : 'x' { };
87 END
88 cp sub1/parsefoo.yxx sub1/parsebar.yy
89 cp sub1/parsefoo.yxx sub2/parsefoo.yxx
90 cp sub1/parsefoo.yxx sub2/parsebar.yy
92 cat > sub1/mainfoo.cc << 'END'
93 // This file should contain valid C++ but invalid C.
94 using namespace std;
95 int main (int argc, char **argv)
97 extern int yyparse (void);
98 return yyparse ();
101 cp sub1/mainfoo.cc sub1/mainbar.cpp
102 cp sub1/mainfoo.cc sub1/mainbaz.c++
103 cp sub1/mainfoo.cc sub1/mainqux.cxx
104 cp sub1/main???.c* sub2
106 $ACLOCAL
107 $AUTOCONF
108 $AUTOMAKE -a
110 ./configure
112 cp config.status config.sav
114 $MAKE
115 ls -l . sub1 sub2
116 # Sanity checks.
117 test -f sub1/parsefoo.cxx
118 test -f sub1/bar-parsebar.cc
119 test -f sub1/parsebaz.y++
120 test -f sub1/parsebaz.c++
121 test -f sub1/parsequx.ypp
122 test -f sub1/qux-parsequx.cpp
123 test -f sub2/parsefoo.cxx
124 test -f sub2/parsefoo.hxx
125 test -f sub2/bar-parsebar.cc
126 test -f sub2/bar-parsebar.hh
127 test -f sub2/parsebaz.y++
128 test -f sub2/parsebaz.c++
129 test -f sub2/parsebaz.h++
130 test -f sub2/parsequx.ypp
131 test -f sub2/qux-parsequx.cpp
132 test -f sub2/qux-parsequx.hpp
134 for target in clean distclean; do
135 $MAKE $target
136 ls -l . sub1 sub2
137 test -f sub1/parsefoo.cxx
138 test -f sub1/bar-parsebar.cc
139 test ! -e sub1/parsebaz.y++
140 test ! -e sub1/parsebaz.c++
141 test ! -e sub1/parsequx.ypp
142 test ! -e sub1/qux-parsequx.cpp
143 test -f sub2/parsefoo.cxx
144 test -f sub2/parsefoo.hxx
145 test -f sub2/bar-parsebar.cc
146 test -f sub2/bar-parsebar.hh
147 test ! -e sub2/parsebaz.y++
148 test ! -e sub2/parsebaz.c++
149 test ! -e sub2/parsebaz.h++
150 test ! -e sub2/parsequx.ypp
151 test ! -e sub2/qux-parsequx.cpp
152 test ! -e sub2/qux-parsequx.hpp
153 done
155 cp config.sav config.status
156 ./config.status # re-create Makefile
158 $MAKE maintainer-clean
159 ls -l . sub1 sub2
160 test -f sub1/parsefoo.yxx
161 test -f sub1/parsebar.yy
162 test ! -e sub1/parsefoo.cxx
163 test ! -e sub1/bar-parsebar.cc
164 test -f sub2/parsefoo.yxx
165 test -f sub2/parsebar.yy
166 test ! -e sub2/parsefoo.cxx
167 test ! -e sub2/parsefoo.hxx
168 test ! -e sub2/bar-parsebar.cc
169 test ! -e sub2/bar-parsebar.hh