doc: update Vala documentation
[automake.git] / t / lex-line.sh
blob90c77c294272873de2c01ed55194ad415120cc0c
1 #! /bin/sh
2 # Copyright (C) 2011-2024 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 <https://www.gnu.org/licenses/>.
17 # Check that automake lex support ensures that lex-generated C
18 # files use correct "#line" directives. Try also with the
19 # 'subdir-object' option enabled.
20 # See also sister test 'yacc-line.sh'.
22 required='cc lex'
23 . test-init.sh
25 cat >> configure.ac << 'END'
26 AC_CONFIG_FILES([sub/Makefile])
27 AC_PROG_CC
28 AC_PROG_LEX
29 AC_OUTPUT
30 END
32 mkdir dir sub sub/dir
34 cat > Makefile.am << 'END'
35 AM_LFLAGS = --never-interactive
37 SUBDIRS = sub
38 bin_PROGRAMS = foo bar
39 LDADD = $(LEXLIB)
40 bar_LFLAGS = -v
41 foo_SOURCES = zardoz.l
42 bar_SOURCES = dir/quux.l
43 ## Avoid spurious failures with Solaris make.
44 zardoz.@OBJEXT@: zardoz.c
45 bar-quux.@OBJEXT@: bar-quux.c
46 END
48 cat > sub/Makefile.am << 'END'
49 AM_LFLAGS = --never-interactive
51 AUTOMAKE_OPTIONS = subdir-objects
52 noinst_PROGRAMS = foo bar
53 ## We already used $(LEXLIB) above, so try @LEXLIB@ now.
54 LDADD = @LEXLIB@
55 foo_LFLAGS = -v
56 foo_SOURCES = zardoz.l
57 bar_SOURCES = dir/quux.l
58 ## Avoid spurious failures with Solaris make.
59 foo-zardoz.@OBJEXT@: foo-zardoz.c
60 dir/quux.@OBJEXT@: dir/quux.c
61 END
63 cat > zardoz.l << 'END'
65 "END" return EOF;
68 int main ()
70 while (yylex () != EOF)
72 return 0;
75 /* Avoid possible link errors. */
76 int yywrap (void)
78 return 1;
80 END
82 cp zardoz.l dir/quux.l
83 cp zardoz.l sub/zardoz.l
84 cp zardoz.l sub/dir/quux.l
86 c_outputs='zardoz.c bar-quux.c sub/foo-zardoz.c sub/dir/quux.c'
88 $ACLOCAL
89 $AUTOCONF
90 # FIXME: stop disabling the warnings in the 'unsupported' category
91 # FIXME: once the 'subdir-objects' option has been mandatory.
92 $AUTOMAKE -a -Wno-unsupported
94 for vpath in : false; do
96 if $vpath; then
97 srcdir=..
98 mkdir build
99 cd build
100 else
101 srcdir=.
104 $srcdir/configure
105 $MAKE
107 # For debugging,
108 ls -l . sub sub/dir
109 $EGREP 'line|\.l' $c_outputs
111 grep '#.*line.*build.*\.l' $c_outputs && exit 1
112 # Adjusted "#line" should not contain reference to the absolute
113 # srcdir.
114 $EGREP '#.*line *"?/.*\.l' $c_outputs && exit 1
115 # Adjusted "#line" should not contain reference to the default
116 # output file names, e.g., 'lex.yy.c'.
117 grep '#.*line.*lex\.yy' $c_outputs && exit 1
118 # Look out for a silly regression.
119 grep "#.*\.l.*\.l" $c_outputs && exit 1
120 if $vpath; then
121 grep '#.*line.*"\.\./zardoz\.l"' zardoz.c
122 grep '#.*line.*"\.\./dir/quux\.l"' bar-quux.c
123 grep '#.*line.*"\.\./\.\./sub/zardoz\.l"' sub/foo-zardoz.c
124 grep '#.*line.*"\.\./\.\./sub/dir/quux\.l"' sub/dir/quux.c
125 else
126 grep '#.*line.*"zardoz\.l"' zardoz.c
127 grep '#.*line.*"dir/quux\.l"' bar-quux.c
128 grep '#.*line.*"zardoz\.l"' sub/foo-zardoz.c
129 grep '#.*line.*"dir/quux\.l"' sub/dir/quux.c
132 cd $srcdir
134 done