build: Inline perl prototypes in sources
[automake.git] / t / lex-clean-cxx.sh
blob2c90b18f27f64963c2b0ce5bea20915ad087991b
1 #! /bin/sh
2 # Copyright (C) 2011-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 <http://www.gnu.org/licenses/>.
17 # Check that C++ source files derived from non-distributed Lex sources
18 # are cleaned by "make clean", while C++ source files derived from
19 # distributed Lex sources are cleaned by "make maintainer-clean".
20 # See also sister test 'lex-clean.sh'.
22 required='c++ lex'
23 . test-init.sh
25 cat >> configure.ac << 'END'
26 AC_PROG_CXX
27 AC_PROG_LEX
28 AC_OUTPUT
29 END
31 cat > Makefile.am << 'END'
32 bin_PROGRAMS = foo bar baz qux
34 foo_SOURCES = mainfoo.cc parsefoo.lxx
36 bar_SOURCES = mainbar.cpp parsebar.ll
37 bar_LFLAGS = $(AM_LFLAGS)
39 baz_SOURCES = mainbaz.c++
40 nodist_baz_SOURCES = parsebaz.l++
42 qux_SOURCES = mainqux.cxx
43 nodist_qux_SOURCES = parsequx.lpp
44 qux_LFLAGS = $(AM_LFLAGS)
46 parsebaz.l++ parsequx.lpp:
47 cp $(srcdir)/parsefoo.lxx $@
49 CLEANFILES = parsebaz.l++ parsequx.lpp
51 LDADD = $(LEXLIB)
52 END
54 cat > parsefoo.lxx << 'END'
56 #define YY_NO_UNISTD_H 1
57 int isatty (int fd) { return 0; }
60 "GOOD" return EOF;
63 int yywrap (void)
65 return 1;
67 END
68 cp parsefoo.lxx parsebar.ll
70 cat > mainfoo.cc << 'END'
71 // This file should contain valid C++ but invalid C.
72 using namespace std;
73 int main (int argc, char **argv)
75 extern int yylex (void);
76 return yylex ();
78 END
79 cp mainfoo.cc mainbar.cpp
80 cp mainfoo.cc mainbaz.c++
81 cp mainfoo.cc mainqux.cxx
83 $ACLOCAL
84 $AUTOCONF
85 $AUTOMAKE -a
87 ./configure
89 cp config.status config.sav
91 $MAKE
92 ls -l
93 # Sanity checks.
94 test -f parsefoo.cxx
95 test -f bar-parsebar.cc
96 test -f parsebaz.l++
97 test -f parsebaz.c++
98 test -f parsequx.lpp
99 test -f qux-parsequx.cpp
101 for target in clean distclean; do
102 $MAKE $target
103 ls -l
104 test -f parsefoo.cxx
105 test -f bar-parsebar.cc
106 test ! -e parsebaz.l++
107 test ! -e parsebaz.c++
108 test ! -e parsequx.lpp
109 test ! -e qux-parsequx.cpp
110 done
112 cp config.sav config.status
113 ./config.status # re-create Makefile
115 $MAKE maintainer-clean
116 ls -l
117 test -f parsefoo.lxx
118 test -f parsebar.ll
119 test ! -e parsefoo.cxx
120 test ! -e bar-parsebar.cc
121 test -f parsefoo.lxx
122 test -f parsebar.ll
123 test ! -e parsefoo.cxx
124 test ! -e bar-parsebar.cc