tests: work around strangeness in MSYS
[automake.git] / tests / yacc6.test
blob8992e95d419655aad73251d6065d3984b5648c56
1 #! /bin/sh
2 # Copyright (C) 2001, 2002, 2003, 2004, 2006, 2007, 2010, 2011 Free
3 # Software Foundation, Inc.
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.
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.
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/>.
18 # Test to make sure ylwrap put in right location.
19 # Report from Tim Van Holder.
20 # Also make sure depcomp does not needlessly update headers.
21 # Report from Paolo Bonzini.
23 required='gcc yacc GNUmake'
24 . ./defs || Exit 1
26 cat > configure.in << 'END'
27 AC_INIT([yacc6], [1.0])
28 # `aux' is not an acceptable file/directory name on Windows systems.
29 AC_CONFIG_AUX_DIR([aux1])
30 AM_INIT_AUTOMAKE
31 AC_CONFIG_FILES([Makefile sub/Makefile])
32 AC_PROG_CC
33 AM_PROG_CC_C_O
34 AC_PROG_YACC
35 AC_OUTPUT
36 END
38 cat > Makefile.am << 'END'
39 SUBDIRS = sub
41 test-time-unchanged:
42 test `ls -1t sub/main.$(OBJEXT) z | sed 1q` = z
43 test-time-changed:
44 test `ls -1t sub/main.$(OBJEXT) z | sed 1q` = sub/main.$(OBJEXT)
45 END
47 mkdir aux1 sub
49 cat > sub/Makefile.am << 'END'
50 bin_PROGRAMS = foo bar
51 AM_YFLAGS = -d
52 foo_SOURCES = foo.y main.c
53 foo_CPPFLAGS = -DFOO
54 bar_SOURCES = bar.y main.c
55 BUILT_SOURCES = foo.h bar.h
56 END
58 cat > sub/foo.y << 'END'
60 int yylex () {return 0;}
61 void yyerror (char *s) {}
63 %token TOKEN
65 foobar : 'f' 'o' 'o' 'b' 'a' 'r' {};
66 END
68 cp sub/foo.y sub/bar.y
70 cat >sub/main.c <<'EOF'
71 #ifdef FOO
72 # include "foo.h"
73 #else
74 # include "bar.h"
75 #endif
77 int
78 main()
80 return 0;
82 EOF
84 $ACLOCAL
85 $AUTOCONF
86 $AUTOMAKE -a
87 test -f aux1/ylwrap
88 test ! -f ylwrap
89 test ! -f sub/ylwrap
90 $FGREP '$(top_srcdir)/aux1/ylwrap' sub/Makefile.in
91 ./configure
92 $MAKE
93 grep '#.*line.*foo\.y' sub/foo.c
94 grep '#.*line.*bar\.y' sub/bar.c
96 $sleep
97 : > z
98 $sleep
99 touch sub/bar.y
100 $MAKE
101 $MAKE test-time-unchanged
102 $sleep
103 sed s/TOKEN/TEKON/g sub/bar.y >sub/bar.yt
104 mv -f sub/bar.yt sub/bar.y
105 $MAKE
106 $MAKE test-time-changed