Debian Codegraph @

t/yacc-clean-cxx.sh

raw symbols SCIP
1 #! /bin/shscip-shell filesystem . . `/bin/sh`.
2 # Copyright (C) 2011-2025 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 <https://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.shscip-shell source . . `test-init.sh`.
25
26 catscip-shell system . . 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 catscip-shell system . . 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 mkdirscip-shell system . . mkdir. sub1 sub2
40
41 catscip-shell system . . cat. > sub1/Makefile.am << 'END'
42 AM_LFLAGS = --never-interactive
43
44 bin_PROGRAMS = foo bar baz qux
45
46 foo_SOURCES = mainfoo.cc parsefoo.yxx
47
48 bar_SOURCES = mainbar.cpp parsebar.yy
49 bar_YFLAGS = $(AM_YFLAGS)
50
51 baz_SOURCES = mainbaz.c++
52 nodist_baz_SOURCES = parsebaz.y++
53
54 qux_SOURCES = mainqux.cxx
55 nodist_qux_SOURCES = parsequx.ypp
56 qux_YFLAGS = $(AM_YFLAGS)
57
58 parsebaz.y++ parsequx.ypp:
59 cp $(srcdir)/parsefoo.yxx $@
60
61 CLEANFILES = parsebaz.y++ parsequx.ypp
62 END
63
64 catscip-shell system . . cat. > sub2/Makefile.am << 'END'
65 include $(top_srcdir)/sub1/Makefile.am
66 AM_YFLAGS = -d
67 END
68
69 catscip-shell system . . cat. > sub1/parsefoo.yxx << 'END'
70 %{
71 // This file should contain valid C++ but invalid C.
72 #include <cstdio>
73 #if (defined __cplusplus) && ((!defined __sun) || (defined __EXTERN_C__))
74 extern "C" {
75 #endif
76
77 // "std::" qualification required by Sun C++ 5.9.
78 int yylex (void) { return std::getchar (); }
79 void yyerror (const char *s) {}
80 #if (defined __cplusplus) && ((!defined __sun) || (defined __EXTERN_C__))
81 }
82 #endif
83
84 %}
85 %%
86 x : 'x' { };
87 END
88 cpscip-shell system . . cp. sub1/parsefoo.yxx sub1/parsebar.yy
89 cpscip-shell system . . cp. sub1/parsefoo.yxx sub2/parsefoo.yxx
90 cpscip-shell system . . cp. sub1/parsefoo.yxx sub2/parsebar.yy
91
92 catscip-shell system . . cat. > sub1/mainfoo.cc << 'END'
93 // This file should contain valid C++ but invalid C.
94 using namespace std;
95 int main (int argc, char **argv)
96 {
97 extern int yyparse (void);
98 return yyparse ();
99 }
100 END
101 cpscip-shell system . . cp. sub1/mainfoo.cc sub1/mainbar.cpp
102 cpscip-shell system . . cp. sub1/mainfoo.cc sub1/mainbaz.c++
103 cpscip-shell system . . cp. sub1/mainfoo.cc sub1/mainqux.cxx
104 cpscip-shell system . . cp. sub1/main???.c* sub2
105
106 $ACLOCAL
107 $AUTOCONF
108 $AUTOMAKE -a
109
110 ./configure
111
112 cpscip-shell system . . cp. config.status config.sav
113
114 $MAKE
115 lsscip-shell system . . ls. -l . sub1 sub2
116 # Sanity checks.
117 testscip-shell system . . test. -f sub1/parsefoo.cxx
118 testscip-shell system . . test. -f sub1/bar-parsebar.cc
119 testscip-shell system . . test. -f sub1/parsebaz.y++
120 testscip-shell system . . test. -f sub1/parsebaz.c++
121 testscip-shell system . . test. -f sub1/parsequx.ypp
122 testscip-shell system . . test. -f sub1/qux-parsequx.cpp
123 testscip-shell system . . test. -f sub2/parsefoo.cxx
124 testscip-shell system . . test. -f sub2/parsefoo.hxx
125 testscip-shell system . . test. -f sub2/bar-parsebar.cc
126 testscip-shell system . . test. -f sub2/bar-parsebar.hh
127 testscip-shell system . . test. -f sub2/parsebaz.y++
128 testscip-shell system . . test. -f sub2/parsebaz.c++
129 testscip-shell system . . test. -f sub2/parsebaz.h++
130 testscip-shell system . . test. -f sub2/parsequx.ypp
131 testscip-shell system . . test. -f sub2/qux-parsequx.cpp
132 testscip-shell system . . test. -f sub2/qux-parsequx.hpp
133
134 for target in clean distclean; do
135 $MAKE $target
136 lsscip-shell system . . ls. -l . sub1 sub2
137 testscip-shell system . . test. -f sub1/parsefoo.cxx
138 testscip-shell system . . test. -f sub1/bar-parsebar.cc
139 testscip-shell system . . test. ! -e sub1/parsebaz.y++
140 testscip-shell system . . test. ! -e sub1/parsebaz.c++
141 testscip-shell system . . test. ! -e sub1/parsequx.ypp
142 testscip-shell system . . test. ! -e sub1/qux-parsequx.cpp
143 testscip-shell system . . test. -f sub2/parsefoo.cxx
144 testscip-shell system . . test. -f sub2/parsefoo.hxx
145 testscip-shell system . . test. -f sub2/bar-parsebar.cc
146 testscip-shell system . . test. -f sub2/bar-parsebar.hh
147 testscip-shell system . . test. ! -e sub2/parsebaz.y++
148 testscip-shell system . . test. ! -e sub2/parsebaz.c++
149 testscip-shell system . . test. ! -e sub2/parsebaz.h++
150 testscip-shell system . . test. ! -e sub2/parsequx.ypp
151 testscip-shell system . . test. ! -e sub2/qux-parsequx.cpp
152 testscip-shell system . . test. ! -e sub2/qux-parsequx.hpp
153 done
154
155 cpscip-shell system . . cp. config.sav config.status
156 ./config.status # re-create Makefile
157
158 $MAKE maintainer-clean
159 lsscip-shell system . . ls. -l . sub1 sub2
160 testscip-shell system . . test. -f sub1/parsefoo.yxx
161 testscip-shell system . . test. -f sub1/parsebar.yy
162 testscip-shell system . . test. ! -e sub1/parsefoo.cxx
163 testscip-shell system . . test. ! -e sub1/bar-parsebar.cc
164 testscip-shell system . . test. -f sub2/parsefoo.yxx
165 testscip-shell system . . test. -f sub2/parsebar.yy
166 testscip-shell system . . test. ! -e sub2/parsefoo.cxx
167 testscip-shell system . . test. ! -e sub2/parsefoo.hxx
168 testscip-shell system . . test. ! -e sub2/bar-parsebar.cc
169 testscip-shell system . . test. ! -e sub2/bar-parsebar.hh
170
171 :