tests: work around strangeness in MSYS
[automake.git] / tests / silent-lex-generic.test
bloba4767c299d9184d6af24ef7d9f47a4d868b9a539
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 Lex.
18 # Keep this in sync with sister test `silent-lex-gcc.test'.
20 required='cc flex'
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_LEX
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.l
37 foo2_SOURCES = $(foo1_SOURCES)
38 foo2_CFLAGS = $(AM_CFLAGS)
39 SUBDIRS = sub
40 LDADD = $(LEXLIB)
41 EOF
43 cat > sub/Makefile.am <<'EOF'
44 AUTOMAKE_OPTIONS = subdir-objects
45 # Need generic and non-generic rules.
46 bin_PROGRAMS = bar1 bar2
47 bar1_SOURCES = bar.l
48 bar2_SOURCES = $(bar1_SOURCES)
49 bar2_CFLAGS = $(AM_CFLAGS)
50 LDADD = $(LEXLIB)
51 EOF
53 cat > foo.l <<'EOF'
55 /* avoid non-ANSI #include of unistd.h */
56 #define YY_NO_UNISTD_H 1
59 "END" return EOF;
62 /* Avoid possible link errors. */
63 int yywrap (void) { return 1; }
64 int main (void) { return 0; }
65 EOF
66 cp foo.l sub/bar.l
68 $ACLOCAL
69 $AUTOMAKE --add-missing
70 $AUTOCONF
72 # Force dependency tracking explicitly, so that slow dependency
73 # extractors are not rejected. Try also with dependency tracking
74 # explicitly disabled.
75 for config_args in \
76 --enable-dependency-tracking --disable-dependency-tracking
78 ./configure $config_args --enable-silent-rules
80 $MAKE >stdout || { cat stdout; Exit 1; }
81 cat stdout
83 $EGREP ' (-c|-o)' stdout && Exit 1
84 $EGREP '(mv|ylwrap) ' stdout && Exit 1
86 grep 'LEX .*foo\.' stdout
87 grep 'LEX .*bar\.' stdout
88 grep ' CC .*foo\.' stdout
89 grep ' CC .*bar\.' stdout
90 grep 'CCLD .*foo1' stdout
91 grep 'CCLD .*bar1' stdout
92 grep 'CCLD .*foo2' stdout
93 grep 'CCLD .*bar2' stdout
95 # Cleaning and then rebuilding with the same V flag (and without
96 # removing the generated sources in between) shouldn't trigger a
97 # different set of rules.
98 $MAKE clean
100 $MAKE >stdout || { cat stdout; Exit 1; }
101 cat stdout
103 $EGREP ' (-c|-o)' stdout && Exit 1
104 $EGREP '(mv|ylwrap) ' stdout && Exit 1
106 # Don't look for LEX, as probably lex hasn't been re-run.
107 grep ' CC .*foo\.' stdout
108 grep ' CC .*bar\.' stdout
109 grep 'CCLD .*foo1' stdout
110 grep 'CCLD .*bar1' stdout
111 grep 'CCLD .*foo2' stdout
112 grep 'CCLD .*bar2' stdout
114 # Ensure a truly clean rebuild.
115 $MAKE clean
116 rm -f foo.c sub/bar.c
118 $MAKE V=1 >stdout || { cat stdout; Exit 1; }
119 cat stdout
121 grep ' -c ' stdout
122 grep ' -o ' stdout
123 grep 'ylwrap ' stdout
125 $EGREP '(LEX|CC|CCLD) ' stdout && Exit 1
127 # Cleaning and then rebuilding with the same V flag (and without
128 # removing the generated sources in between) shouldn't trigger a
129 # different set of rules.
130 $MAKE clean
132 $MAKE V=1 >stdout || { cat stdout; Exit 1; }
133 cat stdout
135 # Don't look for ylwrap, as probably lex hasn't been re-run.
136 grep ' -c ' stdout
137 grep ' -o ' stdout
139 $EGREP '(LEX|CC|CCLD) ' stdout && Exit 1
141 # Ensure a truly clean reconfiguration/rebuild.
142 $MAKE clean
143 $MAKE maintainer-clean
144 rm -f foo.c sub/bar.c
146 done