maint: Update HACKING
[automake.git] / t / lex-lib.sh
blobb0bdd904bf06226d258aa5d27a554c88c98b12ed
1 #! /bin/sh
2 # Copyright (C) 1999-2017 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 we can provide a personal 'yywrap' function in a custom
18 # library.
19 # See also test 'lex-lib-external.sh'.
21 required='cc lex'
22 . test-init.sh
24 cat >> configure.ac << 'END'
25 AC_PROG_CC
26 AM_PROG_AR
27 AC_PROG_RANLIB
28 LEXLIB=libmylex.a
29 AC_PROG_LEX
30 AC_OUTPUT
31 END
33 cat > Makefile.am << 'END'
34 bin_PROGRAMS = lexer
35 lexer_SOURCES = foo.l
36 lexer_LDADD = $(LEXLIB)
37 EXTRA_lexer_DEPENDENCIES = $(LEXLIB)
38 noinst_LIBRARIES = libmylex.a
39 libmylex_a_SOURCES = mu.c
40 END
42 cat > mu.c << 'END'
43 int yywrap (void)
45 return 1;
47 END
49 cat > foo.l <<'END'
51 #define YY_NO_UNISTD_H 1
54 "END" return EOF;
57 int main (void)
59 return 0;
61 END
63 $ACLOCAL
64 $AUTOCONF
65 $AUTOMAKE -a
67 ./configure
68 $MAKE
69 test -f foo.c
70 test -f libmylex.a