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