2 # Copyright (C) 2012-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)
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 we can build a program using several lexers at once
18 # (assuming Flex is used). That is a little tricky, but possible.
20 # <https://lists.gnu.org/archive/html/automake/2010-10/msg00081.html>
21 # <https://lists.gnu.org/archive/html/automake/2009-03/msg00061.html>
26 cat >> configure.ac
<< 'END'
34 cat > Makefile.am
<< 'END'
35 AM_LFLAGS
= --never-interactive
39 zardoz_SOURCES
= main.c
40 # Convenience libraries.
41 noinst_LIBRARIES
= liblex.a liblex-foo.a liblex-bar.a
42 zardoz_LDADD
= $
(noinst_LIBRARIES
)
44 liblex_a_SOURCES
= 0.l
46 # We need the output to always be named 'lex.yy.c', in order for
47 # ylwrap to pick it up.
48 liblex_foo_a_LFLAGS
= -Pfoo -olex.yy.c
49 liblex_foo_a_SOURCES
= a.l
52 liblex_bar_a_LFLAGS
= -Pbar_ -olex.yy.c
53 liblex_bar_a_SOURCES
= b.l
61 extern int yylex
(void
);
62 extern int foolex
(void
);
63 extern int bar_lex
(void
);
65 int main
(int argc
, char
*argv
[])
69 else if (!strcmp
(argv
[1], "--vanilla"))
70 return (yylex
() != 121);
71 else if (!strcmp
(argv
[1], "--foo"))
72 return (foolex
() != 121);
73 else if (!strcmp
(argv
[1], "--bar"))
74 return (bar_lex
() != 121);
82 "VANILLA" { printf (":%s:\n", yytext
); return 121; }
83 .
{ printf (":%s:\n", yytext
); return 1; }
85 /* Avoid possible link errors.
*/
86 int yywrap
(void
) { return 1; }
89 sed 's/VANILLA/FOO/' 0.l
> a.l
90 sed 's/VANILLA/BAR/' 0.l
> b.l
94 $AUTOMAKE --add-missing
99 if ! cross_compiling
; then
100 echo VANILLA | .
/zardoz
--vanilla
101 echo FOO | .
/zardoz
--foo
102 echo BAR | .
/zardoz
--bar
103 .
/zardoz
--vanilla </dev
/null
&& exit 1
104 echo BAR | .
/zardoz
--foo && exit 1
105 : For shells with busted
'set -e'.