doc: update Vala documentation
[automake.git] / t / lex-clean.sh
blob14bad09d9758e372c710c190b8d7443f8979d640
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 # Check that .c files derived from non-distributed .l sources
18 # are cleaned by "make clean", while .c files derived from
19 # distributed .l sources are cleaned by "make maintainer-clean".
20 # See also sister test 'lex-clean-cxx.sh'.
22 required='cc lex'
23 . test-init.sh
25 cat >> configure.ac << 'END'
26 AC_PROG_CC
27 AC_PROG_LEX
28 AC_OUTPUT
29 END
31 cat > Makefile.am << 'END'
32 AM_LFLAGS = --never-interactive
34 bin_PROGRAMS = foo bar baz qux
36 foo_SOURCES = main.c lexer.l
38 bar_SOURCES = main.c lexer.l
39 bar_LFLAGS = $(AM_LFLAGS)
41 baz_SOURCES = main.c
42 nodist_baz_SOURCES = baz.l
44 qux_SOURCES = main.c
45 nodist_qux_SOURCES = baz.l
46 qux_LFLAGS = $(AM_LFLAGS)
48 baz.l:
49 cp $(srcdir)/lexer.l $@
51 CLEANFILES = baz.l
53 LDADD = $(LEXLIB)
54 END
56 cat > lexer.l << 'END'
58 "GOOD" return EOF;
60 END
62 cat > main.c << 'END'
63 extern int yylex (void);
64 int main (void)
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
82 cp config.status config.sav
84 $MAKE
85 ls -l
86 # Sanity checks.
87 test -f lexer.l
88 test -f lexer.c
89 test -f bar-lexer.c
90 test -f baz.l
91 test -f baz.c
92 test -f qux-baz.c
94 for target in clean distclean; do
95 $MAKE $target
96 ls -l
97 test -f lexer.l
98 test -f lexer.c
99 test -f bar-lexer.c
100 test ! -e baz.l
101 test ! -e baz.c
102 test ! -e qux-baz.c
103 done
105 cp config.sav config.status
106 ./config.status # re-create Makefile
108 $MAKE maintainer-clean
109 ls -l
110 test -f lexer.l
111 test ! -e lexer.c
112 test ! -e bar-lexer.c