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