doc: update Vala documentation
[automake.git] / t / yacc-d-vpath.sh
blob6423bc72a9f441267de1580087fd924145a7d1f4
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 # This test checks that dependent files are updated before including
18 # in the distribution. 'parse.c' depends on 'parse.y'. The latter is
19 # updated so that 'parse.c' should be rebuilt. Then we are running
20 # 'make' and 'make distdir' and check whether the version of 'parse.c'
21 # to be distributed is up to date.
23 # Please keep this in sync with sister test 'yaccvpath.sh'.
25 required='cc yacc'
26 . test-init.sh
28 cat >> configure.ac << 'END'
29 AC_PROG_CC
30 AC_PROG_YACC
31 AC_OUTPUT
32 END
34 cat > Makefile.am << 'END'
35 AM_LFLAGS = --never-interactive
37 bin_PROGRAMS = foo
38 foo_SOURCES = parse.y foo.c
39 AM_YFLAGS = -d
40 END
42 # Original parser, with 'foobar'.
43 cat > parse.y << 'END'
45 int yylex () { return 0; }
46 void yyerror (const char *s) {}
48 %token FOOBAR
50 foobar : 'f' 'o' 'o' 'b' 'a' 'r' {};
51 END
53 cat > foo.c << 'END'
54 #include "parse.h"
55 int main () { return 0; }
56 END
58 $ACLOCAL
59 $AUTOCONF
60 $AUTOMAKE -a
62 $YACC -d parse.y
63 mv y.tab.c parse.c
64 mv y.tab.h parse.h
65 # Sanity checks.
66 grep foobar parse.c
67 grep FOOBAR parse.h
69 mkdir sub
70 cd sub
71 ../configure
73 $sleep
75 # New parser, with 'fubar'.
76 cat > ../parse.y << 'END'
78 int yylex () { return 0; }
79 void yyerror (const char *s) {}
81 %token FUBAR
83 fubar : 'f' 'u' 'b' 'a' 'r' {};
84 END
86 $MAKE
87 $MAKE distdir
88 $FGREP fubar $distdir/parse.c
89 $FGREP FUBAR $distdir/parse.h
91 # Now check to make sure that 'make dist' will rebuild the parser.
93 $sleep
95 # New parser, with 'maude'.
96 cat > ../parse.y << 'END'
98 int yylex () { return 0; }
99 void yyerror (const char *s) {}
101 %token MAUDE
103 maude : 'm' 'a' 'u' 'd' 'e' {};
106 $MAKE distdir
107 $FGREP maude $distdir/parse.c
108 $FGREP MAUDE $distdir/parse.h