1 # Top level makefile fragment for GNU C++.
2 # Copyright (C) 1994, 1995, 1997 Free Software Foundation, Inc.
4 #This file is part of GNU CC.
6 #GNU CC is free software; you can redistribute it and/or modify
7 #it under the terms of the GNU General Public License as published by
8 #the Free Software Foundation; either version 2, or (at your option)
11 #GNU CC is distributed in the hope that it will be useful,
12 #but WITHOUT ANY WARRANTY; without even the implied warranty of
13 #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 #GNU General Public License for more details.
16 #You should have received a copy of the GNU General Public License
17 #along with GNU CC; see the file COPYING. If not, write to
18 #the Free Software Foundation, 59 Temple Place - Suite 330,
19 #Boston, MA 02111-1307, USA.
21 # This file provides the language dependent support in the main Makefile.
22 # Each language makefile fragment must provide the following targets:
24 # foo.all.build, foo.all.cross, foo.start.encap, foo.rest.encap,
26 # foo.install-normal, foo.install-common, foo.install-info, foo.install-man,
27 # foo.uninstall, foo.distdir,
28 # foo.mostlyclean, foo.clean, foo.distclean, foo.extraclean,
29 # foo.maintainer-clean, foo.stage1, foo.stage2, foo.stage3, foo.stage4
31 # where `foo' is the name of the language.
33 # It should also provide rules for:
35 # - making any compiler driver (eg: g++)
36 # - the compiler proper (eg: cc1plus)
37 # - define the names for selecting the language in LANGUAGES.
39 # Extra flags to pass to recursive makes.
41 "CXX_FOR_BUILD=$(CXX_FOR_BUILD)" \
42 "CXXFLAGS=$(CXXFLAGS)" \
43 "CXX_FOR_TARGET=$(CXX_FOR_TARGET)"
45 # Actual names to use when installing a native compiler.
46 CXX_INSTALL_NAME = `t='$(program_transform_name)'; echo c++ | sed $$t`
47 GXX_INSTALL_NAME = `t='$(program_transform_name)'; echo g++ | sed $$t`
48 DEMANGLER_INSTALL_NAME = `t='$(program_transform_name)'; echo c++filt | sed $$t`
50 # Actual names to use when installing a cross-compiler.
51 CXX_CROSS_NAME = `t='$(program_transform_cross_name)'; echo c++ | sed $$t`
52 GXX_CROSS_NAME = `t='$(program_transform_cross_name)'; echo g++ | sed $$t`
53 DEMANGLER_CROSS_NAME = `t='$(program_transform_cross_name)'; echo c++filt | sed $$t`
55 # The name to use for the demangler program.
56 DEMANGLER_PROG = c++filt$(exeext)
58 # Extra headers to install.
59 CXX_EXTRA_HEADERS = $(srcdir)/cp/inc/typeinfo $(srcdir)/cp/inc/exception \
60 $(srcdir)/cp/inc/new $(srcdir)/cp/inc/new.h
62 # Extra code to include in libgcc2.
63 CXX_LIB2FUNCS = tinfo.o tinfo2.o new.o opnew.o opnewnt.o opvnew.o opvnewnt.o \
64 opdel.o opdelnt.o opvdel.o opvdelnt.o exception.o
65 CXX_LIB2SRCS = $(srcdir)/cp/new.cc $(srcdir)/cp/new1.cc $(srcdir)/cp/new2.cc \
66 $(srcdir)/cp/exception.cc $(srcdir)/cp/tinfo.cc \
67 $(srcdir)/cp/tinfo2.cc $(srcdir)/cp/tinfo.h
69 # Define the names for selecting c++ in LANGUAGES.
70 # Note that it would be nice to move the dependency on g++
71 # into the C++ rule, but that needs a little bit of work
72 # to do the right thing within all.cross.
73 C++ c++: cc1plus$(exeext)
75 # Tell GNU make to ignore these if they exist.
78 g++.c: $(srcdir)/gcc.c
80 $(LN_S) $(srcdir)/gcc.c $@
82 g++spec.o: $(srcdir)/cp/g++spec.c
83 $(CC) -c $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) $(srcdir)/cp/g++spec.c
85 # N.B.: This is a copy of the gcc.o rule, with -DLANG_SPECIFIC_DRIVER added.
86 # It'd be nice if we could find an easier way to do this---rather than have
87 # to track changes to the toplevel gcc Makefile as well.
88 # We depend on g++.c last, to make it obvious where it came from.
89 g++.o: $(CONFIG_H) multilib.h config.status $(lang_specs_files) g++.c \
91 $(CC) $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \
93 -DLANG_SPECIFIC_DRIVER \
96 # Create the compiler driver for g++.
97 g++$(exeext): g++.o g++spec.o version.o choose-temp.o pexecute.o prefix.o mkstemp.o $(LIBDEPS) $(EXTRA_GCC_OBJS)
98 $(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ g++.o g++spec.o prefix.o \
99 version.o choose-temp.o pexecute.o mkstemp.o $(EXTRA_GCC_OBJS) $(LIBS)
101 # Create a version of the g++ driver which calls the cross-compiler.
102 g++-cross$(exeext): g++$(exeext)
103 -rm -f g++-cross$(exeext)
104 cp g++$(exeext) g++-cross$(exeext)
106 cxxmain.o: $(srcdir)/../libiberty/cplus-dem.c demangle.h
108 $(LN_S) $(srcdir)/../libiberty/cplus-dem.c cxxmain.c
109 $(CC) -c -DMAIN $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \
110 -DVERSION=\"$(version)\" cxxmain.c
112 $(DEMANGLER_PROG): cxxmain.o underscore.o getopt.o getopt1.o $(LIBDEPS)
113 $(CC) $(ALL_CFLAGS) $(LDFLAGS) $(LIBS) -o $@ \
114 cxxmain.o underscore.o getopt.o getopt1.o
116 CXX_SRCS = $(srcdir)/cp/call.c $(srcdir)/cp/decl2.c \
117 $(srcdir)/cp/except.c $(srcdir)/cp/input.c $(srcdir)/cp/pt.c \
118 $(srcdir)/cp/spew.c $(srcdir)/cp/xref.c $(srcdir)/cp/class.c \
119 $(srcdir)/cp/expr.c $(srcdir)/cp/lex.c \
120 $(srcdir)/cp/ptree.c $(srcdir)/cp/tree.c $(srcdir)/cp/cvt.c \
121 $(srcdir)/cp/errfn.c $(srcdir)/cp/rtti.c $(srcdir)/cp/method.c \
122 $(srcdir)/cp/search.c $(srcdir)/cp/typeck.c $(srcdir)/cp/decl.c \
123 $(srcdir)/cp/error.c $(srcdir)/cp/friend.c $(srcdir)/cp/init.c \
124 $(srcdir)/cp/parse.y $(srcdir)/cp/sig.c $(srcdir)/cp/typeck2.c \
125 $(srcdir)/cp/repo.c $(srcdir)/cp/semantics.c
127 cc1plus$(exeext): $(P) $(CXX_SRCS) $(LIBDEPS) stamp-objlist c-common.o c-pragma.o \
128 $(srcdir)/cp/cp-tree.h $(srcdir)/cp/cp-tree.def
129 cd cp; $(MAKE) $(FLAGS_TO_PASS) $(CXX_FLAGS_TO_PASS) ../cc1plus$(exeext)
133 c++.all.build: g++$(exeext)
134 c++.all.cross: g++-cross$(exeext) $(DEMANGLER_PROG)
135 c++.start.encap: g++$(exeext)
136 c++.rest.encap: $(DEMANGLER_PROG)
141 # C++ language-support library pieces for libgcc.
142 tinfo.o: cc1plus$(exeext) $(srcdir)/cp/tinfo.cc
143 $(GCC_FOR_TARGET) $(LIBGCC2_CFLAGS) $(CXXFLAGS) $(INCLUDES) \
144 -c $(srcdir)/cp/tinfo.cc
145 tinfo2.o: cc1plus$(exeext) $(srcdir)/cp/tinfo2.cc
146 $(GCC_FOR_TARGET) $(LIBGCC2_CFLAGS) $(CXXFLAGS) $(INCLUDES) \
147 -c $(srcdir)/cp/tinfo2.cc
148 exception.o: cc1plus$(exeext) $(srcdir)/cp/exception.cc
149 $(GCC_FOR_TARGET) $(LIBGCC2_CFLAGS) $(CXXFLAGS) $(INCLUDES) \
150 -c -fexceptions $(srcdir)/cp/exception.cc
151 new.o: cc1plus$(exeext) $(srcdir)/cp/new.cc
152 $(GCC_FOR_TARGET) $(LIBGCC2_CFLAGS) $(CXXFLAGS) $(INCLUDES) \
153 -c $(srcdir)/cp/new.cc
154 opnew.o: cc1plus$(exeext) $(srcdir)/cp/new1.cc
155 $(GCC_FOR_TARGET) $(LIBGCC2_CFLAGS) $(CXXFLAGS) $(INCLUDES) \
156 -c $(srcdir)/cp/new1.cc -DL_op_new -o opnew.o
157 opnewnt.o: cc1plus$(exeext) $(srcdir)/cp/new1.cc
158 $(GCC_FOR_TARGET) $(LIBGCC2_CFLAGS) $(CXXFLAGS) $(INCLUDES) \
159 -c $(srcdir)/cp/new1.cc -DL_op_newnt -o opnewnt.o
160 opvnew.o: cc1plus$(exeext) $(srcdir)/cp/new2.cc
161 $(GCC_FOR_TARGET) $(LIBGCC2_CFLAGS) $(CXXFLAGS) $(INCLUDES) \
162 -c $(srcdir)/cp/new2.cc -DL_op_vnew -o opvnew.o
163 opvnewnt.o: cc1plus$(exeext) $(srcdir)/cp/new2.cc
164 $(GCC_FOR_TARGET) $(LIBGCC2_CFLAGS) $(CXXFLAGS) $(INCLUDES) \
165 -c $(srcdir)/cp/new2.cc -DL_op_vnewnt -o opvnewnt.o
166 opdel.o: cc1plus$(exeext) $(srcdir)/cp/new2.cc
167 $(GCC_FOR_TARGET) $(LIBGCC2_CFLAGS) $(CXXFLAGS) $(INCLUDES) \
168 -c $(srcdir)/cp/new2.cc -DL_op_delete -o opdel.o
169 opdelnt.o: cc1plus$(exeext) $(srcdir)/cp/new2.cc
170 $(GCC_FOR_TARGET) $(LIBGCC2_CFLAGS) $(CXXFLAGS) $(INCLUDES) \
171 -c $(srcdir)/cp/new2.cc -DL_op_delnt -o opdelnt.o
172 opvdel.o: cc1plus$(exeext) $(srcdir)/cp/new2.cc
173 $(GCC_FOR_TARGET) $(LIBGCC2_CFLAGS) $(CXXFLAGS) $(INCLUDES) \
174 -c $(srcdir)/cp/new2.cc -DL_op_vdel -o opvdel.o
175 opvdelnt.o: cc1plus$(exeext) $(srcdir)/cp/new2.cc
176 $(GCC_FOR_TARGET) $(LIBGCC2_CFLAGS) $(CXXFLAGS) $(INCLUDES) \
177 -c $(srcdir)/cp/new2.cc -DL_op_vdelnt -o opvdelnt.o
179 # We want to update cplib2.txt if any of the source files change...
180 cplib2.txt: $(CXX_LIB2SRCS) $(CXX_EXTRA_HEADERS) cplib2.ready
181 case " $(LANGUAGES) " in \
183 echo $(CXX_LIB2FUNCS) > cplib2.new;; \
185 echo "" > cplib2.new;; \
187 mv -f cplib2.new cplib2.txt
189 # Or if it would be different.
190 cplib2.ready: $(GCC_PASSES) $(LANGUAGES) $(LIBGCC2_DEPS) stmp-int-hdrs
191 @if [ -r cplib2.txt ]; then \
192 case " $(LANGUAGES) " in \
194 echo $(CXX_LIB2FUNCS) > cplib2.new;; \
196 echo "" > cplib2.new;; \
198 if cmp -s cplib2.new cplib2.txt; then true; else \
199 touch cplib2.ready; \
204 @if [ -f cplib2.ready ]; then true; else \
205 touch cplib2.ready; \
209 # cc1plus is installed elsewhere as part of $(COMPILERS).
211 # Nothing to do here.
214 # Install the driver program as $(target)-g++
215 # and also as either g++ (if native) or $(tooldir)/bin/g++.
217 -if [ -f cc1plus$(exeext) ] ; then \
218 if [ -f g++-cross$(exeext) ] ; then \
219 rm -f $(bindir)/$(GXX_CROSS_NAME)$(exeext); \
220 $(INSTALL_PROGRAM) g++-cross$(exeext) $(bindir)/$(GXX_CROSS_NAME)$(exeext); \
221 chmod a+x $(bindir)/$(GXX_CROSS_NAME)$(exeext); \
222 rm -f $(bindir)/$(CXX_CROSS_NAME)$(exeext); \
223 $(LN) $(bindir)/$(GXX_CROSS_NAME)$(exeext) $(bindir)/$(CXX_CROSS_NAME)$(exeext); \
225 rm -f $(bindir)/$(GXX_INSTALL_NAME)$(exeext); \
226 $(INSTALL_PROGRAM) g++$(exeext) $(bindir)/$(GXX_INSTALL_NAME)$(exeext); \
227 chmod a+x $(bindir)/$(GXX_INSTALL_NAME)$(exeext); \
228 rm -f $(bindir)/$(CXX_INSTALL_NAME)$(exeext); \
229 $(LN) $(bindir)/$(GXX_INSTALL_NAME)$(exeext) $(bindir)/$(CXX_INSTALL_NAME)$(exeext); \
231 if [ x$(DEMANGLER_PROG) != x ] && [ -x "$(DEMANGLER_PROG)" ]; then \
232 if [ -f g++-cross$(exeext) ] ; then \
233 rm -f $(bindir)/$(DEMANGLER_CROSS_NAME)$(exeext); \
234 $(INSTALL_PROGRAM) $(DEMANGLER_PROG) $(bindir)/$(DEMANGLER_CROSS_NAME)$(exeext); \
235 chmod a+x $(bindir)/$(DEMANGLER_CROSS_NAME)$(exeext); \
237 rm -f $(bindir)/$(DEMANGLER_INSTALL_NAME)$(exeext); \
238 $(INSTALL_PROGRAM) $(DEMANGLER_PROG) $(bindir)/$(DEMANGLER_INSTALL_NAME)$(exeext); \
239 chmod a+x $(bindir)/$(DEMANGLER_INSTALL_NAME)$(exeext); \
246 c++.install-man: $(srcdir)/cp/g++.1
247 -if [ -f cc1plus$(exeext) ] ; then \
248 if [ -f g++-cross$(exeext) ] ; then \
249 rm -f $(mandir)/$(GXX_CROSS_NAME)$(manext); \
250 $(INSTALL_DATA) $(srcdir)/cp/g++.1 $(mandir)/$(GXX_CROSS_NAME)$(manext); \
251 chmod a-x $(mandir)/$(GXX_CROSS_NAME)$(manext); \
253 rm -f $(mandir)/$(GXX_INSTALL_NAME)$(manext); \
254 $(INSTALL_DATA) $(srcdir)/cp/g++.1 $(mandir)/$(GXX_INSTALL_NAME)$(manext); \
255 chmod a-x $(mandir)/$(GXX_INSTALL_NAME)$(manext); \
260 -rm -rf $(bindir)/$(CXX_INSTALL_NAME)$(exeext)
261 -rm -rf $(bindir)/$(CXX_CROSS_NAME)$(exeext)
262 -rm -rf $(bindir)/$(GXX_INSTALL_NAME)$(exeext)
263 -rm -rf $(bindir)/$(GXX_CROSS_NAME)$(exeext)
264 -rm -rf $(bindir)/$(DEMANGLER_INSTALL_NAME)$(exeext)
265 -rm -rf $(bindir)/$(DEMANGLER_CROSS_NAME)$(exeext)
266 -rm -rf $(mandir)/$(GXX_INSTALL_NAME)$(manext)
267 -rm -rf $(mandir)/$(GXX_CROSS_NAME)$(manext)
270 # A lot of the ancillary files are deleted by the main makefile.
271 # We just have to delete files specific to us.
274 -rm -f cp/*$(objext) $(DEMANGLER_PROG)
276 -rm -f cplib2.txt cplib2.ready
278 -rm -f cp/config.status cp/Makefile
279 -rm -f cp/parse.output
282 c++.maintainer-clean:
283 -rm -f cp/parse.c cp/parse.h
286 # The main makefile has already created stage?/cp.
288 c++.stage1: stage1-start
289 -mv cp/*$(objext) stage1/cp
290 c++.stage2: stage2-start
291 -mv cp/*$(objext) stage2/cp
292 c++.stage3: stage3-start
293 -mv cp/*$(objext) stage3/cp
294 c++.stage4: stage4-start
295 -mv cp/*$(objext) stage4/cp
299 # This target creates the files that can be rebuilt, but go in the
300 # distribution anyway. It then copies the files to the distdir directory.
304 cd cp ; $(MAKE) $(FLAGS_TO_PASS) $(CXX_FLAGS_TO_PASS) parse.c hash.h
306 for file in *[0-9a-zA-Z+]; do \
307 $(LN) $$file ../tmp/cp; \
310 for file in *[0-9a-zA-Z+]; do \
311 ln $$file ../../tmp/cp/inc >/dev/null 2>&1 \
312 || cp $$file ../../tmp/cp/inc; \