Merge branch 'minor'
[automake.git] / t / yacc-d-vpath.sh
blobda679b4138797a764aee71240cd8efef286f00cf
1 #! /bin/sh
2 # Copyright (C) 2011-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 # 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 bin_PROGRAMS = foo
36 foo_SOURCES = parse.y foo.c
37 AM_YFLAGS = -d
38 END
40 # Original parser, with 'foobar'.
41 cat > parse.y << 'END'
43 int yylex () { return 0; }
44 void yyerror (char *s) {}
46 %token FOOBAR
48 foobar : 'f' 'o' 'o' 'b' 'a' 'r' {};
49 END
51 cat > foo.c << 'END'
52 #include "parse.h"
53 int main () { return 0; }
54 END
56 $ACLOCAL
57 $AUTOCONF
58 $AUTOMAKE -a
60 $YACC -d parse.y
61 mv y.tab.c parse.c
62 mv y.tab.h parse.h
63 # Sanity checks.
64 grep foobar parse.c
65 grep FOOBAR parse.h
67 mkdir sub
68 cd sub
69 ../configure
71 $sleep
73 # New parser, with 'fubar'.
74 cat > ../parse.y << 'END'
76 int yylex () { return 0; }
77 void yyerror (char *s) {}
79 %token FUBAR
81 fubar : 'f' 'u' 'b' 'a' 'r' {};
82 END
84 $MAKE
85 $MAKE distdir
86 $FGREP fubar $distdir/parse.c
87 $FGREP FUBAR $distdir/parse.h
89 # Now check to make sure that 'make dist' will rebuild the parser.
91 $sleep
93 # New parser, with 'maude'.
94 cat > ../parse.y << 'END'
96 int yylex () { return 0; }
97 void yyerror (char *s) {}
99 %token MAUDE
101 maude : 'm' 'a' 'u' 'd' 'e' {};
104 $MAKE distdir
105 $FGREP maude $distdir/parse.c
106 $FGREP MAUDE $distdir/parse.h