maint: Document how to handle assignment exemption
[automake.git] / t / silent-yacc-headers.sh
blobff3ea3678f6ae1a478cc25df059a60217c0415a0
1 #!/bin/sh
2 # Copyright (C) 2011-2017 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)
7 # any later version.
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 silent-rules mode for Yacc, when yacc-generated headers are
18 # involved (i.e., the '-d' option is in *YFLAGS).
20 required='cc yacc'
21 . test-init.sh
23 mkdir sub
25 cat >>configure.ac <<'EOF'
26 AC_PROG_YACC
27 AC_PROG_CC
28 AC_OUTPUT
29 EOF
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
40 cat > parse.y <<'EOF'
42 void yyerror (char *s) { return; }
43 int yylex (void) { return 0; }
44 int main (void) { return 0; }
46 %token EOF
48 fubar : 'f' 'o' 'o' 'b' 'a' 'r' EOF {};
49 EOF
51 $ACLOCAL
52 $AUTOMAKE --add-missing
53 $AUTOCONF
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
61 ./configure --enable-silent-rules
63 run_make -O
65 $EGREP ' (-c|-d|-o)' stdout && exit 1
66 $EGREP '(mv|ylwrap) ' stdout && exit 1
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
73 grep ' CC *parse\.' stdout
74 grep ' CC *bar-parse\.' stdout
75 grep 'CCLD *foo' stdout
76 grep 'CCLD *bar' stdout
78 # Check recovering from header removal.
79 rm -f parse.h bar-parse.h
80 run_make -O parse.h bar-parse.h
82 $EGREP ' (-c|-d|-o)' stdout && exit 1
83 $EGREP '(mv|ylwrap) ' stdout && exit 1
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
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
95 run_make -O
97 $EGREP ' (-c|-d|-o)' stdout && exit 1
98 $EGREP '(mv|ylwrap) ' stdout && exit 1
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
107 # Check recovering from header removal.
108 rm -f parse.h bar-parse.h
109 run_make -O parse.h bar-parse.h
111 $EGREP ' (-c|-d|-o)' stdout && exit 1
112 $EGREP '(mv|ylwrap) ' stdout && exit 1
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
119 # Ensure a truly clean rebuild.
120 $MAKE maintainer-clean
122 ./configure --enable-silent-rules
124 run_make -O V=1
126 grep ' -c ' stdout
127 grep ' -o ' stdout
128 grep ' -d ' stdout
129 grep 'ylwrap ' stdout
131 $EGREP '(YACC|CC|CCLD) ' stdout && exit 1
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
137 grep ' -d ' stdout
138 grep 'ylwrap ' stdout
140 grep 'YACC' stdout && exit 1
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
147 run_make -O V=1
149 # Don't look for ylwrap, as probably lex hasn't been re-run.
150 grep ' -c ' stdout
151 grep ' -o ' stdout
153 $EGREP '(YACC|CC|CCLD) ' stdout && exit 1
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
159 grep ' -d ' stdout
160 grep 'ylwrap ' stdout
162 grep 'YACC' stdout && exit 1