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 # Check that .c and .h files derived from non-distributed .y sources
18 # are cleaned by "make clean", while .c and .h files derived from
19 # distributed .y sources are cleaned by "make maintainer-clean".
20 # See also sister test 'yacc-cxx-clean.test'.
25 cat >> configure.ac << 'END'
28 AC_CONFIG_FILES([sub1/Makefile sub2/Makefile])
32 cat > Makefile.am << 'END'
33 # Use two subdirectories, one to test with '-d' in YFLAGS, the
34 # other one to test with empty YFLAGS.
40 cat > sub1/Makefile.am << 'END'
41 bin_PROGRAMS = foo bar baz qux
43 foo_SOURCES = main.c parse.y
45 bar_SOURCES = main.c parse.y
46 bar_YFLAGS = $(AM_YFLAGS)
49 nodist_baz_SOURCES = baz.y
52 nodist_qux_SOURCES = baz.y
53 qux_YFLAGS = $(AM_YFLAGS)
56 cp $(srcdir)/parse.y $@
61 cat > sub2/Makefile.am << 'END'
62 include $(top_srcdir)/sub1/Makefile.am
66 cat > sub1/parse.y << 'END'
68 int yylex () { return (getchar ()); }
69 void yyerror (char *s) {}
74 cp sub1/parse.y sub2/parse.y
76 cat > sub1/main.c << 'END'
82 cp sub1/main.c sub2/main.c
90 cp config.status config.sav
97 test -f sub1/bar-parse.c
100 test -f sub1/qux-baz.c
104 test -f sub2/bar-parse.c
105 test -f sub2/bar-parse.h
109 test -f sub2/qux-baz.c
110 test -f sub2/qux-baz.h
112 for target in clean distclean; do
117 test -f sub1/bar-parse.c
120 test ! -e sub1/qux-baz.c
124 test -f sub2/bar-parse.c
125 test -f sub2/bar-parse.h
129 test ! -e sub2/qux-baz.c
130 test ! -e sub2/qux-baz.h
133 cp config.sav config.status
134 ./config.status # Re-create 'Makefile'.
136 $MAKE maintainer-clean
139 test ! -e sub1/parse.c
140 test ! -e sub1/bar-parse.c
142 test ! -e sub2/parse.c
143 test ! -e sub2/parse.h
144 test ! -e sub2/bar-parse.c
145 test ! -e sub2/bar-parse.h