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 # Tests that we can recover from deleted headers generated by 'yacc -d'.
22 cat >> configure.ac
<< 'END'
28 cat > Makefile.am
<<'END'
29 bin_PROGRAMS = p1 p2 p3 p4
30 # The order in which files are listed in the p*_SOURCES variables
31 # below is significant, since it causes make failures whenever
32 # the proper definition of BUILT_SOURCES or the declaration of
33 # extra dependencies for 'main3.o' are removed.
34 p1_SOURCES = main1.c parse1.y
35 p2_SOURCES = main2.c parse2.y
36 p3_SOURCES = main3.c parse3.y parse3.h
41 BUILT_SOURCES = parse1.h p2-parse2.h
43 # When we know which files include a yacc-generated header, we
44 # should be able to just declare dependencies directly instead
45 # of relying on the BUILT_SOURCES hack, and things should still
47 main3.@OBJEXT@ parse3.@OBJEXT@: parse3.h
49 .PHONY: clean-p3 build-p3
55 cat > parse1.y
<< 'END'
58 int yylex
() { return 0; }
59 void yyerror
(char
*s
) { return; }
67 cat > main1.c
<< 'END'
71 return ZARDOZ
+ yyparse
();
75 sed 's/"parse1\.h"/"p2-parse2.h"/' parse1.y
> parse2.y
76 sed 's/"parse1\.h"/"p2-parse2.h"/' main1.c
> main2.c
78 sed 's/"parse1\.h"/"parse3.h"/' parse1.y
> parse3.y
79 sed 's/"parse1\.h"/"parse3.h"/' main1.c
> main3.c
81 cat > parse4.y
<< 'END'
83 int yylex
() { return 0; }
84 void yyerror
(char
*s
) { return; }
102 headers
='parse1.h p2-parse2.h parse3.h parse4.h'
104 # Check that we remake only the necessary headers.
109 test ! -e p2-parse2.h
123 test ! -e p2-parse2.h
126 # Since we declared parse3.h into $(p3_SOURCES), make should be
127 # able to rebuild it automatically before remaking 'p3'.
130 test ! -e parse3.h
# Sanity check.
139 test ! -e p2-parse2.h
143 # Now remake all the headers together.
152 # Most headers should be remade by "make all".
159 # parse4.h is not declared in any *_SOURCES variable, nor #included
160 # by any C source file, so it shouldn't be rebuilt by "make all".