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)
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'.
25 cat >> configure.ac << 'END'
26 AC_CONFIG_FILES([sub/Makefile])
34 cat > Makefile.am << 'END'
36 bin_PROGRAMS = foo bar
39 foo_SOURCES = zardoz.y
40 bar_SOURCES = dir/quux.y
41 ## Avoid spurious failures with Solaris make.
42 zardoz.@OBJEXT@: zardoz.c
43 bar-quux.@OBJEXT@: bar-quux.c
46 cat > sub/Makefile.am << 'END'
47 AUTOMAKE_OPTIONS = subdir-objects
48 noinst_PROGRAMS = foo bar
50 foo_SOURCES = zardoz.y
51 bar_SOURCES = dir/quux.y
52 ## Avoid spurious failures with Solaris make.
53 foo-zardoz.@OBJEXT@: foo-zardoz.c
54 dir/quux.@OBJEXT@: dir/quux.c
57 cat > zardoz.y << 'END'
59 int yylex () { return 0; }
60 void yyerror (char *s) { return; }
71 cp zardoz.y dir/quux.y
72 cp zardoz.y sub/zardoz.y
73 cp zardoz.y sub/dir/quux.y
75 c_outputs='zardoz.c bar-quux.c sub/foo-zardoz.c sub/dir/quux.c'
79 # FIXME: stop disabling the warnings in the 'unsupported' category
80 # FIXME: once the 'subdir-objects' option has been mandatory.
81 $AUTOMAKE -a -Wno-unsupported
83 for vpath in : false; do
98 $EGREP 'line|\.y' $c_outputs
100 # Adjusted "#line" should not contain reference to the builddir.
101 grep '#.*line.*build.*\.y' $c_outputs && exit 1
102 # Adjusted "#line" should not contain reference to the absolute
104 $EGREP '#.*line *"?/.*\.y' $c_outputs && exit 1
105 # Adjusted "#line" should not contain reference to the default
106 # output file names, e.g., 'y.tab.c' and 'y.tab.h'.
107 grep '#.*line.*y\.tab\.' $c_outputs && exit 1
108 # Look out for a silly regression.
109 grep "#.*\.y.*\.y" $c_outputs && exit 1
111 grep '#.*line.*"\.\./zardoz\.y"' zardoz.c
112 grep '#.*line.*"\.\./dir/quux\.y"' bar-quux.c
113 grep '#.*line.*"\.\./\.\./sub/zardoz\.y"' sub/foo-zardoz.c
114 grep '#.*line.*"\.\./\.\./sub/dir/quux\.y"' sub/dir/quux.c
116 grep '#.*line.*"zardoz\.y"' zardoz.c
117 grep '#.*line.*"dir/quux\.y"' bar-quux.c
118 grep '#.*line.*"zardoz\.y"' sub/foo-zardoz.c
119 grep '#.*line.*"dir/quux\.y"' sub/dir/quux.c