5f1eaea6aae4df6cf79b2b4fa6d92e5db4d0ceb2
[platform/upstream/automake.git] / tests / yacc8.test
1 #! /bin/sh
2 # Copyright (C) 2002, 2003, 2004  Free Software Foundation, Inc.
3 #
4 # This file is part of GNU Automake.
5 #
6 # GNU Automake is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2, or (at your option)
9 # any later version.
10 #
11 # GNU Automake is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 # GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with Automake; see the file COPYING.  If not, write to
18 # the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 # Boston, MA 02111-1307, USA.
20
21 # Test for subdir parsers.
22
23 required="gcc bison"
24
25 . ./defs || exit 1
26
27 set -e
28
29 cat > configure.in << 'END'
30 AC_INIT([yacc8], [1.0])
31 AC_CONFIG_AUX_DIR([.])
32 AM_INIT_AUTOMAKE
33 AC_CONFIG_FILES([Makefile])
34 AC_PROG_CC
35 AM_PROG_CC_C_O
36 AC_PROG_YACC
37 AC_OUTPUT
38 END
39
40 cat > Makefile.am << 'END'
41 AUTOMAKE_OPTIONS = subdir-objects
42 bin_PROGRAMS = foo/foo
43 foo_foo_SOURCES = foo/parse.y
44 AM_YFLAGS = -d
45
46 obj: foo/parse.$(OBJEXT)
47
48 test1: obj
49         test -f foo/parse.c
50         test -f foo/parse.$(OBJEXT)
51
52 test2: obj
53         test -f foo/parse.c
54         test -f foo/parse.$(OBJEXT)
55 END
56
57 mkdir foo
58
59 cat > foo/parse.y << 'END'
60 %{
61 int yylex () {return 0;}
62 void yyerror (char *s) {}
63 %}
64 %%
65 foobar : 'f' 'o' 'o' 'b' 'a' 'r' {};
66 END
67
68 $ACLOCAL
69 $AUTOCONF
70 $AUTOMAKE -a
71
72 mkdir sub
73 cd sub
74
75 ../configure
76 $MAKE test1
77
78 # Aside of the rest of this test, let's see if we can recover from
79 # parse.h removal
80 test -f foo/parse.h
81 rm -f foo/parse.h
82 $MAKE foo/parse.h
83 test -f foo/parse.h
84
85 # Make sure foo/parse.h is not updated, unless when needed.
86 $sleep
87 : > z
88 $sleep
89 touch ../foo/parse.y
90 $MAKE obj
91 test `ls -1t foo/parse.h z | sed 1q` = z
92 $sleep
93 $PERL -pi -e 's/%%/%token TOKEN\n%%/g' ../foo/parse.y
94 $MAKE obj
95 test `ls -1t foo/parse.h z | sed 1q` = foo/parse.h
96
97 # Now, adds another parser to test ylwrap.
98
99 cd ..
100
101 # Sleep some to make sure timestamp of Makefile.am will change.
102 $sleep
103
104 cp foo/parse.y foo/parse2.y
105 cat >> Makefile.am << 'END'
106 EXTRA_foo_foo_SOURCES = foo/parse2.y
107 END
108
109 $AUTOMAKE -a
110 test -f ./ylwrap || exit 1
111
112 cd sub
113 # Regenerate Makefile (automatic in GNU Make, but not in other Makes)
114 ./config.status
115 $MAKE test2