doc: update Vala documentation
[automake.git] / t / yacc-clean.sh
blob106591ca27ed75f039c5e428f9aa50b32d5cdcea
1 #! /bin/sh
2 # Copyright (C) 2011-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 that .c and .h files derived from non-distributed .y sources
18 # are cleaned by "make clean", while .c and .h files derived from
19 # distributed .y sources are cleaned by "make maintainer-clean".
20 # See also sister test 'yacc-cxx-clean.sh'.
22 required='cc yacc'
23 . test-init.sh
25 cat >> configure.ac << 'END'
26 AC_PROG_CC
27 AC_PROG_YACC
28 AC_CONFIG_FILES([sub1/Makefile sub2/Makefile])
29 AC_OUTPUT
30 END
32 cat > Makefile.am << 'END'
33 # Use two subdirectories, one to test with '-d' in YFLAGS, the
34 # other one to test with empty YFLAGS.
35 SUBDIRS = sub1 sub2
36 END
38 mkdir sub1 sub2
40 cat > sub1/Makefile.am << 'END'
41 AM_LFLAGS = --never-interactive
43 bin_PROGRAMS = foo bar baz qux
45 foo_SOURCES = main.c parse.y
47 bar_SOURCES = main.c parse.y
48 bar_YFLAGS = $(AM_YFLAGS)
50 baz_SOURCES = main.c
51 nodist_baz_SOURCES = baz.y
53 qux_SOURCES = main.c
54 nodist_qux_SOURCES = baz.y
55 qux_YFLAGS = $(AM_YFLAGS)
57 baz.y:
58 cp $(srcdir)/parse.y $@
60 CLEANFILES = baz.y
61 END
63 cat > sub2/Makefile.am << 'END'
64 include $(top_srcdir)/sub1/Makefile.am
65 AM_YFLAGS = -d
66 END
68 cat > sub1/parse.y << 'END'
70 #include <stdio.h>
72 int yylex () { return (getchar ()); }
73 void yyerror (const char *s) {}
76 x : 'x' { };
77 END
78 cp sub1/parse.y sub2/parse.y
80 cat > sub1/main.c << 'END'
81 extern int yyparse(void);
83 int main ()
85 return yyparse ();
87 END
88 cp sub1/main.c sub2/main.c
90 $ACLOCAL
91 $AUTOCONF
92 $AUTOMAKE -a
94 ./configure
96 cp config.status config.sav
98 $MAKE
99 ls -l . sub1 sub2
100 # Sanity checks.
101 test -f sub1/parse.y
102 test -f sub1/parse.c
103 test -f sub1/bar-parse.c
104 test -f sub1/baz.y
105 test -f sub1/baz.c
106 test -f sub1/qux-baz.c
107 test -f sub2/parse.y
108 test -f sub2/parse.c
109 test -f sub2/parse.h
110 test -f sub2/bar-parse.c
111 test -f sub2/bar-parse.h
112 test -f sub2/baz.y
113 test -f sub2/baz.c
114 test -f sub2/baz.h
115 test -f sub2/qux-baz.c
116 test -f sub2/qux-baz.h
118 for target in clean distclean; do
119 $MAKE $target
120 ls -l . sub1 sub2
121 test -f sub1/parse.y
122 test -f sub1/parse.c
123 test -f sub1/bar-parse.c
124 test ! -e sub1/baz.y
125 test ! -e sub1/baz.c
126 test ! -e sub1/qux-baz.c
127 test -f sub2/parse.y
128 test -f sub2/parse.c
129 test -f sub2/parse.h
130 test -f sub2/bar-parse.c
131 test -f sub2/bar-parse.h
132 test ! -e sub2/baz.y
133 test ! -e sub2/baz.c
134 test ! -e sub2/baz.h
135 test ! -e sub2/qux-baz.c
136 test ! -e sub2/qux-baz.h
137 done
139 cp config.sav config.status
140 ./config.status # Re-create 'Makefile'.
142 $MAKE maintainer-clean
143 ls -l . sub1 sub2
144 test -f sub1/parse.y
145 test ! -e sub1/parse.c
146 test ! -e sub1/bar-parse.c
147 test -f sub2/parse.y
148 test ! -e sub2/parse.c
149 test ! -e sub2/parse.h
150 test ! -e sub2/bar-parse.c
151 test ! -e sub2/bar-parse.h