tests: avoid a spurious failure on MSYS
[platform/upstream/automake.git] / t / lex-clean-cxx.sh
1 #! /bin/sh
2 # Copyright (C) 2011-2013 Free Software Foundation, Inc.
3 #
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.
8 #
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.
13 #
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/>.
16
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'.
21
22 required='c++ lex'
23 . test-init.sh
24
25 cat >> configure.ac << 'END'
26 AC_PROG_CXX
27 AC_PROG_LEX
28 AC_OUTPUT
29 END
30
31 cat > Makefile.am << 'END'
32 bin_PROGRAMS = foo bar baz qux
33
34 foo_SOURCES = mainfoo.cc parsefoo.lxx
35
36 bar_SOURCES = mainbar.cpp parsebar.ll
37 bar_LFLAGS = $(AM_LFLAGS)
38
39 baz_SOURCES = mainbaz.c++
40 nodist_baz_SOURCES = parsebaz.l++
41
42 qux_SOURCES = mainqux.cxx
43 nodist_qux_SOURCES = parsequx.lpp
44 qux_LFLAGS = $(AM_LFLAGS)
45
46 parsebaz.l++ parsequx.lpp:
47         cp $(srcdir)/parsefoo.lxx $@
48
49 CLEANFILES = parsebaz.l++ parsequx.lpp
50
51 LDADD = $(LEXLIB)
52 END
53
54 cat > parsefoo.lxx << 'END'
55 %{
56 #define YY_NO_UNISTD_H 1
57 int isatty (int fd) { return 0; }
58 %}
59 %%
60 "GOOD"   return EOF;
61 .
62 %%
63 int yywrap (void)
64 {
65   return 1;
66 }
67 END
68 cp parsefoo.lxx parsebar.ll
69
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)
74 {
75   extern int yylex (void);
76   return yylex ();
77 }
78 END
79 cp mainfoo.cc mainbar.cpp
80 cp mainfoo.cc mainbaz.c++
81 cp mainfoo.cc mainqux.cxx
82
83 $ACLOCAL
84 $AUTOCONF
85 $AUTOMAKE -a
86
87 ./configure
88
89 cp config.status config.sav
90
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
100
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
111
112 cp config.sav config.status
113 ./config.status # re-create Makefile
114
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
125
126 :