tests: work around strangeness in MSYS
[automake.git] / tests / silent-yacc-generic.test
blob65799113092084af98ed401f7689479d7f40eb1c
1 #!/bin/sh
2 # Copyright (C) 2010, 2011 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 for Yacc.
18 # Keep this in sync with sister test `silent-yacc-gcc.test'.
20 required='cc yacc'
21 . ./defs || Exit 1
23 mkdir sub
25 cat >>configure.in <<'EOF'
26 AM_SILENT_RULES
27 AM_PROG_CC_C_O
28 AC_PROG_YACC
29 AC_CONFIG_FILES([sub/Makefile])
30 AC_OUTPUT
31 EOF
33 cat > Makefile.am <<'EOF'
34 # Need generic and non-generic rules.
35 bin_PROGRAMS = foo1 foo2
36 foo1_SOURCES = foo.y
37 foo2_SOURCES = $(foo1_SOURCES)
38 foo2_CFLAGS = $(AM_CPPFLAGS)
39 SUBDIRS = sub
40 EOF
42 cat > sub/Makefile.am <<'EOF'
43 AUTOMAKE_OPTIONS = subdir-objects
44 # Need generic and non-generic rules.
45 bin_PROGRAMS = bar1 bar2
46 bar1_SOURCES = bar.y
47 bar2_SOURCES = $(bar1_SOURCES)
48 bar2_CFLAGS = $(AM_CPPFLAGS)
49 EOF
51 cat > foo.y <<'EOF'
53 void yyerror (char *s) {}
54 int yylex (void) {return 0;}
55 int main(void) {return 0;}
57 %token EOF
59 fubar : 'f' 'o' 'o' 'b' 'a' 'r' EOF {};
60 EOF
61 cp foo.y sub/bar.y
63 $ACLOCAL
64 $AUTOMAKE --add-missing
65 $AUTOCONF
67 # Force dependency tracking explicitly, so that slow dependency
68 # extractors are not rejected. Try also with dependency tracking
69 # explicitly disabled.
70 for config_args in \
71 --enable-dependency-tracking --disable-dependency-tracking
73 ./configure $config_args --enable-silent-rules
75 $MAKE >stdout || { cat stdout; Exit 1; }
76 cat stdout
78 $EGREP ' (-c|-o)' stdout && Exit 1
79 $EGREP '(mv|ylwrap) ' stdout && Exit 1
81 grep 'YACC .*foo\.' stdout
82 grep 'YACC .*bar\.' stdout
83 grep ' CC .*foo\.' stdout
84 grep ' CC .*bar\.' stdout
85 grep 'CCLD .*foo1' stdout
86 grep 'CCLD .*bar1' stdout
87 grep 'CCLD .*foo2' stdout
88 grep 'CCLD .*bar2' stdout
90 # Cleaning and then rebuilding with the same V flag (and without
91 # removing the generated sources in between) shouldn't trigger a
92 # different set of rules.
93 $MAKE clean
95 $MAKE >stdout || { cat stdout; Exit 1; }
96 cat stdout
98 $EGREP ' (-c|-o)' stdout && Exit 1
99 $EGREP '(mv|ylwrap) ' stdout && Exit 1
101 # Don't look for YACC, as probably yacc hasn't been re-run.
102 grep ' CC .*foo\.' stdout
103 grep ' CC .*bar\.' stdout
104 grep 'CCLD .*foo1' stdout
105 grep 'CCLD .*bar1' stdout
106 grep 'CCLD .*foo2' stdout
107 grep 'CCLD .*bar2' stdout
109 # Ensure a truly clean rebuild.
110 $MAKE clean
111 rm -f foo.[ch] sub/bar.[ch]
113 $MAKE V=1 >stdout || { cat stdout; Exit 1; }
114 cat stdout
116 grep ' -c ' stdout
117 grep ' -o ' stdout
118 grep 'ylwrap ' stdout
120 $EGREP '(YACC|CC|CCLD) ' stdout && Exit 1
122 # Cleaning and then rebuilding with the same V flag (and without
123 # removing the generated sources in between) shouldn't trigger a
124 # different set of rules.
125 $MAKE clean
127 $MAKE V=1 >stdout || { cat stdout; Exit 1; }
128 cat stdout
130 # Don't look for ylwrap, as probably lex hasn't been re-run.
131 grep ' -c ' stdout
132 grep ' -o ' stdout
134 $EGREP '(YACC|CC|CCLD) ' stdout && Exit 1
136 # Ensure a truly clean reconfiguration/rebuild.
137 $MAKE clean
138 $MAKE maintainer-clean
139 rm -f foo.[ch] sub/bar.[ch]
141 done