Merge branch 'maint'
[platform/upstream/automake.git] / t / silent-many-generic.sh
1 #!/bin/sh
2 # Copyright (C) 2009-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, with 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 should work with generic compilers; keep it in sync with
22 # sister test 'silent-many-gcc.test', which requires the GNU compilers
23 # and forces the use of gcc depmode.
24
25 required='cc c++ fortran fortran77 lex yacc'
26 . ./defs || exit 1
27
28 # Avoids too much code duplication.
29 do_and_check_silent_build ()
30 {
31   case $1 in
32     --rebuild) rebuild=true;;
33             *) rebuild=false;;
34   esac
35
36   $MAKE >stdout || { cat stdout; exit 1; }
37   cat stdout
38   # Avoid spurious failures with SunStudio Fortran compilers.
39   sed '/^NOTICE:/d' stdout > t
40   mv -f t stdout
41   cat stdout
42
43   $EGREP ' (-c|-o)' stdout && exit 1
44   $EGREP '(mv|ylwrap) ' stdout && exit 1
45
46   grep 'CXX .*foo1\.' stdout
47   grep 'CXX .*baz1\.' stdout
48   grep 'FC .*foo2\.'  stdout
49   grep 'FC .*baz2\.'  stdout
50   grep 'F77 .*foo3\.' stdout
51   grep 'F77 .*baz3\.' stdout
52   grep ' CC .*foo5\.' stdout
53   grep ' CC .*baz5\.' stdout
54   grep ' CC .*foo6\.' stdout
55   grep ' CC .*baz6\.' stdout
56
57   grep 'CXXLD .*foo' stdout
58   grep 'CCLD .*bar'  stdout
59   grep 'CXXLD .*baz' stdout
60   grep 'CCLD .*bla'  stdout
61
62   if ! $rebuild; then
63     grep 'YACC .*foo6\.' stdout
64     grep 'YACC .*baz6\.' stdout
65     grep 'LEX .*foo5\.'  stdout
66     grep 'LEX .*baz5\.'  stdout
67   fi
68
69   unset rebuild
70 }
71
72 # Avoids too much code duplication.
73 do_and_check_verbose_build ()
74 {
75   case $1 in
76     --rebuild) rebuild=true;;
77             *) rebuild=false;;
78   esac
79
80   $MAKE V=1 >stdout || { cat stdout; exit 1; }
81   cat stdout
82
83   grep ' -c ' stdout
84   grep ' -o ' stdout
85
86   $EGREP '(CC|CXX|FC|F77|LD) ' stdout && exit 1
87
88   if ! $rebuild; then
89     grep 'ylwrap ' stdout
90     $EGREP '(LEX|YACC) ' stdout && exit 1
91   fi
92
93   unset rebuild
94 }
95
96 mkdir sub
97
98 cat >>configure.ac <<'EOF'
99 AM_PROG_CC_C_O
100 AC_PROG_F77
101 AC_PROG_FC
102 AC_PROG_LEX
103 AC_PROG_YACC
104 AC_PROG_CXX
105
106 # FIXME: remove this hack once the requirements c++, fortran and fortran77
107 # are implemented correctly.
108 test -n "`echo $CXX`" || AC_MSG_ERROR([C++ compiler not found], [77])
109 test -n "`echo $FC`"  || AC_MSG_ERROR([Fortran compiler not found], [77])
110 test -n "`echo $F77`" || AC_MSG_ERROR([Fortran 77 compiler not found], [77])
111
112 # The SunStudio C++ compiler is unfortunately named 'sunCC' (or even just
113 # 'CC', yuck!); similarly and the Portland group C++ compiler is named
114 # 'pgCC'.  This can cause problems with our grepping checks on the output
115 # from make.  Avoid these problems by invoking a wrapper script, as
116 # filtering the make output proved too fragile.
117 case " $CXX " in
118   *'CC '*)
119     AC_MSG_WARN([the C++ compiler '$CXX' name ends with 'CC'])
120     AC_MSG_WARN([it will be wrapped with the custom script 'am--cxx'])
121     echo '#!/bin/sh' > bin/am--cxx
122     echo 'PATH=$saved_PATH; export PATH' >> bin/am--cxx
123     echo "case \$# in" >> bin/am--cxx
124     echo "  0) exec $CXX ;;" >> bin/am--cxx
125     echo "  *) exec $CXX \"\$@\" ;;" >> bin/am--cxx
126     echo "esac" >> bin/am--cxx
127     chmod a+x bin/am--cxx
128     CXX=am--cxx
129 esac
130
131 AC_CONFIG_FILES([sub/Makefile])
132 AC_OUTPUT
133 EOF
134
135 cat > Makefile.am <<'EOF'
136 # Need generic and non-generic rules.
137 bin_PROGRAMS = foo bar fo2
138 bar_CFLAGS = $(AM_CFLAGS)
139 foo_SOURCES = foo1.cpp foo2.f90 foo3.f foo5.l foo6.y
140 fo2_SOURCES = $(foo_SOURCES)
141 fo2_CPPFLAGS = $(AM_CPPFLAGS)
142 fo2_FFLAGS = $(AM_FFLAGS)
143 fo2_FCFLAGS = $(AM_FCFLAGS)
144 fo2_YFLAGS = -v
145 fo2_LFLAGS = -n
146 SUBDIRS = sub
147 AM_YFLAGS = -d
148 LDADD = $(LEXLIB)
149 BUILT_SOURCES = foo6.h
150 EOF
151
152 cat > sub/Makefile.am <<'EOF'
153 AUTOMAKE_OPTIONS = subdir-objects
154 # Need generic and non-generic rules.
155 bin_PROGRAMS = baz bla ba2
156 bla_CFLAGS = $(AM_CFLAGS)
157 baz_SOURCES = baz1.cpp baz2.f90 baz3.f baz5.l baz6.y
158 ba2_SOURCES = $(baz_SOURCES)
159 ba2_CPPFLAGS = $(AM_CPPFLAGS)
160 ba2_FFLAGS = $(AM_FFLAGS)
161 ba2_FCFLAGS = $(AM_FCFLAGS)
162 ba2_YFLAGS = -v
163 ba2_LFLAGS = -n
164 AM_YFLAGS = -d
165 LDADD = $(LEXLIB)
166 BUILT_SOURCES = baz6.h
167 EOF
168
169 cat > foo1.cpp <<'EOF'
170 int main ()
171 {
172   return 0;
173 }
174 EOF
175 cat > foo2.f90 <<'EOF'
176       subroutine foo2
177       return
178       end
179 EOF
180 cat > foo3.f <<'EOF'
181       subroutine foo3
182       return
183       end
184 EOF
185 cat > foo5.l <<'EOF'
186 %{
187 #define YY_NO_UNISTD_H 1
188 %}
189 %%
190 "END"   return EOF;
191 .
192 %%
193 /* Avoid possible link errors. */
194 int yywrap (void)
195 {
196   return 1;
197 }
198 EOF
199 cat > foo6.y <<'EOF'
200 %{
201 void yyerror (char *s) {}
202 %}
203 %token EOF
204 %%
205 fubar : 'f' 'o' 'o' 'b' 'a' 'r' EOF {};
206 EOF
207 cp foo1.cpp bar.c
208 cp foo1.cpp sub/baz.c
209 cp foo1.cpp sub/bla.c
210 cp foo1.cpp sub/baz1.cpp
211 cp foo2.f90 sub/baz2.f90
212 cp foo3.f sub/baz3.f
213 cp foo5.l sub/baz5.l
214 cp foo6.y sub/baz6.y
215
216 mkdir bin
217 saved_PATH=$PATH; export saved_PATH
218 PATH=$(pwd)/bin$PATH_SEPARATOR$PATH; export PATH
219
220 $ACLOCAL
221 $AUTOMAKE --add-missing
222 $AUTOCONF
223
224 # Ensure per-target rules are used, to ensure their coverage below.
225 # (We do not do an exhaustive check, that wouldn't be practical).
226 $FGREP 'bar-bar.o' Makefile.in
227 $FGREP 'fo2-foo5.c' Makefile.in
228 $FGREP 'fo2-foo6.c' Makefile.in
229
230 # Force dependency tracking explicitly, so that slow dependency
231 # extractors are not rejected.  Try also with dependency tracking
232 # explicitly disabled.
233 for config_args in \
234   --enable-dependency-tracking --disable-dependency-tracking
235 do
236
237   ./configure $config_args --enable-silent-rules
238
239   do_and_check_silent_build
240   # Cleaning and then rebuilding with the same V flag (and without
241   # removing the generated sources in between) shouldn't trigger a
242   # different set of rules.
243   $MAKE clean
244   do_and_check_silent_build --rebuild
245
246   # Ensure a clean rebuild.
247   $MAKE clean
248   # This is required, since these files are not removed by 'make clean'
249   # (as dictated by the GNU Coding Standards).
250   rm -f *foo5.c *foo6.[ch] sub/*baz5.c sub/*baz6.[ch]
251
252   do_and_check_verbose_build
253   # Cleaning and then rebuilding with the same V flag (and without
254   # removing the generated sources in between) shouldn't trigger a
255   # different set of rules.
256   $MAKE clean
257   do_and_check_verbose_build --rebuild
258
259   # Ensure a clean reconfiguration/rebuild.
260   $MAKE clean
261   $MAKE maintainer-clean
262
263 done
264
265 :