test: protect more yacc declarations against C vs. C++ linkage.
[automake.git] / t / lex-nodist.sh
blobf15cbf76ec36ba505740e71ad4d0cb64cf00dd71
1 #! /bin/sh
2 # Copyright (C) 2011-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)
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 # Checks for .c files derived from non-distributed .l sources.
18 # The test 'lex-pr204.sh' does similar check with AM_MAINTAINER_MODE
19 # enabled.
20 # The tests 'yacc-nodist.sh' and 'yacc-pr204.sh' does similar checks
21 # for yacc-generated .c and .h files.
23 required='cc lex'
24 . test-init.sh
26 cat >> configure.ac << 'END'
27 AC_PROG_CC
28 dnl Sister test 'lex-pr204.sh' should use 'AC_PROG_LEX' instead.
29 AM_PROG_LEX
30 AC_OUTPUT
31 END
33 cat > Makefile.am << 'END'
34 AM_LFLAGS = --never-interactive
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 extern int yylex (void);
66 int main ()
68 return yylex ();
71 /* Avoid possible link errors. */
72 int yywrap (void)
74 return 1;
76 END
78 $ACLOCAL
79 $AUTOCONF
80 $AUTOMAKE -a
82 ./configure
83 $MAKE
84 $MAKE test-build
85 $MAKE test-dist
87 # But the distribution must work correctly, assuming the user has
88 # the proper tools to process yacc files.
89 $MAKE distcheck