fixup: list of yacc/lex tests was botched
[platform/upstream/automake.git] / tests / silent-many-gcc.test
1 #!/bin/sh
2 # Copyright (C) 2009, 2010, 2011 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, with gcc depmode and many languages at once.
18 # This test partly overlaps with other silent*.test, but it serves as
19 # a stress test by using many different languages at once -- so don't
20 # remove this test script.
21 # This test requires the GNU compilers; keep it in sync with sister test
22 # `silent-many-generic.test', which should work with generic compilers.
23
24 required='gcc g++ gfortran lex yacc'
25 . ./defs || Exit 1
26
27 set -e
28
29 # Avoids too much code duplication.
30 do_and_check_silent_build ()
31 {
32   case $1 in
33     --rebuild) rebuild=true;;
34             *) rebuild=false;;
35   esac
36
37   $MAKE >stdout || { cat stdout; Exit 1; }
38   cat stdout
39   # Avoid spurious failures with SunStudio Fortran compilers.
40   sed '/^NOTICE:/d' stdout > t
41   mv -f t stdout
42   cat stdout
43
44   $EGREP ' (-c|-o)' stdout && Exit 1
45   $EGREP '(mv|ylwrap) ' stdout && Exit 1
46
47   grep 'CXX .*foo1\.' stdout
48   grep 'CXX .*baz1\.' stdout
49   grep 'FC .*foo2\.'  stdout
50   grep 'FC .*baz2\.'  stdout
51   grep 'F77 .*foo3\.' stdout
52   grep 'F77 .*baz3\.' stdout
53   grep ' CC .*foo5\.' stdout
54   grep ' CC .*baz5\.' stdout
55   grep ' CC .*foo6\.' stdout
56   grep ' CC .*baz6\.' stdout
57
58   grep 'CXXLD .*foo' stdout
59   grep 'CCLD .*bar'  stdout
60   grep 'CXXLD .*baz' stdout
61   grep 'CCLD .*bla'  stdout
62
63   if $rebuild; then :; else
64     grep 'YACC .*foo6\.' stdout
65     grep 'YACC .*baz6\.' stdout
66     grep 'LEX .*foo5\.'  stdout
67     grep 'LEX .*baz5\.'  stdout
68   fi
69
70   unset rebuild
71 }
72
73 # Avoids too much code duplication.
74 do_and_check_verbose_build ()
75 {
76   case $1 in
77     --rebuild) rebuild=true;;
78             *) rebuild=false;;
79   esac
80
81   $MAKE V=1 >stdout || { cat stdout; Exit 1; }
82   cat stdout
83
84   grep ' -c ' stdout
85   grep ' -o ' stdout
86
87   $EGREP '(CC|CXX|FC|F77|LD) ' stdout && Exit 1
88
89   if $rebuild; then :; else
90     grep 'ylwrap ' stdout
91     $EGREP '(LEX|YACC) ' stdout && Exit 1
92   fi
93
94   unset rebuild
95 }
96
97 mkdir sub
98
99 cat >>configure.in <<'EOF'
100 AM_SILENT_RULES
101 AM_PROG_CC_C_O
102 AC_PROG_CXX
103 AC_PROG_F77
104 AC_PROG_FC
105 AC_PROG_LEX
106 AC_PROG_YACC
107 AC_CONFIG_FILES([sub/Makefile])
108 AC_OUTPUT
109 EOF
110
111 cat > Makefile.am <<'EOF'
112 # Need generic and non-generic rules.
113 bin_PROGRAMS = foo bar fo2
114 bar_CFLAGS = $(AM_CFLAGS)
115 foo_SOURCES = foo1.cpp foo2.f90 foo3.f foo5.l foo6.y
116 fo2_SOURCES = $(foo_SOURCES)
117 fo2_CPPFLAGS = $(AM_CPPFLAGS)
118 fo2_FFLAGS = $(AM_FFLAGS)
119 fo2_FCFLAGS = $(AM_FCFLAGS)
120 fo2_YFLAGS = -v
121 fo2_LFLAGS = -n
122 SUBDIRS = sub
123 AM_YFLAGS = -d
124 LDADD = $(LEXLIB)
125 BUILT_SOURCES = foo6.h
126 EOF
127
128 cat > sub/Makefile.am <<'EOF'
129 AUTOMAKE_OPTIONS = subdir-objects
130 # Need generic and non-generic rules.
131 bin_PROGRAMS = baz bla ba2
132 bla_CFLAGS = $(AM_CFLAGS)
133 baz_SOURCES = baz1.cpp baz2.f90 baz3.f baz5.l baz6.y
134 ba2_SOURCES = $(baz_SOURCES)
135 ba2_CPPFLAGS = $(AM_CPPFLAGS)
136 ba2_FFLAGS = $(AM_FFLAGS)
137 ba2_FCFLAGS = $(AM_FCFLAGS)
138 ba2_YFLAGS = -v
139 ba2_LFLAGS = -n
140 AM_YFLAGS = -d
141 LDADD = $(LEXLIB)
142 BUILT_SOURCES = baz6.h
143 EOF
144
145 cat > foo1.cpp <<'EOF'
146 int main ()
147 {
148   return 0;
149 }
150 EOF
151 cat > foo2.f90 <<'EOF'
152       subroutine foo2
153       return
154       end
155 EOF
156 cat > foo3.f <<'EOF'
157       subroutine foo3
158       return
159       end
160 EOF
161 cat > foo5.l <<'EOF'
162 %%
163 "END"   return EOF;
164 .
165 %%
166 /* Avoid possible link errors. */
167 int yywrap (void)
168 {
169   return 1;
170 }
171 EOF
172 cat > foo6.y <<'EOF'
173 %{
174 void yyerror (char *s) {}
175 %}
176 %token EOF
177 %%
178 fubar : 'f' 'o' 'o' 'b' 'a' 'r' EOF {};
179 EOF
180 cp foo1.cpp bar.c
181 cp foo1.cpp sub/baz.c
182 cp foo1.cpp sub/bla.c
183 cp foo1.cpp sub/baz1.cpp
184 cp foo2.f90 sub/baz2.f90
185 cp foo3.f sub/baz3.f
186 cp foo5.l sub/baz5.l
187 cp foo6.y sub/baz6.y
188
189 $ACLOCAL
190 $AUTOMAKE --add-missing
191 $AUTOCONF
192
193 # Ensure per-target rules are used, to ensure their coverage below.
194 # (We do not do an exhaustive check, that wouldn't be practical).
195 $FGREP 'bar-bar.o' Makefile.in
196 $FGREP 'fo2-foo5.c' Makefile.in
197 $FGREP 'fo2-foo6.c' Makefile.in
198
199 # Force gcc ("fast") depmode.
200 # This apparently useless "for" loop is here to simplify the syncing
201 # with sister test `silent-many-generic.test'.
202 for config_args in \
203   am_cv_CC_dependencies_compiler_type=gcc
204 do
205
206   ./configure $config_args --enable-silent-rules
207
208   do_and_check_silent_build
209   # Cleaning and then rebuilding with the same V flag (and without
210   # removing the generated sources in between) shouldn't trigger a
211   # different set of rules.
212   $MAKE clean
213   do_and_check_silent_build --rebuild
214
215   # Ensure a clean rebuild.
216   $MAKE clean
217   # This is required, since these files are not removed by `make clean'
218   # (as dictated by the GNU Coding Standards).
219   rm -f *foo5.c *foo6.[ch] sub/*baz5.c sub/*baz6.[ch]
220
221   do_and_check_verbose_build
222   # Cleaning and then rebuilding with the same V flag (and without
223   # removing the generated sources in between) shouldn't trigger a
224   # different set of rules.
225   $MAKE clean
226   do_and_check_verbose_build --rebuild
227
228   # Ensure a clean reconfiguration/rebuild.
229   $MAKE clean
230   $MAKE maintainer-clean
231
232 done
233
234 :