1 # Top level makefile fragment for GNU C++.
2 # Copyright (C) 1994, 1995, 1997, 1998, 1999, 2000
3 # Free Software Foundation, Inc.
5 #This file is part of GNU CC.
7 #GNU CC is free software; you can redistribute it and/or modify
8 #it under the terms of the GNU General Public License as published by
9 #the Free Software Foundation; either version 2, or (at your option)
12 #GNU CC is distributed in the hope that it will be useful,
13 #but WITHOUT ANY WARRANTY; without even the implied warranty of
14 #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 #GNU General Public License for more details.
17 #You should have received a copy of the GNU General Public License
18 #along with GNU CC; see the file COPYING. If not, write to
19 #the Free Software Foundation, 59 Temple Place - Suite 330,
20 #Boston, MA 02111-1307, USA.
22 # This file provides the language dependent support in the main Makefile.
23 # Each language makefile fragment must provide the following targets:
25 # foo.all.build, foo.all.cross, foo.start.encap, foo.rest.encap,
27 # foo.install-normal, foo.install-common, foo.install-info, foo.install-man,
28 # foo.uninstall, foo.distdir,
29 # foo.mostlyclean, foo.clean, foo.distclean, foo.extraclean,
30 # foo.maintainer-clean, foo.stage1, foo.stage2, foo.stage3, foo.stage4
32 # where `foo' is the name of the language.
34 # It should also provide rules for:
36 # - making any compiler driver (eg: g++)
37 # - the compiler proper (eg: cc1plus)
38 # - define the names for selecting the language in LANGUAGES.
40 # Extra flags to pass to recursive makes.
42 "CXX_FOR_BUILD=$(CXX_FOR_BUILD)" \
43 "CXXFLAGS=$(CXXFLAGS)" \
44 "CXX_FOR_TARGET=$(CXX_FOR_TARGET)"
46 # Actual names to use when installing a native compiler.
47 CXX_INSTALL_NAME = `t='$(program_transform_name)'; echo c++ | sed $$t`
48 GXX_INSTALL_NAME = `t='$(program_transform_name)'; echo g++ | sed $$t`
49 DEMANGLER_INSTALL_NAME = `t='$(program_transform_name)'; echo c++filt | sed $$t`
51 # Actual names to use when installing a cross-compiler.
52 CXX_CROSS_NAME = `t='$(program_transform_cross_name)'; echo c++ | sed $$t`
53 GXX_CROSS_NAME = `t='$(program_transform_cross_name)'; echo g++ | sed $$t`
54 DEMANGLER_CROSS_NAME = `t='$(program_transform_cross_name)'; echo c++filt | sed $$t`
56 # The name to use for the demangler program.
57 DEMANGLER_PROG = c++filt$(exeext)
59 # Extra code to include in libgcc2.
60 CXX_LIB2FUNCS = tinfo.o tinfo2.o new.o opnew.o opnewnt.o opvnew.o opvnewnt.o \
61 opdel.o opdelnt.o opvdel.o opvdelnt.o exception.o vec.o
62 CXX_LIB2SRCS = $(srcdir)/cp/new.cc $(srcdir)/cp/new1.cc $(srcdir)/cp/new2.cc \
63 $(srcdir)/cp/exception.cc $(srcdir)/cp/tinfo.cc \
64 $(srcdir)/cp/tinfo2.cc $(srcdir)/cp/tinfo.h
66 # Define the names for selecting c++ in LANGUAGES.
67 # Note that it would be nice to move the dependency on g++
68 # into the C++ rule, but that needs a little bit of work
69 # to do the right thing within all.cross.
70 C++ c++: cc1plus$(exeext)
72 # Tell GNU make to ignore these if they exist.
75 g++spec.o: $(srcdir)/cp/g++spec.c system.h $(GCC_H)
76 $(CC) -c $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) $(srcdir)/cp/g++spec.c
78 $(INTL_TARGETS): $(srcdir)/cp/parse.c
79 $(srcdir)/cp/parse.c: $(srcdir)/cp/parse.y
80 @cp_srcdir=`sed -n 's/^srcdir[ ]*=[ ]*//p' cp/Makefile` && \
81 echo "cd cp && $(MAKE) $$cp_srcdir/parse.c" && \
83 $(MAKE) $(LANG_FLAGS_TO_PASS) $(CXX_FLAGS_TO_PASS) \
86 # Create the compiler driver for g++.
87 GXX_OBJS = gcc.o g++spec.o intl.o prefix.o version.o
88 g++$(exeext): $(GXX_OBJS) $(EXTRA_GCC_OBJS) $(LIBDEPS)
89 $(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ \
90 $(GXX_OBJS) $(EXTRA_GCC_OBJS) $(LIBS)
92 # Create a version of the g++ driver which calls the cross-compiler.
93 g++-cross$(exeext): g++$(exeext)
94 -rm -f g++-cross$(exeext)
95 cp g++$(exeext) g++-cross$(exeext)
97 cxxmain.o: $(srcdir)/../libiberty/cplus-dem.c $(DEMANGLE_H)
99 $(LN_S) $(srcdir)/../libiberty/cplus-dem.c cxxmain.c
100 $(CC) -c -DMAIN $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \
101 -DVERSION=\"$(version)\" cxxmain.c
103 # Apparently OpenVM needs the -o to be at the beginning of the link line.
104 $(DEMANGLER_PROG): cxxmain.o underscore.o $(LIBDEPS)
105 $(CC) -o $@ $(ALL_CFLAGS) $(LDFLAGS) \
106 cxxmain.o underscore.o $(LIBS)
108 CXX_SRCS = $(srcdir)/cp/call.c $(srcdir)/cp/class.c $(srcdir)/cp/cp-tree.def \
109 $(srcdir)/c-common.def \
110 $(srcdir)/cp/cp-tree.h $(srcdir)/cp/cvt.c $(srcdir)/cp/decl.c \
111 $(srcdir)/cp/decl.h $(srcdir)/cp/decl2.c $(srcdir)/cp/dump.c \
112 $(srcdir)/cp/errfn.c $(srcdir)/cp/error.c $(srcdir)/cp/except.c \
113 $(srcdir)/cp/expr.c $(srcdir)/cp/friend.c $(srcdir)/cp/init.c \
114 $(srcdir)/cp/lex.c $(srcdir)/cp/lex.h \
115 $(srcdir)/cp/mangle.c $(srcdir)/cp/method.c $(srcdir)/cp/optimize.c \
116 $(srcdir)/cp/parse.y $(srcdir)/cp/pt.c $(srcdir)/cp/ptree.c \
117 $(srcdir)/cp/repo.c $(srcdir)/cp/rtti.c $(srcdir)/cp/search.c \
118 $(srcdir)/cp/semantics.c $(srcdir)/cp/spew.c $(srcdir)/cp/tree.c \
119 $(srcdir)/cp/typeck.c $(srcdir)/cp/typeck2.c $(srcdir)/cp/xref.c
121 cc1plus$(exeext): $(P) $(CXX_SRCS) $(LIBDEPS) $(BACKEND) c-common.o \
122 c-pragma.o c-semantics.o c-lex.o $(srcdir)/cp/cp-tree.h $(srcdir)/cp/cp-tree.def \
123 $(srcdir)/c-common.def $(srcdir)/cp/cfns.gperf hash.o \
124 $(srcdir)/cp/operators.def
125 cd cp; $(MAKE) $(LANG_FLAGS_TO_PASS) $(CXX_FLAGS_TO_PASS) ../cc1plus$(exeext)
129 c++.all.build: g++$(exeext)
130 c++.all.cross: g++-cross$(exeext) $(DEMANGLER_PROG)
131 c++.start.encap: g++$(exeext)
132 c++.rest.encap: $(DEMANGLER_PROG)
138 # cc1plus is installed elsewhere as part of $(COMPILERS).
140 # Nothing to do here.
143 # Install the driver program as $(target)-g++
144 # and also as either g++ (if native) or $(tooldir)/bin/g++.
146 -if [ -f cc1plus$(exeext) ] ; then \
147 if [ -f g++-cross$(exeext) ] ; then \
148 rm -f $(bindir)/$(GXX_CROSS_NAME)$(exeext); \
149 $(INSTALL_PROGRAM) g++-cross$(exeext) $(bindir)/$(GXX_CROSS_NAME)$(exeext); \
150 chmod a+x $(bindir)/$(GXX_CROSS_NAME)$(exeext); \
151 rm -f $(bindir)/$(CXX_CROSS_NAME)$(exeext); \
152 $(LN) $(bindir)/$(GXX_CROSS_NAME)$(exeext) $(bindir)/$(CXX_CROSS_NAME)$(exeext); \
153 if [ -d $(gcc_tooldir)/bin/. ] ; then \
154 rm -f $(gcc_tooldir)/bin/g++$(exeext); \
155 $(INSTALL_PROGRAM) g++-cross$(exeext) $(gcc_tooldir)/bin/g++$(exeext); \
156 rm -f $(gcc_tooldir)/bin/c++$(exeext); \
157 $(LN) $(gcc_tooldir)/bin/g++$(exeext) $(gcc_tooldir)/bin/c++$(exeext); \
160 rm -f $(bindir)/$(GXX_INSTALL_NAME)$(exeext); \
161 $(INSTALL_PROGRAM) g++$(exeext) $(bindir)/$(GXX_INSTALL_NAME)$(exeext); \
162 chmod a+x $(bindir)/$(GXX_INSTALL_NAME)$(exeext); \
163 rm -f $(bindir)/$(CXX_INSTALL_NAME)$(exeext); \
164 $(LN) $(bindir)/$(GXX_INSTALL_NAME)$(exeext) $(bindir)/$(CXX_INSTALL_NAME)$(exeext); \
165 rm -f $(bindir)/$(target_alias)-g++$(exeext); \
166 $(LN) $(bindir)/$(GXX_INSTALL_NAME)$(exeext) $(bindir)/$(target_alias)-g++$(exeext); \
167 rm -f $(bindir)/$(target_alias)-c++$(exeext); \
168 $(LN) $(bindir)/$(CXX_INSTALL_NAME)$(exeext) $(bindir)/$(target_alias)-c++$(exeext); \
170 if [ x$(DEMANGLER_PROG) != x ] && [ -x "$(DEMANGLER_PROG)" ]; then \
171 if [ -f g++-cross$(exeext) ] ; then \
172 rm -f $(bindir)/$(DEMANGLER_CROSS_NAME)$(exeext); \
173 $(INSTALL_PROGRAM) $(DEMANGLER_PROG) $(bindir)/$(DEMANGLER_CROSS_NAME)$(exeext); \
174 chmod a+x $(bindir)/$(DEMANGLER_CROSS_NAME)$(exeext); \
176 rm -f $(bindir)/$(DEMANGLER_INSTALL_NAME)$(exeext); \
177 $(INSTALL_PROGRAM) $(DEMANGLER_PROG) $(bindir)/$(DEMANGLER_INSTALL_NAME)$(exeext); \
178 chmod a+x $(bindir)/$(DEMANGLER_INSTALL_NAME)$(exeext); \
185 c++.install-man: $(srcdir)/cp/g++.1
186 -if [ -f cc1plus$(exeext) ] ; then \
187 if [ -f g++-cross$(exeext) ] ; then \
188 rm -f $(man1dir)/$(GXX_CROSS_NAME)$(manext); \
189 $(INSTALL_DATA) $(srcdir)/cp/g++.1 $(man1dir)/$(GXX_CROSS_NAME)$(manext); \
190 chmod a-x $(man1dir)/$(GXX_CROSS_NAME)$(manext); \
192 rm -f $(man1dir)/$(GXX_INSTALL_NAME)$(manext); \
193 $(INSTALL_DATA) $(srcdir)/cp/g++.1 $(man1dir)/$(GXX_INSTALL_NAME)$(manext); \
194 chmod a-x $(man1dir)/$(GXX_INSTALL_NAME)$(manext); \
199 -rm -rf $(bindir)/$(CXX_INSTALL_NAME)$(exeext)
200 -rm -rf $(bindir)/$(CXX_CROSS_NAME)$(exeext)
201 -rm -rf $(bindir)/$(GXX_INSTALL_NAME)$(exeext)
202 -rm -rf $(bindir)/$(GXX_CROSS_NAME)$(exeext)
203 -rm -rf $(bindir)/$(DEMANGLER_INSTALL_NAME)$(exeext)
204 -rm -rf $(bindir)/$(DEMANGLER_CROSS_NAME)$(exeext)
205 -rm -rf $(man1dir)/$(GXX_INSTALL_NAME)$(manext)
206 -rm -rf $(man1dir)/$(GXX_CROSS_NAME)$(manext)
209 # A lot of the ancillary files are deleted by the main makefile.
210 # We just have to delete files specific to us.
213 -rm -f cp/*$(objext) $(DEMANGLER_PROG)
216 -rm -f cp/config.status cp/Makefile
217 -rm -f cp/parse.output
219 c++.maintainer-clean:
220 -rm -f cp/parse.c cp/parse.h
223 # The main makefile has already created stage?/cp.
225 c++.stage1: stage1-start
226 -mv cp/*$(objext) stage1/cp
227 c++.stage2: stage2-start
228 -mv cp/*$(objext) stage2/cp
229 c++.stage3: stage3-start
230 -mv cp/*$(objext) stage3/cp
231 c++.stage4: stage4-start
232 -mv cp/*$(objext) stage4/cp
236 # This target creates the files that can be rebuilt, but go in the
237 # distribution anyway. It then copies the files to the distdir directory.
241 cd cp ; $(MAKE) $(LANG_FLAGS_TO_PASS) $(CXX_FLAGS_TO_PASS) parse.c hash.h
243 for file in *[0-9a-zA-Z+]; do \
244 $(LN) $$file ../tmp/cp; \
247 for file in *[0-9a-zA-Z+]; do \
248 ln $$file ../../tmp/cp/inc >/dev/null 2>&1 \
249 || cp $$file ../../tmp/cp/inc; \