tests: avoid a spurious failure on MSYS
[platform/upstream/automake.git] / t / silent-lex.sh
1 #!/bin/sh
2 # Copyright (C) 2010-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 for Lex.
18
19 required='cc lex'
20 . test-init.sh
21
22 mkdir sub
23
24 cat >>configure.ac <<'EOF'
25 AM_PROG_CC_C_O
26 AC_PROG_LEX
27 AC_CONFIG_FILES([sub/Makefile])
28 AC_OUTPUT
29 EOF
30
31 cat > Makefile.am <<'EOF'
32 # Need generic and non-generic rules.
33 bin_PROGRAMS = foo1 foo2
34 foo1_SOURCES = foo.l
35 foo2_SOURCES = $(foo1_SOURCES)
36 foo2_LFLAGS = -n
37 foo2_CFLAGS = $(AM_CFLAGS)
38 SUBDIRS = sub
39 LDADD = $(LEXLIB)
40 EOF
41
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.l
47 bar2_SOURCES = $(bar1_SOURCES)
48 bar2_LFLAGS = -n
49 bar2_CFLAGS = $(AM_CFLAGS)
50 LDADD = $(LEXLIB)
51 EOF
52
53 cat > foo.l <<'EOF'
54 %{
55 #define YY_NO_UNISTD_H 1
56 %}
57 %%
58 "END"   return EOF;
59 .
60 %%
61 /* Avoid possible link errors. */
62 int yywrap (void) { return 1; }
63 int   main (void) { return 0; }
64 EOF
65 cp foo.l sub/bar.l
66
67 $ACLOCAL
68 $AUTOMAKE --add-missing
69 $AUTOCONF
70
71 # Ensure per-target rules are used, to ensure their coverage below.
72 $FGREP 'foo2-foo.c' Makefile.in || exit 99
73 $FGREP 'bar2-bar.c' sub/Makefile.in || exit 99
74
75 ./configure --enable-silent-rules
76
77 run_make -O
78
79 $EGREP ' (-c|-o)' stdout && exit 1
80 $EGREP '(mv|ylwrap) ' stdout && exit 1
81
82 grep 'LEX .*foo\.' stdout
83 grep 'LEX .*bar\.' stdout
84 grep ' CC .*foo\.' stdout
85 grep ' CC .*bar\.' stdout
86 grep 'CCLD .*foo1' stdout
87 grep 'CCLD .*bar1' stdout
88 grep 'CCLD .*foo2' stdout
89 grep 'CCLD .*bar2' stdout
90
91 # Cleaning and then rebuilding with the same V flag (and without
92 # removing the generated sources in between) shouldn't trigger a
93 # different set of rules.
94 $MAKE clean
95
96 run_make -O
97
98 $EGREP ' (-c|-o)' stdout && exit 1
99 $EGREP '(mv|ylwrap) ' stdout && exit 1
100
101 # Don't look for LEX, as probably lex 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
108
109 # Ensure a truly clean rebuild.
110 $MAKE clean
111 rm -f *foo.c sub/*bar.c
112
113 run_make -O V=1
114
115 grep ' -c ' stdout
116 grep ' -o ' stdout
117 grep 'ylwrap ' stdout
118
119 $EGREP '(LEX|CC|CCLD) ' stdout && exit 1
120
121 # Cleaning and then rebuilding with the same V flag (and without
122 # removing the generated sources in between) shouldn't trigger a
123 # different set of rules.
124 $MAKE clean
125
126 run_make -O V=1
127
128 # Don't look for ylwrap, as probably lex hasn't been re-run.
129 grep ' -c ' stdout
130 grep ' -o ' stdout
131
132 $EGREP '(LEX|CC|CCLD) ' stdout && exit 1
133
134 :