2 # Copyright (C) 2011-2012 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 <http://www.gnu.org/licenses/>.
17 # Various tests on Yacc/C++ support with yacc-generated headers
18 # (i.e., '-d' in *YFLAGS).
19 # Keep in sync with sister test `yacc-d-basic.test'.
31 // Valid C++, but deliberately invalid C.
34 int yylex (void) { return 0; }
35 void yyerror (const char *s) {}
47 // Valid C++, but deliberately invalid C.
50 int main (int argc, char **argv)
58 cat >> configure.in << 'END'
61 AC_CONFIG_FILES([foo/Makefile bar/Makefile baz/Makefile qux/Makefile])
65 mkdir foo bar baz qux baz/sub
67 # These makefiles will be extended later.
68 cat > Makefile.am <<'END'
71 @echo ' ' $(DIST_COMMON) ' '
73 cp Makefile.am foo/Makefile.am
74 cp Makefile.am bar/Makefile.am
75 cp Makefile.am baz/Makefile.am
76 cp Makefile.am qux/Makefile.am
78 cat >> Makefile.am <<'END'
79 SUBDIRS = foo bar baz qux
85 cp $testsrcdir/../lib/ylwrap .
89 # Try with -d in $(YFLAGS) (don't do this in real life!).
90 cat >> foo/Makefile.am <<END
92 zardoz_SOURCES = parse.yy main.cc
93 BUILT_SOURCES = parse.hh
98 $AUTOMAKE -Wno-gnu foo/Makefile
100 write_parse parse.hh > foo/parse.yy
101 write_main parse.hh > foo/main.cc
103 # Try with -d in $(AM_YFLAGS).
104 cat >> bar/Makefile.am <<END
105 bin_PROGRAMS = zardoz
106 zardoz_SOURCES = parse.ypp main.cpp
107 BUILT_SOURCES = parse.hpp
108 AM_YFLAGS${tab}= -d ${tab}
111 $AUTOMAKE bar/Makefile
113 write_parse parse.hpp > bar/parse.ypp
114 write_main parse.hpp > bar/main.cpp
116 # Try with -d in $(AM_YFLAGS), and a subdir parser.
117 cat >> baz/Makefile.am <<END
118 AUTOMAKE_OPTIONS = subdir-objects
120 joe_SOURCES = sub/parse.y++ sub/main.c++
121 BUILT_SOURCES = sub/parse.h++
126 $AUTOMAKE baz/Makefile
128 write_parse sub/parse.h++ > baz/sub/parse.y++
129 write_main sub/parse.h++ > baz/sub/main.c++
131 # Try with -d in $(xxx_YFLAGS) (per-object flag).
132 cat >> qux/Makefile.am <<END
134 maude_SOURCES = parse.yxx main.cxx
135 maude_YFLAGS=${tab} -d${tab}
136 BUILT_SOURCES = maude-parse.hxx
139 $AUTOMAKE qux/Makefile
141 write_parse maude-parse.hxx > qux/parse.yxx
142 write_main maude-parse.hxx > qux/main.cxx
147 ls -l . foo bar baz baz/sub qux # For debugging.
151 test -f bar/parse.cpp
152 test -f bar/parse.hpp
153 test -f baz/sub/parse.c++
154 test -f baz/sub/parse.h++
155 test -f qux/maude-parse.cxx
156 test -f qux/maude-parse.hxx
158 # The ylwrap script must be shipped.
160 $MAKE -s echo-distcom | grep '[ /]ylwrap '
162 # The generated C++ source and header files must be shipped.
165 $MAKE -s echo-distcom | grep '[ /]parse\.cc '
166 $MAKE -s echo-distcom | grep '[ /]parse\.hh '
170 $MAKE -s echo-distcom | grep '[ /]parse\.cpp '
171 $MAKE -s echo-distcom | grep '[ /]parse\.hpp '
175 $MAKE -s echo-distcom | grep '[ /]sub/parse\.c++ '
176 $MAKE -s echo-distcom | grep '[ /]sub/parse\.h++ '
180 $MAKE -s echo-distcom | grep '[ /]maude-parse\.cxx '
181 $MAKE -s echo-distcom | grep '[ /]maude-parse\.hxx '
185 find $distdir # For debugging.
187 test -f $distdir/ylwrap
188 test -f $distdir/foo/parse.cc
189 test -f $distdir/foo/parse.hh
190 test -f $distdir/bar/parse.cpp
191 test -f $distdir/bar/parse.hpp
192 test -f $distdir/baz/sub/parse.c++
193 test -f $distdir/baz/sub/parse.h++
194 test -f $distdir/qux/maude-parse.cxx
195 test -f $distdir/qux/maude-parse.hxx
197 # The Yacc-derived C++ sources must be created, and not removed once
198 # compiled (i.e., not treated like "intermediate files" in the GNU
202 # Check that we can recover from deleted headers.
204 rm -f foo/parse.hh bar/parse.hpp baz/sub/parse.h++ qux/maude-parse.hxx
207 test -f bar/parse.hpp
208 test -f baz/sub/parse.h++
209 test -f qux/maude-parse.hxx
211 # Make sure that the Yacc-derived C++ sources are erased by
212 # maintainer-clean, and not by distclean.
216 test -f bar/parse.cpp
217 test -f bar/parse.hpp
218 test -f baz/sub/parse.c++
219 test -f baz/sub/parse.h++
220 test -f qux/maude-parse.cxx
221 test -f qux/maude-parse.hxx
222 ./configure # We must re-create `Makefile'.
223 $MAKE maintainer-clean
224 test ! -f foo/parse.cc
225 test ! -f foo/parse.hh
226 test ! -f bar/parse.cpp
227 test ! -f bar/parse.hpp
228 test ! -f baz/sub/parse.c++
229 test ! -f baz/sub/parse.h++
230 test ! -f qux/maude-parse.cxx
231 test ! -f qux/maude-parse.hxx