summaryrefslogtreecommitdiff
path: root/tests/yacc6.test
blob: 081e5326833043e63e95946ef2a213e18ef50c6e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#! /bin/sh
# Copyright (C) 2001, 2002, 2003, 2004  Free Software Foundation, Inc.
#
# This file is part of GNU Automake.
#
# GNU Automake is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# GNU Automake is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Automake; see the file COPYING.  If not, write to
# the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.

# Test to make sure ylwrap put in right location.
# Report from Tim Van Holder.
# Also make sure depcomp does not needlessly update headers.
# Report from Paolo Bonzini.

required='gcc bison GNUmake'
. ./defs || exit 1

set -e

cat > configure.in << 'END'
AC_INIT([yacc6], [1.0])
AC_CONFIG_AUX_DIR([aux1])
AM_INIT_AUTOMAKE
AC_CONFIG_FILES([Makefile])
AC_PROG_CC
AM_PROG_CC_C_O
AC_PROG_YACC
AC_CONFIG_FILES([sub/Makefile])
AC_OUTPUT
END

cat > Makefile.am << 'END'
SUBDIRS = sub

test-time-unchanged:
	test `ls -1t sub/main.$(OBJEXT) z | sed 1q` = z
test-time-changed:
	test `ls -1t sub/main.$(OBJEXT) z | sed 1q` = sub/main.$(OBJEXT)
END

mkdir aux1 sub

cat > sub/Makefile.am << 'END'
bin_PROGRAMS = foo bar
AM_YFLAGS = -d
foo_SOURCES = foo.y main.c
foo_CPPFLAGS = -DFOO
bar_SOURCES = bar.y main.c
END

cat > sub/foo.y << 'END'
%{
int yylex () {return 0;}
void yyerror (char *s) {}
%}
%token TOKEN
%%
foobar : 'f' 'o' 'o' 'b' 'a' 'r' {};
END

cp sub/foo.y sub/bar.y

cat >sub/main.c <<'EOF'
#ifdef FOO
#  include "foo.h"
#else
#  include "bar.h"
#endif

int
main()
{
  return 0;
}
EOF

$ACLOCAL
$AUTOCONF
$AUTOMAKE -a
test -f aux1/ylwrap
test ! -f ylwrap
test ! -f sub/ylwrap
$FGREP '(top_srcdir)/aux1/ylwrap' sub/Makefile.in
./configure
$MAKE
grep '#.*line.*foo.y' sub/foo.c
grep '#.*line.*bar.y' sub/bar.c

$sleep
: > z
$sleep
touch sub/bar.y
$MAKE
$MAKE test-time-unchanged
$sleep
$PERL -pi -e s/TOKEN/TEKON/g sub/bar.y
$MAKE
$MAKE test-time-changed