tests: Let 'ltorder.sh' run successfully with Guix dynamic loader
[automake.git] / t / silent-yacc.sh
blobfafe0706be086bdcb79020be5514f62325f0a1ca
1 #!/bin/sh
2 # Copyright (C) 2010-2018 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 # Need generic and non-generic rules.
33 bin_PROGRAMS = foo1 foo2
34 foo1_SOURCES = foo.y
35 foo2_SOURCES = $(foo1_SOURCES)
36 foo2_YFLAGS = -v
37 foo2_CFLAGS = $(AM_CPPFLAGS)
38 SUBDIRS = sub
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.y
46 bar2_SOURCES = $(bar1_SOURCES)
47 bar2_YFLAGS = -v
48 bar2_CFLAGS = $(AM_CPPFLAGS)
49 EOF
51 cat > foo.y <<'EOF'
53 void yyerror (char *s) { return; }
54 int yylex (void) { return 0; }
55 int main (void) { return 0; }
57 %token EOF
59 fubar : 'f' 'o' 'o' 'b' 'a' 'r' EOF {};
60 EOF
61 cp foo.y sub/bar.y
63 $ACLOCAL
64 $AUTOMAKE --add-missing
65 $AUTOCONF
67 # Ensure per-target rules are used, to ensure their coverage below.
68 $FGREP 'foo2-foo.c' Makefile.in || exit 99
69 $FGREP 'bar2-bar.c' sub/Makefile.in || exit 99
71 ./configure --enable-silent-rules
73 run_make -O
75 $EGREP ' (-c|-o)' stdout && exit 1
76 $EGREP '(mv|ylwrap) ' stdout && exit 1
78 grep 'YACC .*foo\.' stdout
79 grep 'YACC .*bar\.' stdout
80 grep ' CC .*foo\.' stdout
81 grep ' CC .*bar\.' stdout
82 grep 'CCLD .*foo1' stdout
83 grep 'CCLD .*bar1' stdout
84 grep 'CCLD .*foo2' stdout
85 grep 'CCLD .*bar2' stdout
87 # Cleaning and then rebuilding with the same V flag (and without
88 # removing the generated sources in between) shouldn't trigger a
89 # different set of rules.
90 $MAKE clean
92 run_make -O
94 $EGREP ' (-c|-o)' stdout && exit 1
95 $EGREP '(mv|ylwrap) ' stdout && exit 1
97 # Don't look for YACC, as probably yacc hasn't been re-run.
98 grep ' CC .*foo\.' stdout
99 grep ' CC .*bar\.' stdout
100 grep 'CCLD .*foo1' stdout
101 grep 'CCLD .*bar1' stdout
102 grep 'CCLD .*foo2' stdout
103 grep 'CCLD .*bar2' stdout
105 # Ensure a truly clean rebuild.
106 $MAKE clean
107 rm -f *foo.[ch] sub/*bar.[ch]
109 run_make -O V=1
111 grep ' -c ' stdout
112 grep ' -o ' stdout
113 grep 'ylwrap ' stdout
115 $EGREP '(YACC|CC|CCLD) ' stdout && exit 1
117 # Cleaning and then rebuilding with the same V flag (and without
118 # removing the generated sources in between) shouldn't trigger a
119 # different set of rules.
120 $MAKE clean
122 run_make -O V=1
124 # Don't look for ylwrap, as probably lex hasn't been re-run.
125 grep ' -c ' stdout
126 grep ' -o ' stdout
128 $EGREP '(YACC|CC|CCLD) ' stdout && exit 1