automake: require ABOUT-NLS only at gnits strictness.
[automake.git] / t / silent-yacc.sh
blobf5dce73858fd0f39cf46cdaca52f3183b288e90f
1 #!/bin/sh
2 # Copyright (C) 2010-2024 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 Yacc.
19 required='cc yacc'
20 . test-init.sh
22 mkdir sub
24 cat >>configure.ac <<'EOF'
25 AC_PROG_CC
26 AC_PROG_YACC
27 AC_CONFIG_FILES([sub/Makefile])
28 AC_OUTPUT
29 EOF
31 cat > Makefile.am <<'EOF'
32 AM_LFLAGS = --never-interactive
34 # Need generic and non-generic rules.
35 bin_PROGRAMS = foo1 foo2
36 foo1_SOURCES = foo.y
37 foo2_SOURCES = $(foo1_SOURCES)
38 foo2_YFLAGS = -v
39 foo2_CFLAGS = $(AM_CPPFLAGS)
40 SUBDIRS = sub
41 EOF
43 cat > sub/Makefile.am <<'EOF'
44 AUTOMAKE_OPTIONS = subdir-objects
45 AM_LFLAGS = --never-interactive
47 # Need generic and non-generic rules.
48 bin_PROGRAMS = bar1 bar2
49 bar1_SOURCES = bar.y
50 bar2_SOURCES = $(bar1_SOURCES)
51 bar2_YFLAGS = -v
52 bar2_CFLAGS = $(AM_CPPFLAGS)
53 EOF
55 cat > foo.y <<'EOF'
57 void yyerror (const char *s) {}
58 int yylex (void) { return 0; }
59 int main (void) { return 0; }
61 %token EOF
63 fubar : 'f' 'o' 'o' 'b' 'a' 'r' EOF {};
64 EOF
65 cp foo.y sub/bar.y
67 $ACLOCAL
68 $AUTOMAKE --add-missing
69 $AUTOCONF
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
75 ./configure --enable-silent-rules
77 run_make -O
79 $EGREP ' (-c|-o)' stdout && exit 1
80 $EGREP '(mv|ylwrap) ' stdout && exit 1
82 grep 'YACC .*foo\.' stdout
83 grep 'YACC .*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
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
96 run_make -O
98 $EGREP ' (-c|-o)' stdout && exit 1
99 $EGREP '(mv|ylwrap) ' stdout && exit 1
101 # Don't look for YACC, as probably yacc 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
109 # Ensure a truly clean rebuild.
110 $MAKE clean
111 rm -f *foo.[ch] sub/*bar.[ch]
113 run_make -O V=1
115 grep ' -c ' stdout
116 grep ' -o ' stdout
117 grep 'ylwrap ' stdout
119 $EGREP '(YACC|CC|CCLD) ' stdout && exit 1
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
126 run_make -O V=1
128 # Don't look for ylwrap, as probably lex hasn't been re-run.
129 grep ' -c ' stdout
130 grep ' -o ' stdout
132 $EGREP '(YACC|CC|CCLD) ' stdout && exit 1