tests: cosmetic changes in t/extra-sources.sh
[platform/upstream/automake.git] / t / yacc-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 and header files derived from non-distributed
18 # Yacc sources are cleaned by "make clean", while C++ source and
19 # header files derived from distributed Yacc sources are cleaned by
20 # "make maintainer-clean".
21 # See also sister test 'yacc-clean.sh'.
22
23 required='c++ yacc'
24 . test-init.sh
25
26 cat >> configure.ac << 'END'
27 AC_PROG_CXX
28 AC_PROG_YACC
29 AC_CONFIG_FILES([sub1/Makefile sub2/Makefile])
30 AC_OUTPUT
31 END
32
33 cat > Makefile.am << 'END'
34 # Use two subdirectories, one to test with '-d' in YFLAGS, the
35 # other one to test with empty YFLAGS.
36 SUBDIRS = sub1 sub2
37 END
38
39 mkdir sub1 sub2
40
41 cat > sub1/Makefile.am << 'END'
42 bin_PROGRAMS = foo bar baz qux
43
44 foo_SOURCES = mainfoo.cc parsefoo.yxx
45
46 bar_SOURCES = mainbar.cpp parsebar.yy
47 bar_YFLAGS = $(AM_YFLAGS)
48
49 baz_SOURCES = mainbaz.c++
50 nodist_baz_SOURCES = parsebaz.y++
51
52 qux_SOURCES = mainqux.cxx
53 nodist_qux_SOURCES = parsequx.ypp
54 qux_YFLAGS = $(AM_YFLAGS)
55
56 parsebaz.y++ parsequx.ypp:
57         cp $(srcdir)/parsefoo.yxx $@
58
59 CLEANFILES = parsebaz.y++ parsequx.ypp
60 END
61
62 cat > sub2/Makefile.am << 'END'
63 include $(top_srcdir)/sub1/Makefile.am
64 AM_YFLAGS = -d
65 END
66
67 cat > sub1/parsefoo.yxx << 'END'
68 %{
69 // This file should contain valid C++ but invalid C.
70 #include <cstdio>
71 // "std::" qualification required by Sun C++ 5.9.
72 int yylex (void) { return std::getchar (); }
73 void yyerror (const char *s) { return; }
74 %}
75 %%
76 x : 'x' { };
77 END
78 cp sub1/parsefoo.yxx sub1/parsebar.yy
79 cp sub1/parsefoo.yxx sub2/parsefoo.yxx
80 cp sub1/parsefoo.yxx sub2/parsebar.yy
81
82 cat > sub1/mainfoo.cc << 'END'
83 // This file should contain valid C++ but invalid C.
84 using namespace std;
85 int main (int argc, char **argv)
86 {
87   extern int yyparse (void);
88   return yyparse ();
89 }
90 END
91 cp sub1/mainfoo.cc sub1/mainbar.cpp
92 cp sub1/mainfoo.cc sub1/mainbaz.c++
93 cp sub1/mainfoo.cc sub1/mainqux.cxx
94 cp sub1/main???.c* sub2
95
96 $ACLOCAL
97 $AUTOCONF
98 $AUTOMAKE -a
99
100 ./configure
101
102 cp config.status config.sav
103
104 $MAKE
105 ls -l . sub1 sub2
106 # Sanity checks.
107 test -f sub1/parsefoo.cxx
108 test -f sub1/bar-parsebar.cc
109 test -f sub1/parsebaz.y++
110 test -f sub1/parsebaz.c++
111 test -f sub1/parsequx.ypp
112 test -f sub1/qux-parsequx.cpp
113 test -f sub2/parsefoo.cxx
114 test -f sub2/parsefoo.hxx
115 test -f sub2/bar-parsebar.cc
116 test -f sub2/bar-parsebar.hh
117 test -f sub2/parsebaz.y++
118 test -f sub2/parsebaz.c++
119 test -f sub2/parsebaz.h++
120 test -f sub2/parsequx.ypp
121 test -f sub2/qux-parsequx.cpp
122 test -f sub2/qux-parsequx.hpp
123
124 for target in clean distclean; do
125   $MAKE $target
126   ls -l . sub1 sub2
127   test -f sub1/parsefoo.cxx
128   test -f sub1/bar-parsebar.cc
129   test ! -e sub1/parsebaz.y++
130   test ! -e sub1/parsebaz.c++
131   test ! -e sub1/parsequx.ypp
132   test ! -e sub1/qux-parsequx.cpp
133   test -f sub2/parsefoo.cxx
134   test -f sub2/parsefoo.hxx
135   test -f sub2/bar-parsebar.cc
136   test -f sub2/bar-parsebar.hh
137   test ! -e sub2/parsebaz.y++
138   test ! -e sub2/parsebaz.c++
139   test ! -e sub2/parsebaz.h++
140   test ! -e sub2/parsequx.ypp
141   test ! -e sub2/qux-parsequx.cpp
142   test ! -e sub2/qux-parsequx.hpp
143 done
144
145 cp config.sav config.status
146 ./config.status # re-create Makefile
147
148 $MAKE maintainer-clean
149 ls -l . sub1 sub2
150 test -f sub1/parsefoo.yxx
151 test -f sub1/parsebar.yy
152 test ! -e sub1/parsefoo.cxx
153 test ! -e sub1/bar-parsebar.cc
154 test -f sub2/parsefoo.yxx
155 test -f sub2/parsebar.yy
156 test ! -e sub2/parsefoo.cxx
157 test ! -e sub2/parsefoo.hxx
158 test ! -e sub2/bar-parsebar.cc
159 test ! -e sub2/bar-parsebar.hh
160
161 :