configure: remove an obsolete TODO comment
[platform/upstream/automake.git] / t / lex-line.sh
1 #! /bin/sh
2 # Copyright (C) 2011-2013 Free Software Foundation, Inc.
3 #
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.
8 #
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.
13 #
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/>.
16
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'.
21
22 required='cc lex'
23 . test-init.sh
24
25 cat >> configure.ac << 'END'
26 AC_CONFIG_FILES([sub/Makefile])
27 AC_PROG_CC
28 AM_PROG_CC_C_O
29 AC_PROG_LEX
30 AC_OUTPUT
31 END
32
33 mkdir dir sub sub/dir
34
35 cat > Makefile.am << 'END'
36 SUBDIRS = sub
37 bin_PROGRAMS = foo bar
38 LDADD = $(LEXLIB)
39 bar_LFLAGS = -v
40 foo_SOURCES = zardoz.l
41 bar_SOURCES = dir/quux.l
42 ## Avoid spurious failures with Solaris make.
43 zardoz.@OBJEXT@: zardoz.c
44 bar-quux.@OBJEXT@: bar-quux.c
45 END
46
47 cat > sub/Makefile.am << 'END'
48 AUTOMAKE_OPTIONS = subdir-objects
49 noinst_PROGRAMS = foo bar
50 ## We already used $(LEXLIB) above, so try @LEXLIB@ now.
51 LDADD = @LEXLIB@
52 foo_LFLAGS = -v
53 foo_SOURCES = zardoz.l
54 bar_SOURCES = dir/quux.l
55 ## Avoid spurious failures with Solaris make.
56 foo-zardoz.@OBJEXT@: foo-zardoz.c
57 dir/quux.@OBJEXT@: dir/quux.c
58 END
59
60 cat > zardoz.l << 'END'
61 %{
62 #define YY_NO_UNISTD_H 1
63 %}
64 %%
65 "END"  return EOF;
66 .
67 %%
68 int main ()
69 {
70   while (yylex () != EOF)
71     ;
72   return 0;
73 }
74
75 /* Avoid possible link errors. */
76 int yywrap (void)
77 {
78   return 1;
79 }
80 END
81
82 cp zardoz.l dir/quux.l
83 cp zardoz.l sub/zardoz.l
84 cp zardoz.l sub/dir/quux.l
85
86 c_outputs='zardoz.c bar-quux.c sub/foo-zardoz.c sub/dir/quux.c'
87
88 $ACLOCAL
89 $AUTOCONF
90 $AUTOMAKE -a
91
92 for vpath in : false; do
93
94   if $vpath; then
95     srcdir=..
96     mkdir build
97     cd build
98   else
99     srcdir=.
100   fi
101
102   $srcdir/configure
103   $MAKE
104
105   # For debugging,
106   ls -l . sub sub/dir
107   $EGREP 'line|\.l' $c_outputs
108
109   grep '#.*line.*build.*\.l' $c_outputs && exit 1
110   # Adjusted "#line" should not contain reference to the absolute
111   # srcdir.
112   $EGREP '#.*line *"?/.*\.l' $c_outputs && exit 1
113   # Adjusted "#line" should not contain reference to the default
114   # output file names, e.g., 'lex.yy.c'.
115   grep '#.*line.*lex\.yy' $c_outputs && exit 1
116   # Look out for a silly regression.
117   grep "#.*\.l.*\.l" $c_outputs && exit 1
118   if $vpath; then
119     grep '#.*line.*"\.\./zardoz\.l"' zardoz.c
120     grep '#.*line.*"\.\./dir/quux\.l"' bar-quux.c
121     grep '#.*line.*"\.\./\.\./sub/zardoz\.l"' sub/foo-zardoz.c
122     grep '#.*line.*"\.\./\.\./sub/dir/quux\.l"' sub/dir/quux.c
123   else
124     grep '#.*line.*"zardoz\.l"' zardoz.c
125     grep '#.*line.*"dir/quux\.l"' bar-quux.c
126     grep '#.*line.*"zardoz\.l"' sub/foo-zardoz.c
127     grep '#.*line.*"dir/quux\.l"' sub/dir/quux.c
128   fi
129
130   cd $srcdir
131
132 done
133
134 :