tests: never source test-defs.sh directly, source test-lib.sh instead
[automake.git] / t / lex5.sh
blobcce028a79b8bae9bd1647761086acb6cb7a88210
1 #! /bin/sh
2 # Copyright (C) 2002-2012 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 <http://www.gnu.org/licenses/>.
17 # Test for subdir lexers.
19 required='cc lex'
20 . ./defs || exit 1
22 cat >> configure.ac << 'END'
23 AC_PROG_CC
24 AM_PROG_CC_C_O
25 AM_PROG_LEX
26 AC_OUTPUT
27 END
29 cat > Makefile.am << 'END'
30 AUTOMAKE_OPTIONS = subdir-objects
31 LDADD = @LEXLIB@
33 bin_PROGRAMS = foo/foo
34 foo_foo_SOURCES = foo/foo.l
35 END
37 mkdir foo
39 cat > foo/foo.l << 'END'
41 #define YY_NO_UNISTD_H 1
44 "END" return EOF;
47 int
48 main ()
50 while (yylex () != EOF)
53 return 0;
55 END
57 $ACLOCAL
58 $AUTOCONF
59 $AUTOMAKE -a
61 # We expect ylwrap to be used and distributed even if there is
62 # only one lexer.
63 test -f ylwrap
65 mkdir sub
66 cd sub
67 ../configure
68 $MAKE foo/foo.o
69 ls -l # For debugging.
71 test -f foo/foo.c
72 test -f foo/foo.o
74 # Now, adds another lexer to test ylwrap.
76 cd ..
77 cp foo/foo.l foo/foo2.l
78 cat >> Makefile.am << 'END'
79 EXTRA_foo_foo_SOURCES = foo/foo2.l
80 END
82 # Make sure Makefile.in has a new time stamp: the rebuild rules are
83 # used below. We do this after updating Makefile.am, that way we can
84 # ensure that automake, even with --no-force, is not confused if the
85 # new Makefile.am has the same time stamp as the older one (since the
86 # output will change, --no-force should have no effect).
87 $sleep
89 $AUTOMAKE -a --no-force
91 cd sub
92 using_gmake || $MAKE Makefile
93 $MAKE foo/foo2.o
94 ls -l # For debugging.
95 test -f foo/foo2.c
96 test -f foo/foo2.o