2 # Copyright (C) 2001-2012 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
])
35 cat > Makefile.am
<< 'END'
37 bin_PROGRAMS
= foo bar
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
47 cat > sub
/Makefile.am
<< 'END'
48 AUTOMAKE_OPTIONS
= subdir-objects
49 noinst_PROGRAMS
= foo bar
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
58 cat > zardoz.y
<< 'END'
60 int yylex
() { return 0; }
61 void yyerror
(char
*s
) { return; }
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'
82 for vpath
in : false
; do
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
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
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
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