| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232 | #! /bin/sh# Copyright (C) 2011-2017 Free Software Foundation, Inc.## This program is free software; you can redistribute it and/or modify# it under the terms of the GNU General Public License as published by# the Free Software Foundation; either version 2, or (at your option)# any later version.## This program is distributed in the hope that it will be useful,# but WITHOUT ANY WARRANTY; without even the implied warranty of# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the# GNU General Public License for more details.## You should have received a copy of the GNU General Public License# along with this program.  If not, see <http://www.gnu.org/licenses/>.# Various tests on Yacc/C++ support with yacc-generated headers# (i.e., '-d' in *YFLAGS).# Keep in sync with sister test 'yacc-d-basic.sh'.required='c++ yacc'. test-init.shwrite_parse (){  header=$1  unindent <<END    %{    // Valid C++, but deliberately invalid C.    #include <cstdlib>    #include "$header"    int yylex (void) { return 0; }    void yyerror (const char *s) {}    %}    %%    x : 'x' {};    %%END}write_main (){  header=$1  unindent <<END    // Valid C++, but deliberately invalid C.    #include <cstdio>    #include "$header"    int main (int argc, char **argv)    {      int yyparse (void);      return yyparse ();    }END}cat >> configure.ac << 'END'AC_PROG_CXXAC_PROG_YACCAC_CONFIG_FILES([foo/Makefile bar/Makefile baz/Makefile qux/Makefile])AC_OUTPUTENDmkdir foo bar baz qux baz/sub# These makefiles will be extended later.cat > Makefile.am <<'END'.PHONY: echo-distcomecho-distcom:	@echo ' ' $(DIST_COMMON) ' 'ENDcp Makefile.am foo/Makefile.amcp Makefile.am bar/Makefile.amcp Makefile.am baz/Makefile.amcp Makefile.am qux/Makefile.amcat >> Makefile.am <<'END'SUBDIRS = foo bar baz quxEND$ACLOCAL$AUTOCONFcp "$am_scriptdir/ylwrap" . \  || fatal_ "cannot fetch auxiliary script 'ylwrap'"$AUTOMAKE Makefile# Try with -d in $(YFLAGS) (don't do this in real life!).cat >> foo/Makefile.am <<ENDbin_PROGRAMS = zardozzardoz_SOURCES = parse.yy main.ccBUILT_SOURCES = parse.hhYFLAGS=\-dEND$AUTOMAKE -Wno-gnu foo/Makefilewrite_parse parse.hh > foo/parse.yywrite_main parse.hh > foo/main.cc# Try with -d in $(AM_YFLAGS).cat >> bar/Makefile.am <<ENDbin_PROGRAMS = zardozzardoz_SOURCES = parse.ypp main.cppBUILT_SOURCES = parse.hppAM_YFLAGS${tab}=  -d ${tab}END$AUTOMAKE bar/Makefilewrite_parse parse.hpp > bar/parse.yppwrite_main parse.hpp > bar/main.cpp# Try with -d in $(AM_YFLAGS), and a subdir parser.cat >> baz/Makefile.am <<ENDAUTOMAKE_OPTIONS = subdir-objectsbin_PROGRAMS = joejoe_SOURCES = sub/parse.y++ sub/main.c++BUILT_SOURCES = sub/parse.h++AM_YFLAGS = \${tab}-dEND$AUTOMAKE baz/Makefilewrite_parse sub/parse.h++ > baz/sub/parse.y++write_main sub/parse.h++ > baz/sub/main.c++# Try with -d in $(xxx_YFLAGS) (per-object flag).cat >> qux/Makefile.am <<ENDbin_PROGRAMS = maudemaude_SOURCES = parse.yxx main.cxxmaude_YFLAGS=${tab}  -d${tab}BUILT_SOURCES = maude-parse.hxxEND$AUTOMAKE qux/Makefilewrite_parse maude-parse.hxx > qux/parse.yxxwrite_main maude-parse.hxx > qux/main.cxx./configure$MAKEls -l . foo bar baz baz/sub qux # For debugging.test -f foo/parse.cctest -f foo/parse.hhtest -f bar/parse.cpptest -f bar/parse.hpptest -f baz/sub/parse.c++test -f baz/sub/parse.h++test -f qux/maude-parse.cxxtest -f qux/maude-parse.hxx# The ylwrap script must be shipped.$MAKE echo-distcom$MAKE -s echo-distcom | grep '[ /]ylwrap '# The generated C++ source and header files must be shipped.cd foo$MAKE echo-distcom$MAKE -s echo-distcom | grep '[ /]parse\.cc '$MAKE -s echo-distcom | grep '[ /]parse\.hh 'cd ..cd bar$MAKE echo-distcom$MAKE -s echo-distcom | grep '[ /]parse\.cpp '$MAKE -s echo-distcom | grep '[ /]parse\.hpp 'cd ..cd baz$MAKE echo-distcom$MAKE -s echo-distcom | grep '[ /]sub/parse\.c++ '$MAKE -s echo-distcom | grep '[ /]sub/parse\.h++ 'cd ..cd qux$MAKE echo-distcom$MAKE -s echo-distcom | grep '[ /]maude-parse\.cxx '$MAKE -s echo-distcom | grep '[ /]maude-parse\.hxx 'cd ..$MAKE distdirfind $distdir # For debugging.test -f $distdir/ylwraptest -f $distdir/foo/parse.cctest -f $distdir/foo/parse.hhtest -f $distdir/bar/parse.cpptest -f $distdir/bar/parse.hpptest -f $distdir/baz/sub/parse.c++test -f $distdir/baz/sub/parse.h++test -f $distdir/qux/maude-parse.cxxtest -f $distdir/qux/maude-parse.hxx# The Yacc-derived C++ sources must be created, and not removed once# compiled (i.e., not treated like "intermediate files" in the GNU# make sense).yl_distcheck# Check that we can recover from deleted headers.$MAKE cleanrm -f foo/parse.hh bar/parse.hpp baz/sub/parse.h++ qux/maude-parse.hxx$MAKEtest -f foo/parse.hhtest -f bar/parse.hpptest -f baz/sub/parse.h++test -f qux/maude-parse.hxx# Make sure that the Yacc-derived C++ sources are erased by# maintainer-clean, and not by distclean.$MAKE distcleantest -f foo/parse.cctest -f foo/parse.hhtest -f bar/parse.cpptest -f bar/parse.hpptest -f baz/sub/parse.c++test -f baz/sub/parse.h++test -f qux/maude-parse.cxxtest -f qux/maude-parse.hxx./configure # Re-create 'Makefile'.$MAKE maintainer-cleantest ! -e foo/parse.cctest ! -e foo/parse.hhtest ! -e bar/parse.cpptest ! -e bar/parse.hpptest ! -e baz/sub/parse.c++test ! -e baz/sub/parse.h++test ! -e qux/maude-parse.cxxtest ! -e qux/maude-parse.hxx:
 |