2 # Copyright (C) 2012-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 we can build a program using several lexers at once
18 # (assuming Flex is used). That is a little tricky, but possible.
20 # <http://lists.gnu.org/archive/html/automake/2010-10/msg00081.html>
21 # <http://lists.gnu.org/archive/html/automake/2009-03/msg00061.html>
26 cat >> configure.ac << 'END'
34 cat > Makefile.am << 'END'
37 zardoz_SOURCES = main.c
38 # Convenience libraries.
39 noinst_LIBRARIES = liblex.a liblex-foo.a liblex-bar.a
40 zardoz_LDADD = $(noinst_LIBRARIES)
42 liblex_a_SOURCES = 0.l
44 # We need the output to always be named 'lex.yy.c', in order for
45 # ylwrap to pick it up.
46 liblex_foo_a_LFLAGS = -Pfoo -olex.yy.c
47 liblex_foo_a_SOURCES = a.l
50 liblex_bar_a_LFLAGS = -Pbar_ -olex.yy.c
51 liblex_bar_a_SOURCES = b.l
59 int main (int argc, char *argv[])
63 else if (!strcmp(argv[1], "--vanilla"))
64 return (yylex () != 121);
65 else if (!strcmp(argv[1], "--foo"))
66 return (foolex () != 121);
67 else if (!strcmp(argv[1], "--bar"))
68 return (bar_lex () != 121);
76 #define YY_NO_UNISTD_H 1
79 "VANILLA" { printf (":%s:\n", yytext); return 121; }
80 . { printf (":%s:\n", yytext); return 1; }
82 /* Avoid possible link errors. */
83 int yywrap (void) { return 1; }
86 sed 's/VANILLA/FOO/' 0.l > a.l
87 sed 's/VANILLA/BAR/' 0.l > b.l
91 $AUTOMAKE --add-missing
96 if ! cross_compiling; then
97 echo VANILLA | ./zardoz --vanilla
98 echo FOO | ./zardoz --foo
99 echo BAR | ./zardoz --bar
100 ./zardoz --vanilla </dev/null && exit 1
101 echo BAR | ./zardoz --foo && exit 1
102 : For shells with busted 'set -e'.