tests: move coverage about BUILT_SOURCES
[automake.git] / t / silent-many-gcc.sh
blob98104b649807678e1faff6ef89b4af6e32deff79
1 #!/bin/sh
2 # Copyright (C) 2009-2012 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, with gcc depmode and many languages at once.
18 # This test partly overlaps with other 'silent*.sh', 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.sh', which should work with generic compilers.
24 required='gcc g++ gfortran lex yacc'
25 . ./defs || exit 1
27 # Avoids too much code duplication.
28 do_and_check_silent_build ()
30 case $1 in
31 --rebuild) rebuild=true;;
32 *) rebuild=false;;
33 esac
35 $MAKE >stdout || { cat stdout; exit 1; }
36 cat stdout
37 # Avoid spurious failures with SunStudio Fortran compilers.
38 sed '/^NOTICE:/d' stdout > t
39 mv -f t stdout
40 cat stdout
42 $EGREP ' (-c|-o)' stdout && exit 1
43 $EGREP '(mv|ylwrap) ' stdout && exit 1
45 grep 'CXX .*foo1\.' stdout
46 grep 'CXX .*baz1\.' stdout
47 grep 'FC .*foo2\.' stdout
48 grep 'FC .*baz2\.' stdout
49 grep 'F77 .*foo3\.' stdout
50 grep 'F77 .*baz3\.' stdout
51 grep ' CC .*foo5\.' stdout
52 grep ' CC .*baz5\.' stdout
53 grep ' CC .*foo6\.' stdout
54 grep ' CC .*baz6\.' stdout
56 grep 'CXXLD .*foo' stdout
57 grep 'CCLD .*bar' stdout
58 grep 'CXXLD .*baz' stdout
59 grep 'CCLD .*bla' stdout
61 if ! $rebuild; then
62 grep 'YACC .*foo6\.' stdout
63 grep 'YACC .*baz6\.' stdout
64 grep 'LEX .*foo5\.' stdout
65 grep 'LEX .*baz5\.' stdout
68 unset rebuild
71 # Avoids too much code duplication.
72 do_and_check_verbose_build ()
74 case $1 in
75 --rebuild) rebuild=true;;
76 *) rebuild=false;;
77 esac
79 $MAKE V=1 >stdout || { cat stdout; exit 1; }
80 cat stdout
82 grep ' -c ' stdout
83 grep ' -o ' stdout
85 $EGREP '(CC|CXX|FC|F77|LD) ' stdout && exit 1
87 if ! $rebuild; then
88 grep 'ylwrap ' stdout
89 $EGREP '(LEX|YACC) ' stdout && exit 1
92 unset rebuild
95 mkdir sub
97 cat >>configure.ac <<'EOF'
98 AM_SILENT_RULES
99 AM_PROG_CC_C_O
100 AC_PROG_CXX
101 AC_PROG_F77
102 AC_PROG_FC
103 AC_PROG_LEX
104 AC_PROG_YACC
105 AC_CONFIG_FILES([sub/Makefile])
106 AC_OUTPUT
109 cat > Makefile.am <<'EOF'
110 # Need generic and non-generic rules.
111 bin_PROGRAMS = foo bar fo2
112 bar_CFLAGS = $(AM_CFLAGS)
113 foo_SOURCES = foo1.cpp foo2.f90 foo3.f foo5.l foo6.y
114 fo2_SOURCES = $(foo_SOURCES)
115 fo2_CPPFLAGS = $(AM_CPPFLAGS)
116 fo2_FFLAGS = $(AM_FFLAGS)
117 fo2_FCFLAGS = $(AM_FCFLAGS)
118 fo2_YFLAGS = -v
119 fo2_LFLAGS = -n
120 SUBDIRS = sub
121 AM_YFLAGS = -d
122 LDADD = $(LEXLIB)
123 BUILT_SOURCES = foo6.h
126 cat > sub/Makefile.am <<'EOF'
127 AUTOMAKE_OPTIONS = subdir-objects
128 # Need generic and non-generic rules.
129 bin_PROGRAMS = baz bla ba2
130 bla_CFLAGS = $(AM_CFLAGS)
131 baz_SOURCES = baz1.cpp baz2.f90 baz3.f baz5.l baz6.y
132 ba2_SOURCES = $(baz_SOURCES)
133 ba2_CPPFLAGS = $(AM_CPPFLAGS)
134 ba2_FFLAGS = $(AM_FFLAGS)
135 ba2_FCFLAGS = $(AM_FCFLAGS)
136 ba2_YFLAGS = -v
137 ba2_LFLAGS = -n
138 AM_YFLAGS = -d
139 LDADD = $(LEXLIB)
140 BUILT_SOURCES = baz6.h
143 cat > foo1.cpp <<'EOF'
144 int main ()
146 return 0;
149 cat > foo2.f90 <<'EOF'
150 subroutine foo2
151 return
154 cat > foo3.f <<'EOF'
155 subroutine foo3
156 return
159 cat > foo5.l <<'EOF'
161 #define YY_NO_UNISTD_H 1
164 "END" return EOF;
167 /* Avoid possible link errors. */
168 int yywrap (void)
170 return 1;
173 cat > foo6.y <<'EOF'
175 void yyerror (char *s) {}
177 %token EOF
179 fubar : 'f' 'o' 'o' 'b' 'a' 'r' EOF {};
181 cp foo1.cpp bar.c
182 cp foo1.cpp sub/baz.c
183 cp foo1.cpp sub/bla.c
184 cp foo1.cpp sub/baz1.cpp
185 cp foo2.f90 sub/baz2.f90
186 cp foo3.f sub/baz3.f
187 cp foo5.l sub/baz5.l
188 cp foo6.y sub/baz6.y
190 $ACLOCAL
191 $AUTOMAKE --add-missing
192 $AUTOCONF
194 # Sanity check: make sure the cache variables we force are really
195 # used by configure.
196 $FGREP am_cv_CC_dependencies_compiler_type configure
197 $FGREP am_cv_CXX_dependencies_compiler_type configure
198 # Ensure per-target rules are used, to ensure their coverage below.
199 # (We do not do an exhaustive check, that wouldn't be practical).
200 $FGREP 'bar-bar.o' Makefile.in
201 $FGREP 'fo2-foo5.c' Makefile.in
202 $FGREP 'fo2-foo6.c' Makefile.in
204 # Force gcc ("fast") depmode.
205 depmodes="am_cv_CC_dependencies_compiler_type=gcc \
206 am_cv_CXX_dependencies_compiler_type=gcc"
207 # This apparently useless "for" loop is here to simplify the syncing
208 # with sister test 'silent-many-generic.sh'.
209 for config_args in \
210 "$depmodes"
213 ./configure $config_args --enable-silent-rules
215 do_and_check_silent_build
216 # Cleaning and then rebuilding with the same V flag (and without
217 # removing the generated sources in between) shouldn't trigger a
218 # different set of rules.
219 $MAKE clean
220 do_and_check_silent_build --rebuild
222 # Ensure a clean rebuild.
223 $MAKE clean
224 # This is required, since these files are not removed by 'make clean'
225 # (as dictated by the GNU Coding Standards).
226 rm -f *foo5.c *foo6.[ch] sub/*baz5.c sub/*baz6.[ch]
228 do_and_check_verbose_build
229 # Cleaning and then rebuilding with the same V flag (and without
230 # removing the generated sources in between) shouldn't trigger a
231 # different set of rules.
232 $MAKE clean
233 do_and_check_verbose_build --rebuild
235 # Ensure a clean reconfiguration/rebuild.
236 $MAKE clean
237 $MAKE maintainer-clean
239 done