Merge branch 'maint'
[platform/upstream/automake.git] / t / silent-yacc.sh
1 #!/bin/sh
2 # Copyright (C) 2010-2012 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.
18 # Keep this in sync with sister test 'silent-yacc-gcc.sh'.
19
20 required='cc yacc'
21 . ./defs || exit 1
22
23 mkdir sub
24
25 cat >>configure.ac <<'EOF'
26 AM_PROG_CC_C_O
27 AC_PROG_YACC
28 AC_CONFIG_FILES([sub/Makefile])
29 AC_OUTPUT
30 EOF
31
32 cat > Makefile.am <<'EOF'
33 # Need generic and non-generic rules.
34 bin_PROGRAMS = foo1 foo2
35 foo1_SOURCES = foo.y
36 foo2_SOURCES = $(foo1_SOURCES)
37 foo2_YFLAGS = -v
38 foo2_CFLAGS = $(AM_CPPFLAGS)
39 SUBDIRS = sub
40 EOF
41
42 cat > sub/Makefile.am <<'EOF'
43 AUTOMAKE_OPTIONS = subdir-objects
44 # Need generic and non-generic rules.
45 bin_PROGRAMS = bar1 bar2
46 bar1_SOURCES = bar.y
47 bar2_SOURCES = $(bar1_SOURCES)
48 bar2_YFLAGS = -v
49 bar2_CFLAGS = $(AM_CPPFLAGS)
50 EOF
51
52 cat > foo.y <<'EOF'
53 %{
54 void yyerror (char *s) { return; }
55 int yylex (void) { return 0; }
56 int main (void) { return 0; }
57 %}
58 %token EOF
59 %%
60 fubar : 'f' 'o' 'o' 'b' 'a' 'r' EOF {};
61 EOF
62 cp foo.y sub/bar.y
63
64 $ACLOCAL
65 $AUTOMAKE --add-missing
66 $AUTOCONF
67
68 # Ensure per-target rules are used, to ensure their coverage below.
69 $FGREP 'foo2-foo.c' Makefile.in || exit 99
70 $FGREP 'bar2-bar.c' sub/Makefile.in || exit 99
71
72 ./configure --enable-silent-rules
73
74 $MAKE >stdout || { cat stdout; exit 1; }
75 cat stdout
76
77 $EGREP ' (-c|-o)' stdout && exit 1
78 $EGREP '(mv|ylwrap) ' stdout && exit 1
79
80 grep 'YACC .*foo\.' stdout
81 grep 'YACC .*bar\.' stdout
82 grep ' CC .*foo\.' stdout
83 grep ' CC .*bar\.' stdout
84 grep 'CCLD .*foo1' stdout
85 grep 'CCLD .*bar1' stdout
86 grep 'CCLD .*foo2' stdout
87 grep 'CCLD .*bar2' stdout
88
89 # Cleaning and then rebuilding with the same V flag (and without
90 # removing the generated sources in between) shouldn't trigger a
91 # different set of rules.
92 $MAKE clean
93
94 $MAKE >stdout || { cat stdout; exit 1; }
95 cat stdout
96
97 $EGREP ' (-c|-o)' stdout && exit 1
98 $EGREP '(mv|ylwrap) ' stdout && exit 1
99
100 # Don't look for YACC, as probably yacc hasn't been re-run.
101 grep ' CC .*foo\.' stdout
102 grep ' CC .*bar\.' stdout
103 grep 'CCLD .*foo1' stdout
104 grep 'CCLD .*bar1' stdout
105 grep 'CCLD .*foo2' stdout
106 grep 'CCLD .*bar2' stdout
107
108 # Ensure a truly clean rebuild.
109 $MAKE clean
110 rm -f *foo.[ch] sub/*bar.[ch]
111
112 $MAKE V=1 >stdout || { cat stdout; exit 1; }
113 cat stdout
114
115 grep ' -c ' stdout
116 grep ' -o ' stdout
117 grep 'ylwrap ' stdout
118
119 $EGREP '(YACC|CC|CCLD) ' stdout && exit 1
120
121 # Cleaning and then rebuilding with the same V flag (and without
122 # removing the generated sources in between) shouldn't trigger a
123 # different set of rules.
124 $MAKE clean
125
126 $MAKE V=1 >stdout || { cat stdout; exit 1; }
127 cat stdout
128
129 # Don't look for ylwrap, as probably lex hasn't been re-run.
130 grep ' -c ' stdout
131 grep ' -o ' stdout
132
133 $EGREP '(YACC|CC|CCLD) ' stdout && exit 1
134
135 :