Merge branch 'master' into test-protocols
[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 mkdir sub
24
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
32
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
42
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
52
53 cat > foo.l <<'EOF'
54 %%
55 "END"   return EOF;
56 .
57 %%
58 EOF
59 cp foo.l sub/bar.l
60
61 $ACLOCAL
62 $AUTOMAKE --add-missing
63 $AUTOCONF
64
65 # Force dependency tracking explicitly, so that slow dependency
66 # extractors are not rejected.  Try also with dependency tracking
67 # explicitly disabled.
68 for config_args in \
69   --enable-dependency-tracking --disable-dependency-tracking
70 do
71   ./configure $config_args --enable-silent-rules
72
73   $MAKE >stdout || { cat stdout; Exit 1; }
74   cat stdout
75
76   $EGREP ' (-c|-o)' stdout && Exit 1
77   $EGREP '(mv|ylwrap) ' stdout && Exit 1
78
79   grep 'LEX .*foo\.' stdout
80   grep 'LEX .*bar\.' stdout
81   grep ' CC .*foo\.' stdout
82   grep ' CC .*bar\.' stdout
83   grep 'CCLD .*foo1' stdout
84   grep 'CCLD .*bar1' stdout
85   grep 'CCLD .*foo2' stdout
86   grep 'CCLD .*bar2' stdout
87
88   # Cleaning and then rebuilding with the same V flag (and without
89   # removing the generated sources in between) shouldn't trigger a
90   # different set of rules.
91   $MAKE clean
92
93   $MAKE >stdout || { cat stdout; Exit 1; }
94   cat stdout
95
96   $EGREP ' (-c|-o)' stdout && Exit 1
97   $EGREP '(mv|ylwrap) ' stdout && Exit 1
98
99   # Don't look for LEX, as probably lex hasn't been re-run.
100   grep ' CC .*foo\.' stdout
101   grep ' CC .*bar\.' stdout
102   grep 'CCLD .*foo1' stdout
103   grep 'CCLD .*bar1' stdout
104   grep 'CCLD .*foo2' stdout
105   grep 'CCLD .*bar2' stdout
106
107   # Ensure a truly clean rebuild.
108   $MAKE clean
109   rm -f foo.c sub/bar.c
110
111   $MAKE V=1 >stdout || { cat stdout; Exit 1; }
112   cat stdout
113
114   grep ' -c ' stdout
115   grep ' -o ' stdout
116   grep 'ylwrap ' stdout
117
118   $EGREP '(LEX|CC|CCLD) ' stdout && Exit 1
119
120   # Cleaning and then rebuilding with the same V flag (and without
121   # removing the generated sources in between) shouldn't trigger a
122   # different set of rules.
123   $MAKE clean
124
125   $MAKE V=1 >stdout || { cat stdout; Exit 1; }
126   cat stdout
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   # Ensure a truly clean reconfiguration/rebuild.
135   $MAKE clean
136   $MAKE maintainer-clean
137   rm -f foo.c sub/bar.c
138
139 done
140
141 :