blob: 61a3535ba672267f430ef8f414d9ceedae542e31 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
|
#! /bin/sh
# Copyright (C) 2011-2014 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/>.
# Tests that we can recover from deleted headers generated by 'yacc -d'.
required='cc yacc'
. test-init.sh
cat >> configure.ac << 'END'
AC_PROG_CC
AC_PROG_YACC
AC_OUTPUT
END
cat > Makefile.am <<'END'
bin_PROGRAMS = p1 p2 p3 p4
# The order in which files are listed in the p*_SOURCES variables
# below is significant, since it causes make failures whenever
# the proper definition of BUILT_SOURCES or the declaration of
# extra dependencies for 'main3.o' are removed.
p1_SOURCES = main1.c parse1.y
p2_SOURCES = main2.c parse2.y
p3_SOURCES = main3.c parse3.y parse3.h
p4_SOURCES = parse4.y
AM_YFLAGS = -d
p2_YFLAGS = -d
BUILT_SOURCES = parse1.h p2-parse2.h
# When we know which files include a yacc-generated header, we
# should be able to just declare dependencies directly instead
# of relying on the BUILT_SOURCES hack, and things should still
# work correctly.
main3.@OBJEXT@ parse3.@OBJEXT@: parse3.h
.PHONY: clean-p3 build-p3
build-p3: p3$(EXEEXT)
clean-p3:
rm -f p3$(EXEEXT)
END
cat > parse1.y << 'END'
%{
#include "parse1.h"
int yylex () { return 0; }
void yyerror (char *s) { return; }
%}
%token ZARDOZ
%%
x : 'x' {};
%%
END
cat > main1.c << 'END'
#include "parse1.h"
int main (void)
{
return ZARDOZ + yyparse ();
}
END
sed 's/"parse1\.h"/"p2-parse2.h"/' parse1.y > parse2.y
sed 's/"parse1\.h"/"p2-parse2.h"/' main1.c > main2.c
sed 's/"parse1\.h"/"parse3.h"/' parse1.y > parse3.y
sed 's/"parse1\.h"/"parse3.h"/' main1.c > main3.c
cat > parse4.y << 'END'
%{
int yylex () { return 0; }
void yyerror (char *s) { return; }
%}
%%
x : 'x' {};
%%
int main (void)
{
return 0;
}
END
$ACLOCAL
$AUTOCONF
$AUTOMAKE -a
./configure
$MAKE
headers='parse1.h p2-parse2.h parse3.h parse4.h'
rm -f $headers
$MAKE $headers
for h in $headers; do test -f $h; done
# Most headers should be remade by "make all".
rm -f $headers
$MAKE all
test -f parse1.h
test -f p2-parse2.h
test -f parse3.h
# parse4.h is not declared in any *_SOURCES variable, nor in
# BUILT_SOURCES, nor #included by any C source file, so it
# shouldn't be rebuilt by "make all".
test ! -e parse4.h
:
|