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 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'.
26 cat >> configure.ac
<< 'END'
29 AC_CONFIG_FILES
([sub
1/Makefile sub
2/Makefile
])
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.
41 cat > sub
1/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
64 cat > sub
2/Makefile.am
<< 'END'
65 include $
(top_srcdir
)/sub
1/Makefile.am
69 cat > sub
1/parsefoo.yxx
<< 'END'
71 // This
file should contain valid C
++ but invalid C.
73 #if (defined __cplusplus) && ((!defined __sun) || (defined __EXTERN_C__))
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__))
88 cp sub
1/parsefoo.yxx sub
1/parsebar.yy
89 cp sub
1/parsefoo.yxx sub
2/parsefoo.yxx
90 cp sub
1/parsefoo.yxx sub
2/parsebar.yy
92 cat > sub
1/mainfoo.cc
<< 'END'
93 // This
file should contain valid C
++ but invalid C.
95 int main
(int argc
, char
**argv
)
97 extern int yyparse
(void
);
101 cp sub
1/mainfoo.cc sub
1/mainbar.cpp
102 cp sub
1/mainfoo.cc sub
1/mainbaz.c
++
103 cp sub
1/mainfoo.cc sub
1/mainqux.cxx
104 cp sub
1/main???.c
* sub2
112 cp config.status config.sav
117 test -f sub
1/parsefoo.cxx
118 test -f sub
1/bar-parsebar.cc
119 test -f sub
1/parsebaz.y
++
120 test -f sub
1/parsebaz.c
++
121 test -f sub
1/parsequx.ypp
122 test -f sub
1/qux-parsequx.cpp
123 test -f sub
2/parsefoo.cxx
124 test -f sub
2/parsefoo.hxx
125 test -f sub
2/bar-parsebar.cc
126 test -f sub
2/bar-parsebar.hh
127 test -f sub
2/parsebaz.y
++
128 test -f sub
2/parsebaz.c
++
129 test -f sub
2/parsebaz.h
++
130 test -f sub
2/parsequx.ypp
131 test -f sub
2/qux-parsequx.cpp
132 test -f sub
2/qux-parsequx.hpp
134 for target
in clean distclean
; do
137 test -f sub
1/parsefoo.cxx
138 test -f sub
1/bar-parsebar.cc
139 test ! -e sub
1/parsebaz.y
++
140 test ! -e sub
1/parsebaz.c
++
141 test ! -e sub
1/parsequx.ypp
142 test ! -e sub
1/qux-parsequx.cpp
143 test -f sub
2/parsefoo.cxx
144 test -f sub
2/parsefoo.hxx
145 test -f sub
2/bar-parsebar.cc
146 test -f sub
2/bar-parsebar.hh
147 test ! -e sub
2/parsebaz.y
++
148 test ! -e sub
2/parsebaz.c
++
149 test ! -e sub
2/parsebaz.h
++
150 test ! -e sub
2/parsequx.ypp
151 test ! -e sub
2/qux-parsequx.cpp
152 test ! -e sub
2/qux-parsequx.hpp
155 cp config.sav config.status
156 .
/config.status
# re-create Makefile
158 $MAKE maintainer-clean
160 test -f sub
1/parsefoo.yxx
161 test -f sub
1/parsebar.yy
162 test ! -e sub
1/parsefoo.cxx
163 test ! -e sub
1/bar-parsebar.cc
164 test -f sub
2/parsefoo.yxx
165 test -f sub
2/parsebar.yy
166 test ! -e sub
2/parsefoo.cxx
167 test ! -e sub
2/parsefoo.hxx
168 test ! -e sub
2/bar-parsebar.cc
169 test ! -e sub
2/bar-parsebar.hh