tests: Let 'ltorder.sh' run successfully with Guix dynamic loader
[automake.git] / t / lex-clean-cxx.sh
blob9b27319adbc513c4b5c4903002c72ccd377ecf3e
1 #! /bin/sh
2 # Copyright (C) 2011-2018 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++ 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_DECL int yylex (void)
57 extern "C" YY_DECL;
58 #define YY_NO_UNISTD_H 1
59 int isatty (int fd) { return 0; }
62 "GOOD" return EOF;
65 int yywrap (void)
67 return 1;
69 END
70 cp parsefoo.lxx parsebar.ll
72 cat > mainfoo.cc << 'END'
73 // This file should contain valid C++ but invalid C.
74 extern "C" int yylex (void);
75 using namespace std;
76 int main (int argc, char **argv)
78 return yylex ();
80 END
81 cp mainfoo.cc mainbar.cpp
82 cp mainfoo.cc mainbaz.c++
83 cp mainfoo.cc mainqux.cxx
85 $ACLOCAL
86 $AUTOCONF
87 $AUTOMAKE -a
89 ./configure
91 cp config.status config.sav
93 $MAKE
94 ls -l
95 # Sanity checks.
96 test -f parsefoo.cxx
97 test -f bar-parsebar.cc
98 test -f parsebaz.l++
99 test -f parsebaz.c++
100 test -f parsequx.lpp
101 test -f qux-parsequx.cpp
103 for target in clean distclean; do
104 $MAKE $target
105 ls -l
106 test -f parsefoo.cxx
107 test -f bar-parsebar.cc
108 test ! -e parsebaz.l++
109 test ! -e parsebaz.c++
110 test ! -e parsequx.lpp
111 test ! -e qux-parsequx.cpp
112 done
114 cp config.sav config.status
115 ./config.status # re-create Makefile
117 $MAKE maintainer-clean
118 ls -l
119 test -f parsefoo.lxx
120 test -f parsebar.ll
121 test ! -e parsefoo.cxx
122 test ! -e bar-parsebar.cc
123 test -f parsefoo.lxx
124 test -f parsebar.ll
125 test ! -e parsefoo.cxx
126 test ! -e bar-parsebar.cc