maint: Update HACKING
[automake.git] / t / silent-lex.sh
blob14ec086be449c017eb3e6981b17bde106be1ae0c
1 #!/bin/sh
2 # Copyright (C) 2010-2017 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 <https://www.gnu.org/licenses/>.
17 # Check silent-rules mode for Lex.
19 required='cc lex'
20 . test-init.sh
22 mkdir sub
24 cat >>configure.ac <<'EOF'
25 AC_PROG_LEX
26 AC_CONFIG_FILES([sub/Makefile])
27 AC_OUTPUT
28 EOF
30 cat > Makefile.am <<'EOF'
31 # Need generic and non-generic rules.
32 bin_PROGRAMS = foo1 foo2
33 foo1_SOURCES = foo.l
34 foo2_SOURCES = $(foo1_SOURCES)
35 foo2_LFLAGS = -n
36 foo2_CFLAGS = $(AM_CFLAGS)
37 SUBDIRS = sub
38 LDADD = $(LEXLIB)
39 EOF
41 cat > sub/Makefile.am <<'EOF'
42 AUTOMAKE_OPTIONS = subdir-objects
43 # Need generic and non-generic rules.
44 bin_PROGRAMS = bar1 bar2
45 bar1_SOURCES = bar.l
46 bar2_SOURCES = $(bar1_SOURCES)
47 bar2_LFLAGS = -n
48 bar2_CFLAGS = $(AM_CFLAGS)
49 LDADD = $(LEXLIB)
50 EOF
52 cat > foo.l <<'EOF'
54 #define YY_NO_UNISTD_H 1
57 "END" return EOF;
60 /* Avoid possible link errors. */
61 int yywrap (void) { return 1; }
62 int main (void) { return 0; }
63 EOF
64 cp foo.l sub/bar.l
66 $ACLOCAL
67 $AUTOMAKE --add-missing
68 $AUTOCONF
70 # Ensure per-target rules are used, to ensure their coverage below.
71 $FGREP 'foo2-foo.c' Makefile.in || exit 99
72 $FGREP 'bar2-bar.c' sub/Makefile.in || exit 99
74 ./configure --enable-silent-rules
76 run_make -O
78 $EGREP ' (-c|-o)' stdout && exit 1
79 $EGREP '(mv|ylwrap) ' stdout && exit 1
81 grep 'LEX .*foo\.' stdout
82 grep 'LEX .*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 run_make -O
97 $EGREP ' (-c|-o)' stdout && exit 1
98 $EGREP '(mv|ylwrap) ' stdout && exit 1
100 # Don't look for LEX, as probably lex hasn't been re-run.
101 grep ' CC .*foo\.' stdout
102 grep ' CC .*bar\.' stdout
103 grep 'CCLD .*foo1' stdout
104 grep 'CCLD .*bar1' stdout
105 grep 'CCLD .*foo2' stdout
106 grep 'CCLD .*bar2' stdout
108 # Ensure a truly clean rebuild.
109 $MAKE clean
110 rm -f *foo.c sub/*bar.c
112 run_make -O V=1
114 grep ' -c ' stdout
115 grep ' -o ' stdout
116 grep 'ylwrap ' stdout
118 $EGREP '(LEX|CC|CCLD) ' stdout && exit 1
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
125 run_make -O V=1
127 # Don't look for ylwrap, as probably lex hasn't been re-run.
128 grep ' -c ' stdout
129 grep ' -o ' stdout
131 $EGREP '(LEX|CC|CCLD) ' stdout && exit 1