Merge branch 'yacc-work' into yl-work-for-master
[platform/upstream/automake.git] / tests / yaccvpath.test
1 #! /bin/sh
2 # Copyright (C) 2001, 2002, 2003, 2010, 2011, 2012 Free Software
3 # Foundation, Inc.
4 #
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2, or (at your option)
8 # any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
18 # This test checks that dependent files are updated before including
19 # in the distribution. `parse.c' depends on `parse.y'. The later is
20 # updated so that `parse.c' should be rebuild. Then we are running
21 # `make' and `make distdir' and check whether the version of `parse.c'
22 # to be distributed is up to date.
23
24 # Please keep this in sync with sister test `yacc-d-vpath.test'.
25
26 required='cc yacc'
27 . ./defs || Exit 1
28
29 cat >> configure.in << 'END'
30 AC_PROG_CC
31 AC_PROG_YACC
32 AC_OUTPUT
33 END
34
35 cat > Makefile.am << 'END'
36 bin_PROGRAMS = foo
37 foo_SOURCES = parse.y foo.c
38 END
39
40 # Original parser, with `foobar'.
41 cat > parse.y << 'END'
42 %{
43 int yylex () { return 0; }
44 void yyerror (char *s) {}
45 %}
46 %%
47 foobar : 'f' 'o' 'o' 'b' 'a' 'r' {};
48 END
49
50 cat > foo.c << 'END'
51 int main () { return 0; }
52 END
53
54 $ACLOCAL
55 $AUTOCONF
56 $AUTOMAKE -a
57
58 $YACC parse.y
59 mv y.tab.c parse.c
60
61 mkdir sub
62 cd sub
63 ../configure
64
65 $sleep
66
67 # New parser, with `fubar'.
68 cat > ../parse.y << 'END'
69 %{
70 int yylex () { return 0; }
71 void yyerror (char *s) {}
72 %}
73 %%
74 fubar : 'f' 'o' 'o' 'b' 'a' 'r' {};
75 END
76
77 $MAKE
78 $MAKE distdir
79 $FGREP fubar $distdir/parse.c
80
81 # Now check to make sure that `make dist' will rebuild the parser.
82
83 $sleep
84
85 # New parser, with `maude'.
86 cat > ../parse.y << 'END'
87 %{
88 int yylex () { return 0; }
89 void yyerror (char *s) {}
90 %}
91 %%
92 maude : 'm' 'a' 'u' 'd' 'e' {};
93 END
94
95 $MAKE distdir
96 $FGREP maude $distdir/parse.c
97
98 :