1 # Top level makefile fragment for GNU C++.
2 # Copyright (C) 1994, 1995 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`
49 # Actual names to use when installing a cross-compiler.
50 CXX_CROSS_NAME = `t='$(program_transform_cross_name)'; echo c++ | sed $$t`
51 GXX_CROSS_NAME = `t='$(program_transform_cross_name)'; echo g++ | sed $$t`
53 # The name to use for the demangler program.
54 DEMANGLER_PROG = c++filt
56 # Extra headers to install.
57 CXX_EXTRA_HEADERS = $(srcdir)/cp/inc/typeinfo $(srcdir)/cp/inc/exception \
58 $(srcdir)/cp/inc/new $(srcdir)/cp/inc/new.h
60 # Extra code to include in libgcc2.
61 CXX_LIB2FUNCS = tinfo.o tinfo2.o new.o exception.o
62 CXX_LIB2SRCS = $(srcdir)/cp/new.cc $(srcdir)/cp/exception.cc \
63 $(srcdir)/cp/tinfo.cc $(srcdir)/cp/tinfo2.cc $(srcdir)/cp/tinfo.h
65 # Define the names for selecting c++ in LANGUAGES.
66 # Note that it would be nice to move the dependency on g++
67 # into the C++ rule, but that needs a little bit of work
68 # to do the right thing within all.cross.
71 # Tell GNU make to ignore these if they exist.
74 g++.c: $(srcdir)/gcc.c
76 ln -s $(srcdir)/gcc.c $@ || cp $(srcdir)/gcc.c $@
78 g++spec.o: $(srcdir)/cp/g++spec.c
79 $(CC) -c $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) $<
81 # N.B.: This is a copy of the gcc.o rule, with -DLANG_SPECIFIC_DRIVER added.
82 # It'd be nice if we could find an easier way to do this---rather than have
83 # to track changes to the toplevel gcc Makefile as well.
84 # We depend on g++.c last, to make it obvious where it came from.
85 g++.o: $(CONFIG_H) multilib.h config.status $(lang_specs_files) g++.c
86 $(CC) $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \
88 -DLANG_SPECIFIC_DRIVER \
91 # Create the compiler driver for g++.
92 g++$(exeext): g++.o g++spec.o version.o choose-temp.o pexecute.o $(LIBDEPS) $(EXTRA_GCC_OBJS)
93 $(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ g++.o g++spec.o version.o \
94 choose-temp.o pexecute.o $(EXTRA_GCC_OBJS) $(LIBS)
96 # Create a version of the g++ driver which calls the cross-compiler.
97 g++-cross$(exeext): g++$(exeext)
98 -rm -f g++-cross$(exeext)
99 cp g++$(exeext) g++-cross$(exeext)
101 cxxmain.o: cplus-dem.c demangle.h
103 ln -s $(srcdir)/cplus-dem.c cxxmain.c > /dev/null 2>&1 \
104 || cp $(srcdir)/cplus-dem.c cxxmain.c
105 $(CC) -c -DMAIN $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \
106 -DVERSION=\"$(version)\" cxxmain.c
109 $(DEMANGLER_PROG): cxxmain.o underscore.o getopt.o getopt1.o $(LIBDEPS)
110 $(CC) $(ALL_CFLAGS) $(LDFLAGS) $(LIBS) -o $@ \
111 cxxmain.o underscore.o getopt.o getopt1.o
113 CXX_SRCS = $(srcdir)/cp/call.c $(srcdir)/cp/decl2.c \
114 $(srcdir)/cp/except.c $(srcdir)/cp/input.c $(srcdir)/cp/pt.c \
115 $(srcdir)/cp/spew.c $(srcdir)/cp/xref.c $(srcdir)/cp/class.c \
116 $(srcdir)/cp/expr.c $(srcdir)/cp/lex.c \
117 $(srcdir)/cp/ptree.c $(srcdir)/cp/tree.c $(srcdir)/cp/cvt.c \
118 $(srcdir)/cp/errfn.c $(srcdir)/cp/rtti.c $(srcdir)/cp/method.c \
119 $(srcdir)/cp/search.c $(srcdir)/cp/typeck.c $(srcdir)/cp/decl.c \
120 $(srcdir)/cp/error.c $(srcdir)/cp/init.c $(srcdir)/cp/parse.y \
121 $(srcdir)/cp/sig.c $(srcdir)/cp/typeck2.c $(srcdir)/cp/repo.c
123 cc1plus: $(P) $(CXX_SRCS) $(LIBDEPS) stamp-objlist c-common.o c-pragma.o
124 cd cp; $(MAKE) $(FLAGS_TO_PASS) $(CXX_FLAGS_TO_PASS) ../cc1plus
128 c++.all.build: g++ $(DEMANGLER_PROG)
129 c++.all.cross: g++-cross $(DEMANGLER_PROG)
131 c++.rest.encap: $(DEMANGLER_PROG)
136 # C++ language-support library pieces for libgcc.
137 tinfo.o: cc1plus $(srcdir)/cp/tinfo.cc
138 $(GCC_FOR_TARGET) $(LIBGCC2_CFLAGS) $(INCLUDES) \
139 -c $(srcdir)/cp/tinfo.cc
140 tinfo2.o: cc1plus $(srcdir)/cp/tinfo2.cc
141 $(GCC_FOR_TARGET) $(LIBGCC2_CFLAGS) $(INCLUDES) \
142 -c $(srcdir)/cp/tinfo2.cc
143 exception.o: cc1plus $(srcdir)/cp/exception.cc
144 $(GCC_FOR_TARGET) $(LIBGCC2_CFLAGS) $(INCLUDES) \
145 -c -O0 -fexceptions $(srcdir)/cp/exception.cc
146 new.o: cc1plus $(srcdir)/cp/new.cc
147 $(GCC_FOR_TARGET) $(LIBGCC2_CFLAGS) $(INCLUDES) \
148 -c $(srcdir)/cp/new.cc
150 # We want to update cplib2.txt if any of the source files change...
151 cplib2.txt: $(CXX_LIB2SRCS) $(CXX_EXTRA_HEADERS) cplib2.ready
152 if [ -f cc1plus ]; then \
153 echo $(CXX_LIB2FUNCS) > cplib2.new; \
155 echo "" > cplib2.new; \
157 mv -f cplib2.new cplib2.txt
159 # Or if it would be different.
160 cplib2.ready: $(GCC_PASSES) $(LIBGCC2_DEPS) stmp-int-hdrs
161 @if [ -r cplib2.txt ]; then \
162 if [ -f cc1plus ]; then \
163 echo $(CXX_LIB2FUNCS) > cplib2.new; \
165 echo "" > cplib2.new; \
167 if cmp -s cplib2.new cplib2.txt; then true; else \
168 touch cplib2.ready; \
173 @if [ -f cplib2.ready ]; then true; else \
174 touch cplib2.ready; \
178 # cc1plus is installed elsewhere as part of $(COMPILERS).
180 # Nothing to do here.
183 # Install the driver program as $(target)-g++
184 # and also as either g++ (if native) or $(tooldir)/bin/g++.
186 -if [ -f cc1plus$(exeext) ] ; then \
187 if [ -f g++-cross$(exeext) ] ; then \
188 rm -f $(bindir)/$(GXX_CROSS_NAME)$(exeext); \
189 $(INSTALL_PROGRAM) g++-cross$(exeext) $(bindir)/$(GXX_CROSS_NAME)$(exeext); \
190 chmod a+x $(bindir)/$(GXX_CROSS_NAME)$(exeext); \
191 rm -f $(bindir)/$(CXX_CROSS_NAME)$(exeext); \
192 ln $(bindir)/$(GXX_CROSS_NAME)$(exeext) $(bindir)/$(CXX_CROSS_NAME)$(exeext) \
194 || cp $(bindir)/$(GXX_CROSS_NAME)$(exeext) $(bindir)/$(CXX_CROSS_NAME)$(exeext) ; \
196 rm -f $(bindir)/$(GXX_INSTALL_NAME)$(exeext); \
197 $(INSTALL_PROGRAM) g++$(exeext) $(bindir)/$(GXX_INSTALL_NAME)$(exeext); \
198 chmod a+x $(bindir)/$(GXX_INSTALL_NAME)$(exeext); \
199 rm -f $(bindir)/$(CXX_INSTALL_NAME)$(exeext); \
200 ln $(bindir)/$(GXX_INSTALL_NAME)$(exeext) $(bindir)/$(CXX_INSTALL_NAME)$(exeext) \
202 || cp $(bindir)/$(GXX_INSTALL_NAME)$(exeext) $(bindir)/$(CXX_INSTALL_NAME)$(exeext) ; \
208 c++.install-man: $(srcdir)/cp/g++.1
209 -if [ -f cc1plus$(exeext) ] ; then \
210 if [ -f g++-cross$(exeext) ] ; then \
211 rm -f $(mandir)/$(GXX_CROSS_NAME)$(manext); \
212 $(INSTALL_DATA) $(srcdir)/cp/g++.1 $(mandir)/$(GXX_CROSS_NAME)$(manext); \
213 chmod a-x $(mandir)/$(GXX_CROSS_NAME)$(manext); \
215 rm -f $(mandir)/$(GXX_INSTALL_NAME)$(manext); \
216 $(INSTALL_DATA) $(srcdir)/cp/g++.1 $(mandir)/$(GXX_INSTALL_NAME)$(manext); \
217 chmod a-x $(mandir)/$(GXX_INSTALL_NAME)$(manext); \
222 -rm -rf $(bindir)/$(CXX_INSTALL_NAME)$(exeext)
223 -rm -rf $(bindir)/$(CXX_CROSS_NAME)$(exeext)
224 -rm -rf $(bindir)/$(GXX_INSTALL_NAME)$(exeext)
225 -rm -rf $(bindir)/$(GXX_CROSS_NAME)$(exeext)
226 -rm -rf $(mandir)/$(GXX_INSTALL_NAME)$(manext)
227 -rm -rf $(mandir)/$(GXX_CROSS_NAME)$(manext)
230 # A lot of the ancillary files are deleted by the main makefile.
231 # We just have to delete files specific to us.
234 -rm -f cp/*$(objext) $(DEMANGLER_PROG)
236 -rm -f cplib2.txt cplib2.ready
238 -rm -f cp/config.status cp/Makefile
239 -rm -f cp/parse.output
241 c++.maintainer-clean:
242 -rm -f cp/parse.c cp/parse.h
245 # The main makefile has already created stage?/cp.
247 c++.stage1: stage1-start
248 -mv cp/*$(objext) stage1/cp
249 c++.stage2: stage2-start
250 -mv cp/*$(objext) stage2/cp
251 c++.stage3: stage3-start
252 -mv cp/*$(objext) stage3/cp
253 c++.stage4: stage4-start
254 -mv cp/*$(objext) stage4/cp
258 # This target creates the files that can be rebuilt, but go in the
259 # distribution anyway. It then copies the files to the distdir directory.
262 cd cp ; $(MAKE) $(FLAGS_TO_PASS) $(CXX_FLAGS_TO_PASS) parse.c hash.h
264 for file in *[0-9a-zA-Z+]; do \
265 ln $$file ../tmp/cp >/dev/null 2>&1 || cp $$file ../tmp/cp; \