tests: cosmetic changes in t/extra-sources.sh
[platform/upstream/automake.git] / t / silent-yacc-headers.sh
1 #!/bin/sh
2 # Copyright (C) 2011-2013 Free Software Foundation, Inc.
3 #
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)
7 # any later version.
8 #
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.
13 #
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/>.
16
17 # Check silent-rules mode for Yacc, when yacc-generated headers are
18 # involved (i.e., the '-d' option is in *YFLAGS).
19
20 required='cc yacc'
21 . test-init.sh
22
23 mkdir sub
24
25 cat >>configure.ac <<'EOF'
26 AC_PROG_YACC
27 AC_PROG_CC
28 AC_OUTPUT
29 EOF
30
31 cat > Makefile.am <<'EOF'
32 # Need generic and non-generic rules.
33 AM_YFLAGS = -d
34 bin_PROGRAMS = foo bar
35 foo_SOURCES = parse.y
36 bar_SOURCES = $(foo_SOURCES)
37 bar_YFLAGS = $(AM_YFLAGS)
38 EOF
39
40 cat > parse.y <<'EOF'
41 %{
42 void yyerror (char *s) { return; }
43 int yylex (void) { return 0; }
44 int main (void) { return 0; }
45 %}
46 %token EOF
47 %%
48 fubar : 'f' 'o' 'o' 'b' 'a' 'r' EOF {};
49 EOF
50
51 $ACLOCAL
52 $AUTOMAKE --add-missing
53 $AUTOCONF
54
55 # Check that the expected non-generic rules has been truly generated.
56 # Otherwise, the coverage offered by this test will be weaker then
57 # expected and planned.
58 $FGREP 'bar-parse.c' Makefile.in
59 $FGREP '$(bar_YFLAGS)' Makefile.in
60
61 ./configure --enable-silent-rules
62
63 run_make -O
64
65 $EGREP ' (-c|-d|-o)' stdout && exit 1
66 $EGREP '(mv|ylwrap) ' stdout && exit 1
67
68 grep 'YACC  *parse\.c' stdout
69 grep 'updating  *parse\.h' stdout
70 grep 'YACC  *bar-parse\.c' stdout
71 grep 'updating  *bar-parse\.h' stdout
72
73 grep ' CC  *parse\.' stdout
74 grep ' CC  *bar-parse\.' stdout
75 grep 'CCLD  *foo' stdout
76 grep 'CCLD  *bar' stdout
77
78 # Check recovering from header removal.
79 rm -f parse.h bar-parse.h
80 run_make -O parse.h bar-parse.h
81
82 $EGREP ' (-c|-d|-o)' stdout && exit 1
83 $EGREP '(mv|ylwrap) ' stdout && exit 1
84
85 grep 'YACC  *parse\.c' stdout
86 grep 'updating  *parse\.h' stdout
87 grep 'YACC  *bar-parse\.c' stdout
88 grep 'updating  *bar-parse\.h' stdout
89
90 # Cleaning and then rebuilding with the same V flag (and without
91 # removing the generated sources in between) shouldn't trigger a
92 # different set of rules.
93 $MAKE clean
94
95 run_make -O
96
97 $EGREP ' (-c|-d|-o)' stdout && exit 1
98 $EGREP '(mv|ylwrap) ' stdout && exit 1
99
100 # Don't look for "YACC *.c" and "updating *.h", as yacc shouldn't
101 # have been re-run.
102 grep ' CC  *parse\.' stdout
103 grep ' CC  *bar-parse\.' stdout
104 grep 'CCLD  *foo' stdout
105 grep 'CCLD  *bar' stdout
106
107 # Check recovering from header removal.
108 rm -f parse.h bar-parse.h
109 run_make -O parse.h bar-parse.h
110
111 $EGREP ' (-c|-d|-o)' stdout && exit 1
112 $EGREP '(mv|ylwrap) ' stdout && exit 1
113
114 grep 'YACC  *parse\.c' stdout
115 grep 'updating  *parse\.h' stdout
116 grep 'YACC  *bar-parse\.c' stdout
117 grep 'updating  *bar-parse\.h' stdout
118
119 # Ensure a truly clean rebuild.
120 $MAKE maintainer-clean
121
122 ./configure --enable-silent-rules
123
124 run_make -O V=1
125
126 grep ' -c ' stdout
127 grep ' -o ' stdout
128 grep ' -d ' stdout
129 grep 'ylwrap ' stdout
130
131 $EGREP '(YACC|CC|CCLD) ' stdout && exit 1
132
133 # Check recovering from header removal.
134 rm -f parse.h bar-parse.h
135 run_make -O V=1 parse.h bar-parse.h
136
137 grep ' -d ' stdout
138 grep 'ylwrap ' stdout
139
140 grep 'YACC' stdout && exit 1
141
142 # Cleaning and then rebuilding with the same V flag (and without
143 # removing the generated sources in between) shouldn't trigger a
144 # different set of rules.
145 $MAKE clean
146
147 run_make -O V=1
148
149 # Don't look for ylwrap, as probably lex hasn't been re-run.
150 grep ' -c ' stdout
151 grep ' -o ' stdout
152
153 $EGREP '(YACC|CC|CCLD) ' stdout && exit 1
154
155 # Check recovering from header removal.
156 rm -f parse.h bar-parse.h
157 run_make -O V=1 parse.h bar-parse.h
158
159 grep ' -d ' stdout
160 grep 'ylwrap ' stdout
161
162 grep 'YACC' stdout && exit 1
163
164 :