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