Merge branch 'msvc' into maint
[platform/upstream/automake.git] / tests / silent-lex-generic.test
1 #!/bin/sh
2 # Copyright (C) 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 for Lex.
18 # Keep this in sync with sister test `silent-lex-gcc.test'.
19
20 required='flex'
21 . ./defs || Exit 1
22
23 set -e
24
25 mkdir sub
26
27 cat >>configure.in <<'EOF'
28 AM_SILENT_RULES
29 AM_PROG_CC_C_O
30 AC_PROG_LEX
31 AC_CONFIG_FILES([sub/Makefile])
32 AC_OUTPUT
33 EOF
34
35 cat > Makefile.am <<'EOF'
36 # Need generic and non-generic rules.
37 bin_PROGRAMS = foo1 foo2
38 foo1_SOURCES = foo.l
39 foo2_SOURCES = $(foo1_SOURCES)
40 foo2_CFLAGS = $(AM_CFLAGS)
41 SUBDIRS = sub
42 LDADD = $(LEXLIB)
43 EOF
44
45 cat > sub/Makefile.am <<'EOF'
46 AUTOMAKE_OPTIONS = subdir-objects
47 # Need generic and non-generic rules.
48 bin_PROGRAMS = bar1 bar2
49 bar1_SOURCES = bar.l
50 bar2_SOURCES = $(bar1_SOURCES)
51 bar2_CFLAGS = $(AM_CFLAGS)
52 LDADD = $(LEXLIB)
53 EOF
54
55 cat > foo.l <<'EOF'
56 %{
57 /* avoid non-ANSI #include of unistd.h */
58 #define YY_NO_UNISTD_H 1
59 %}
60 %%
61 "END"   return EOF;
62 .
63 %%
64 /* Avoid possible link errors. */
65 int yywrap (void) { return 1; }
66 int   main (void) { return 0; }
67 EOF
68 cp foo.l sub/bar.l
69
70 $ACLOCAL
71 $AUTOMAKE --add-missing
72 $AUTOCONF
73
74 # Force dependency tracking explicitly, so that slow dependency
75 # extractors are not rejected.  Try also with dependency tracking
76 # explicitly disabled.
77 for config_args in \
78   --enable-dependency-tracking --disable-dependency-tracking
79 do
80   ./configure $config_args --enable-silent-rules
81
82   $MAKE >stdout || { cat stdout; Exit 1; }
83   cat stdout
84
85   $EGREP ' (-c|-o)' stdout && Exit 1
86   $EGREP '(mv|ylwrap) ' stdout && Exit 1
87
88   grep 'LEX .*foo\.' stdout
89   grep 'LEX .*bar\.' stdout
90   grep ' CC .*foo\.' stdout
91   grep ' CC .*bar\.' stdout
92   grep 'CCLD .*foo1' stdout
93   grep 'CCLD .*bar1' stdout
94   grep 'CCLD .*foo2' stdout
95   grep 'CCLD .*bar2' stdout
96
97   # Cleaning and then rebuilding with the same V flag (and without
98   # removing the generated sources in between) shouldn't trigger a
99   # different set of rules.
100   $MAKE clean
101
102   $MAKE >stdout || { cat stdout; Exit 1; }
103   cat stdout
104
105   $EGREP ' (-c|-o)' stdout && Exit 1
106   $EGREP '(mv|ylwrap) ' stdout && Exit 1
107
108   # Don't look for LEX, as probably lex hasn't been re-run.
109   grep ' CC .*foo\.' stdout
110   grep ' CC .*bar\.' stdout
111   grep 'CCLD .*foo1' stdout
112   grep 'CCLD .*bar1' stdout
113   grep 'CCLD .*foo2' stdout
114   grep 'CCLD .*bar2' stdout
115
116   # Ensure a truly clean rebuild.
117   $MAKE clean
118   rm -f foo.c sub/bar.c
119
120   $MAKE V=1 >stdout || { cat stdout; Exit 1; }
121   cat stdout
122
123   grep ' -c ' stdout
124   grep ' -o ' stdout
125   grep 'ylwrap ' stdout
126
127   $EGREP '(LEX|CC|CCLD) ' stdout && Exit 1
128
129   # Cleaning and then rebuilding with the same V flag (and without
130   # removing the generated sources in between) shouldn't trigger a
131   # different set of rules.
132   $MAKE clean
133
134   $MAKE V=1 >stdout || { cat stdout; Exit 1; }
135   cat stdout
136
137   # Don't look for ylwrap, as probably lex hasn't been re-run.
138   grep ' -c ' stdout
139   grep ' -o ' stdout
140
141   $EGREP '(LEX|CC|CCLD) ' stdout && Exit 1
142
143   # Ensure a truly clean reconfiguration/rebuild.
144   $MAKE clean
145   $MAKE maintainer-clean
146   rm -f foo.c sub/bar.c
147
148 done
149
150 :