Merge branch 'fix-pr13588-pax-hangs' into branch-1.13.2
[automake.git] / t / yacc-line.sh
blobed30c56b3239f21991e73cce53f1537ae6cebf48
1 #! /bin/sh
2 # Copyright (C) 2001-2013 Free Software Foundation, Inc.
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.
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.
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/>.
17 # Check that automake yacc support ensures that yacc-generated C
18 # files use correct "#line" directives. Try also with the
19 # 'subdir-object' option enabled.
20 # See also sister test 'lex-line.sh'.
22 required='cc yacc'
23 . test-init.sh
25 cat >> configure.ac << 'END'
26 AC_CONFIG_FILES([sub/Makefile])
27 AC_PROG_CC
28 AM_PROG_CC_C_O
29 AC_PROG_YACC
30 AC_OUTPUT
31 END
33 mkdir dir sub sub/dir
35 cat > Makefile.am << 'END'
36 SUBDIRS = sub
37 bin_PROGRAMS = foo bar
38 AM_YFLAGS = -d
39 bar_YFLAGS =
40 foo_SOURCES = zardoz.y
41 bar_SOURCES = dir/quux.y
42 ## Avoid spurious failures with Solaris make.
43 zardoz.@OBJEXT@: zardoz.c
44 bar-quux.@OBJEXT@: bar-quux.c
45 END
47 cat > sub/Makefile.am << 'END'
48 AUTOMAKE_OPTIONS = subdir-objects
49 noinst_PROGRAMS = foo bar
50 foo_YFLAGS = -d
51 foo_SOURCES = zardoz.y
52 bar_SOURCES = dir/quux.y
53 ## Avoid spurious failures with Solaris make.
54 foo-zardoz.@OBJEXT@: foo-zardoz.c
55 dir/quux.@OBJEXT@: dir/quux.c
56 END
58 cat > zardoz.y << 'END'
60 int yylex () { return 0; }
61 void yyerror (char *s) { return; }
64 x : 'x' {};
66 int main(void)
68 return yyparse ();
70 END
72 cp zardoz.y dir/quux.y
73 cp zardoz.y sub/zardoz.y
74 cp zardoz.y sub/dir/quux.y
76 c_outputs='zardoz.c bar-quux.c sub/foo-zardoz.c sub/dir/quux.c'
78 $ACLOCAL
79 $AUTOCONF
80 $AUTOMAKE -a
82 for vpath in : false; do
84 if $vpath; then
85 srcdir=..
86 mkdir build
87 cd build
88 else
89 srcdir=.
92 $srcdir/configure
93 $MAKE
95 # For debugging,
96 ls -l . sub sub/dir
97 $EGREP 'line|\.y' $c_outputs
99 # Adjusted "#line" should not contain reference to the builddir.
100 grep '#.*line.*build.*\.y' $c_outputs && exit 1
101 # Adjusted "#line" should not contain reference to the absolute
102 # srcdir.
103 $EGREP '#.*line *"?/.*\.y' $c_outputs && exit 1
104 # Adjusted "#line" should not contain reference to the default
105 # output file names, e.g., 'y.tab.c' and 'y.tab.h'.
106 grep '#.*line.*y\.tab\.' $c_outputs && exit 1
107 # Look out for a silly regression.
108 grep "#.*\.y.*\.y" $c_outputs && exit 1
109 if $vpath; then
110 grep '#.*line.*"\.\./zardoz\.y"' zardoz.c
111 grep '#.*line.*"\.\./dir/quux\.y"' bar-quux.c
112 grep '#.*line.*"\.\./\.\./sub/zardoz\.y"' sub/foo-zardoz.c
113 grep '#.*line.*"\.\./\.\./sub/dir/quux\.y"' sub/dir/quux.c
114 else
115 grep '#.*line.*"zardoz\.y"' zardoz.c
116 grep '#.*line.*"dir/quux\.y"' bar-quux.c
117 grep '#.*line.*"zardoz\.y"' sub/foo-zardoz.c
118 grep '#.*line.*"dir/quux\.y"' sub/dir/quux.c
121 cd $srcdir
123 done