tests: fix spurious failures due to missing 'yywrap()' function
[automake.git] / tests / lex-nodist.test
blob092e089605881cf185b8b69bd300e9b6ec861362
1 #! /bin/sh
2 # Copyright (C) 2011 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 # Checks for .c files derived from non-distributed .l sources.
18 # The test `lex-pr204.test' does similar check with AM_MAINTAINER_MODE
19 # enabled.
20 # The tests 'yacc-nodist.test' and 'yacc-pr204.test' does similar checks
21 # for yacc-generated .c and .h files.
23 required=lex
24 . ./defs || Exit 1
26 set -e
28 cat >> configure.in << 'END'
29 AC_PROG_CC
30 dnl Sister test 'lex-pr204.test' should use 'AC_PROG_LEX' instead.
31 AM_PROG_LEX
32 AC_OUTPUT
33 END
35 cat > Makefile.am << 'END'
36 .PHONY: test-build test-dist
37 test-build: all
38 ls -l
39 test -f lexer.l
40 test -f lexer.c
41 test-dist: distdir
42 ls -l $(distdir)
43 test ! -r $(distdir)/lexer.l
44 test ! -r $(distdir)/lexer.c
45 check-local: test-build test-dist
47 lexer.l:
48 rm -f $@ $@-t
49 :; { : \
50 && echo '%%' \
51 && echo '"GOOD" return EOF;' \
52 && echo '.'; \
53 } > $@-t
54 chmod a-w $@-t && mv -f $@-t $@
56 bin_PROGRAMS = prog
57 prog_SOURCES = main.c
58 nodist_prog_SOURCES = lexer.l
59 prog_LDADD = $(LEXLIB)
60 CLEANFILES = $(nodist_prog_SOURCES)
61 END
63 cat > main.c << 'END'
64 int main ()
66 return yylex ();
69 /* Avoid possible link errors. */
70 int yywrap (void)
72 return 1;
74 END
76 $ACLOCAL
77 $AUTOCONF
78 $AUTOMAKE -a
80 ./configure
81 $MAKE
82 $MAKE test-build
83 $MAKE test-dist
85 # But the distribution must work correctly, assuming the user has
86 # the proper tools to process yacc files.
87 $MAKE distcheck