Merge branch 'msvc' into maint
[platform/upstream/automake.git] / tests / yacc8.test
1 #! /bin/sh
2 # Copyright (C) 2002, 2003, 2004, 2006  Free Software Foundation, Inc.
3 #
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.
8 #
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.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
16
17 # Test for subdir parsers.
18
19 required="gcc bison"
20
21 . ./defs || Exit 1
22
23 set -e
24
25 cat > configure.in << 'END'
26 AC_INIT([yacc8], [1.0])
27 AC_CONFIG_AUX_DIR([.])
28 AM_INIT_AUTOMAKE
29 AC_CONFIG_FILES([Makefile])
30 AC_PROG_CC
31 AM_PROG_CC_C_O
32 AC_PROG_YACC
33 AC_OUTPUT
34 END
35
36 cat > Makefile.am << 'END'
37 AUTOMAKE_OPTIONS = subdir-objects
38 bin_PROGRAMS = foo/foo
39 foo_foo_SOURCES = foo/parse.y
40 AM_YFLAGS = -d
41
42 obj: foo/parse.$(OBJEXT)
43
44 test1: obj
45         test -f foo/parse.c
46         test -f foo/parse.$(OBJEXT)
47
48 test2: obj
49         test -f foo/parse.c
50         test -f foo/parse.$(OBJEXT)
51 END
52
53 mkdir foo
54
55 cat > foo/parse.y << 'END'
56 %{
57 int yylex () {return 0;}
58 void yyerror (char *s) {}
59 %}
60 %%
61 foobar : 'f' 'o' 'o' 'b' 'a' 'r' {};
62 END
63
64 $ACLOCAL
65 $AUTOCONF
66 $AUTOMAKE -a
67
68 mkdir sub
69 cd sub
70
71 ../configure
72 $MAKE test1
73
74 # Aside of the rest of this test, let's see if we can recover from
75 # parse.h removal
76 test -f foo/parse.h
77 rm -f foo/parse.h
78 $MAKE foo/parse.h
79 test -f foo/parse.h
80
81 # Make sure foo/parse.h is not updated, unless when needed.
82 $sleep
83 : > z
84 $sleep
85 touch ../foo/parse.y
86 $MAKE obj
87 test `ls -1t foo/parse.h z | sed 1q` = z
88 $sleep
89 sed 's/%%/%token TOKEN\n%%/g' ../foo/parse.y >../foo/parse.yt
90 mv -f ../foo/parse.yt ../foo/parse.y
91 $MAKE obj
92 test `ls -1t foo/parse.h z | sed 1q` = foo/parse.h
93
94 # Now, adds another parser to test ylwrap.
95
96 cd ..
97
98 # Sleep some to make sure timestamp of Makefile.am will change.
99 $sleep
100
101 cp foo/parse.y foo/parse2.y
102 cat >> Makefile.am << 'END'
103 EXTRA_foo_foo_SOURCES = foo/parse2.y
104 END
105
106 $AUTOMAKE -a
107 test -f ./ylwrap || Exit 1
108
109 cd sub
110 # Regenerate Makefile (automatic in GNU Make, but not in other Makes)
111 ./config.status
112 $MAKE test2