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