2 # Copyright (C) 2011-2013 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.sh'.
29 // Valid C++, but deliberately invalid C.
32 int yylex (void) { return 0; }
33 void yyerror (const char *s) {}
45 // Valid C++, but deliberately invalid C.
48 int main (int argc, char **argv)
56 cat >> configure.ac
<< 'END'
59 AC_CONFIG_FILES
([foo
/Makefile bar
/Makefile baz
/Makefile qux
/Makefile
])
63 mkdir foo bar baz qux baz
/sub
65 # These makefiles will be extended later.
66 cat > Makefile.am
<<'END'
69 @echo ' ' $(DIST_COMMON) ' '
71 cp Makefile.am foo
/Makefile.am
72 cp Makefile.am bar
/Makefile.am
73 cp Makefile.am baz
/Makefile.am
74 cp Makefile.am qux
/Makefile.am
76 cat >> Makefile.am
<<'END'
77 SUBDIRS = foo bar baz qux
83 cp "$am_scriptdir/ylwrap" . \
84 || fatal_
"cannot fetch auxiliary script 'ylwrap'"
88 # Try with -d in $(YFLAGS) (don't do this in real life!).
89 cat >> foo
/Makefile.am
<<END
91 zardoz_SOURCES = parse.yy main.cc
92 BUILT_SOURCES = parse.hh
97 $AUTOMAKE -Wno-gnu foo
/Makefile
99 write_parse parse.hh
> foo
/parse.yy
100 write_main parse.hh
> foo
/main.cc
102 # Try with -d in $(AM_YFLAGS).
103 cat >> bar
/Makefile.am
<<END
104 bin_PROGRAMS = zardoz
105 zardoz_SOURCES = parse.ypp main.cpp
106 BUILT_SOURCES = parse.hpp
107 AM_YFLAGS${tab}= -d ${tab}
110 $AUTOMAKE bar
/Makefile
112 write_parse parse.hpp
> bar
/parse.ypp
113 write_main parse.hpp
> bar
/main.cpp
115 # Try with -d in $(AM_YFLAGS), and a subdir parser.
116 cat >> baz
/Makefile.am
<<END
117 AUTOMAKE_OPTIONS = subdir-objects
119 joe_SOURCES = sub/parse.y++ sub/main.c++
120 BUILT_SOURCES = sub/parse.h++
125 $AUTOMAKE baz
/Makefile
127 write_parse sub
/parse.h
++ > baz
/sub
/parse.y
++
128 write_main sub
/parse.h
++ > baz
/sub
/main.c
++
130 # Try with -d in $(xxx_YFLAGS) (per-object flag).
131 cat >> qux
/Makefile.am
<<END
133 maude_SOURCES = parse.yxx main.cxx
134 maude_YFLAGS=${tab} -d${tab}
135 BUILT_SOURCES = maude-parse.hxx
138 $AUTOMAKE qux
/Makefile
140 write_parse maude-parse.hxx
> qux
/parse.yxx
141 write_main maude-parse.hxx
> qux
/main.cxx
146 ls -l . foo bar baz baz
/sub qux
# For debugging.
150 test -f bar
/parse.cpp
151 test -f bar
/parse.hpp
152 test -f baz
/sub
/parse.c
++
153 test -f baz
/sub
/parse.h
++
154 test -f qux
/maude-parse.cxx
155 test -f qux
/maude-parse.hxx
157 # The ylwrap script must be shipped.
159 $MAKE -s echo-distcom |
grep '[ /]ylwrap '
161 # The generated C++ source and header files must be shipped.
164 $MAKE -s echo-distcom |
grep '[ /]parse\.cc '
165 $MAKE -s echo-distcom |
grep '[ /]parse\.hh '
169 $MAKE -s echo-distcom |
grep '[ /]parse\.cpp '
170 $MAKE -s echo-distcom |
grep '[ /]parse\.hpp '
174 $MAKE -s echo-distcom |
grep '[ /]sub/parse\.c++ '
175 $MAKE -s echo-distcom |
grep '[ /]sub/parse\.h++ '
179 $MAKE -s echo-distcom |
grep '[ /]maude-parse\.cxx '
180 $MAKE -s echo-distcom |
grep '[ /]maude-parse\.hxx '
184 find $distdir # For debugging.
186 test -f $distdir/ylwrap
187 test -f $distdir/foo
/parse.cc
188 test -f $distdir/foo
/parse.hh
189 test -f $distdir/bar
/parse.cpp
190 test -f $distdir/bar
/parse.hpp
191 test -f $distdir/baz
/sub
/parse.c
++
192 test -f $distdir/baz
/sub
/parse.h
++
193 test -f $distdir/qux
/maude-parse.cxx
194 test -f $distdir/qux
/maude-parse.hxx
196 # The Yacc-derived C++ sources must be created, and not removed once
197 # compiled (i.e., not treated like "intermediate files" in the GNU
201 # Check that we can recover from deleted headers.
203 rm -f foo
/parse.hh bar
/parse.hpp baz
/sub
/parse.h
++ qux
/maude-parse.hxx
206 test -f bar
/parse.hpp
207 test -f baz
/sub
/parse.h
++
208 test -f qux
/maude-parse.hxx
210 # Make sure that the Yacc-derived C++ sources are erased by
211 # maintainer-clean, and not by distclean.
215 test -f bar
/parse.cpp
216 test -f bar
/parse.hpp
217 test -f baz
/sub
/parse.c
++
218 test -f baz
/sub
/parse.h
++
219 test -f qux
/maude-parse.cxx
220 test -f qux
/maude-parse.hxx
221 .
/configure
# Re-create 'Makefile'.
222 $MAKE maintainer-clean
223 test ! -e foo
/parse.cc
224 test ! -e foo
/parse.hh
225 test ! -e bar
/parse.cpp
226 test ! -e bar
/parse.hpp
227 test ! -e baz
/sub
/parse.c
++
228 test ! -e baz
/sub
/parse.h
++
229 test ! -e qux
/maude-parse.cxx
230 test ! -e qux
/maude-parse.hxx