1 # Top level makefile fragment for GNU C++.
2 # Copyright (C) 1994, 1995, 1997, 1998, 1999 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++spec.o: $(srcdir)/cp/g++spec.c
79 $(CC) -c $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) $(srcdir)/cp/g++spec.c
81 $(INTL_TARGETS): $(srcdir)/cp/parse.c
82 $(srcdir)/cp/parse.c: $(srcdir)/cp/parse.y
83 @cp_srcdir=`sed -n 's/^srcdir[ ]*=[ ]*//p' cp/Makefile` && \
84 echo "cd cp && $(MAKE) $$cp_srcdir/parse.c" && \
86 $(MAKE) $(SUBDIR_FLAGS_TO_PASS) $(CXX_FLAGS_TO_PASS) \
89 # Create the compiler driver for g++.
90 GXX_OBJS = gcc.o g++spec.o intl.o prefix.o version.o
91 g++$(exeext): $(GXX_OBJS) $(EXTRA_GCC_OBJS) $(LIBDEPS)
92 $(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ \
93 $(GXX_OBJS) $(EXTRA_GCC_OBJS) $(LIBS)
95 # Create a version of the g++ driver which calls the cross-compiler.
96 g++-cross$(exeext): g++$(exeext)
97 -rm -f g++-cross$(exeext)
98 cp g++$(exeext) g++-cross$(exeext)
100 cxxmain.o: $(srcdir)/../libiberty/cplus-dem.c $(DEMANGLE_H)
102 $(LN_S) $(srcdir)/../libiberty/cplus-dem.c cxxmain.c
103 $(CC) -c -DMAIN $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \
104 -DVERSION=\"$(version)\" cxxmain.c
106 # Apparently OpenVM needs the -o to be at the beginning of the link line.
107 $(DEMANGLER_PROG): cxxmain.o underscore.o $(LIBDEPS)
108 $(CC) -o $@ $(ALL_CFLAGS) $(LDFLAGS) \
109 cxxmain.o underscore.o $(LIBS)
111 CXX_SRCS = $(srcdir)/cp/call.c $(srcdir)/cp/decl2.c \
112 $(srcdir)/cp/except.c $(srcdir)/cp/input.c $(srcdir)/cp/pt.c \
113 $(srcdir)/cp/spew.c $(srcdir)/cp/xref.c $(srcdir)/cp/class.c \
114 $(srcdir)/cp/expr.c $(srcdir)/cp/lex.c \
115 $(srcdir)/cp/ptree.c $(srcdir)/cp/tree.c $(srcdir)/cp/cvt.c \
116 $(srcdir)/cp/errfn.c $(srcdir)/cp/rtti.c $(srcdir)/cp/method.c \
117 $(srcdir)/cp/search.c $(srcdir)/cp/typeck.c $(srcdir)/cp/decl.c \
118 $(srcdir)/cp/error.c $(srcdir)/cp/friend.c $(srcdir)/cp/init.c \
119 $(srcdir)/cp/parse.y $(srcdir)/cp/typeck2.c \
120 $(srcdir)/cp/repo.c $(srcdir)/cp/semantics.c \
123 cc1plus$(exeext): $(P) $(CXX_SRCS) $(LIBDEPS) stamp-objlist c-common.o c-pragma.o \
124 $(srcdir)/cp/cp-tree.h $(srcdir)/cp/cp-tree.def $(srcdir)/cp/gxx.gperf hash.o
125 cd cp; $(MAKE) $(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)
137 # C++ language-support library pieces for libgcc.
138 tinfo.o: cc1plus$(exeext) $(srcdir)/cp/tinfo.cc
139 $(GCC_FOR_TARGET) $(LIBGCC2_CFLAGS) $(CXXFLAGS) $(INCLUDES) \
140 -c $(srcdir)/cp/tinfo.cc
141 tinfo2.o: cc1plus$(exeext) $(srcdir)/cp/tinfo2.cc
142 $(GCC_FOR_TARGET) $(LIBGCC2_CFLAGS) $(CXXFLAGS) $(INCLUDES) \
143 -c $(srcdir)/cp/tinfo2.cc
144 exception.o: cc1plus$(exeext) $(srcdir)/cp/exception.cc
145 $(GCC_FOR_TARGET) $(LIBGCC2_CFLAGS) $(CXXFLAGS) $(INCLUDES) \
146 -c -fexceptions $(srcdir)/cp/exception.cc
147 new.o: cc1plus$(exeext) $(srcdir)/cp/new.cc
148 $(GCC_FOR_TARGET) $(LIBGCC2_CFLAGS) $(CXXFLAGS) $(INCLUDES) \
149 -c $(srcdir)/cp/new.cc
150 opnew.o: cc1plus$(exeext) $(srcdir)/cp/new1.cc
151 $(GCC_FOR_TARGET) $(LIBGCC2_CFLAGS) $(CXXFLAGS) $(INCLUDES) \
152 -c $(srcdir)/cp/new1.cc -DL_op_new -o opnew.o
153 opnewnt.o: cc1plus$(exeext) $(srcdir)/cp/new1.cc
154 $(GCC_FOR_TARGET) $(LIBGCC2_CFLAGS) $(CXXFLAGS) $(INCLUDES) \
155 -c $(srcdir)/cp/new1.cc -DL_op_newnt -o opnewnt.o
156 opvnew.o: cc1plus$(exeext) $(srcdir)/cp/new2.cc
157 $(GCC_FOR_TARGET) $(LIBGCC2_CFLAGS) $(CXXFLAGS) $(INCLUDES) \
158 -c $(srcdir)/cp/new2.cc -DL_op_vnew -o opvnew.o
159 opvnewnt.o: cc1plus$(exeext) $(srcdir)/cp/new2.cc
160 $(GCC_FOR_TARGET) $(LIBGCC2_CFLAGS) $(CXXFLAGS) $(INCLUDES) \
161 -c $(srcdir)/cp/new2.cc -DL_op_vnewnt -o opvnewnt.o
162 opdel.o: cc1plus$(exeext) $(srcdir)/cp/new2.cc
163 $(GCC_FOR_TARGET) $(LIBGCC2_CFLAGS) $(CXXFLAGS) $(INCLUDES) \
164 -c $(srcdir)/cp/new2.cc -DL_op_delete -o opdel.o
165 opdelnt.o: cc1plus$(exeext) $(srcdir)/cp/new2.cc
166 $(GCC_FOR_TARGET) $(LIBGCC2_CFLAGS) $(CXXFLAGS) $(INCLUDES) \
167 -c $(srcdir)/cp/new2.cc -DL_op_delnt -o opdelnt.o
168 opvdel.o: cc1plus$(exeext) $(srcdir)/cp/new2.cc
169 $(GCC_FOR_TARGET) $(LIBGCC2_CFLAGS) $(CXXFLAGS) $(INCLUDES) \
170 -c $(srcdir)/cp/new2.cc -DL_op_vdel -o opvdel.o
171 opvdelnt.o: cc1plus$(exeext) $(srcdir)/cp/new2.cc
172 $(GCC_FOR_TARGET) $(LIBGCC2_CFLAGS) $(CXXFLAGS) $(INCLUDES) \
173 -c $(srcdir)/cp/new2.cc -DL_op_vdelnt -o opvdelnt.o
175 # We want to update cplib2.txt if any of the source files change...
176 cplib2.txt: $(CXX_LIB2SRCS) $(CXX_EXTRA_HEADERS) cplib2.ready
177 case " $(LANGUAGES) " in \
179 echo $(CXX_LIB2FUNCS) > cplib2.new;; \
181 echo "" > cplib2.new;; \
183 mv -f cplib2.new cplib2.txt
185 # Or if it would be different.
186 # Don't try to do write if `.' is not writable;
187 # in that case, we're installing from someone else's directory.
188 # But go ahead and fail if that directory hasn't been properly built.
189 cplib2.ready: $(GCC_PASSES) $(LIBGCC2_DEPS) stmp-int-hdrs
190 @if [ -r cplib2.txt -a -w . ]; then \
191 case " $(LANGUAGES) " in \
193 echo $(CXX_LIB2FUNCS) > cplib2.new;; \
195 echo "" > cplib2.new;; \
197 if cmp -s cplib2.new cplib2.txt; then true; else \
198 touch cplib2.ready; \
203 @if [ -f cplib2.ready ]; then true; else \
204 touch cplib2.ready; \
208 # cc1plus is installed elsewhere as part of $(COMPILERS).
210 # Nothing to do here.
213 # Install the driver program as $(target)-g++
214 # and also as either g++ (if native) or $(tooldir)/bin/g++.
216 -if [ -f cc1plus$(exeext) ] ; then \
217 if [ -f g++-cross$(exeext) ] ; then \
218 rm -f $(bindir)/$(GXX_CROSS_NAME)$(exeext); \
219 $(INSTALL_PROGRAM) g++-cross$(exeext) $(bindir)/$(GXX_CROSS_NAME)$(exeext); \
220 chmod a+x $(bindir)/$(GXX_CROSS_NAME)$(exeext); \
221 rm -f $(bindir)/$(CXX_CROSS_NAME)$(exeext); \
222 $(LN) $(bindir)/$(GXX_CROSS_NAME)$(exeext) $(bindir)/$(CXX_CROSS_NAME)$(exeext); \
224 rm -f $(bindir)/$(GXX_INSTALL_NAME)$(exeext); \
225 $(INSTALL_PROGRAM) g++$(exeext) $(bindir)/$(GXX_INSTALL_NAME)$(exeext); \
226 chmod a+x $(bindir)/$(GXX_INSTALL_NAME)$(exeext); \
227 rm -f $(bindir)/$(CXX_INSTALL_NAME)$(exeext); \
228 $(LN) $(bindir)/$(GXX_INSTALL_NAME)$(exeext) $(bindir)/$(CXX_INSTALL_NAME)$(exeext); \
230 if [ x$(DEMANGLER_PROG) != x ] && [ -x "$(DEMANGLER_PROG)" ]; then \
231 if [ -f g++-cross$(exeext) ] ; then \
232 rm -f $(bindir)/$(DEMANGLER_CROSS_NAME)$(exeext); \
233 $(INSTALL_PROGRAM) $(DEMANGLER_PROG) $(bindir)/$(DEMANGLER_CROSS_NAME)$(exeext); \
234 chmod a+x $(bindir)/$(DEMANGLER_CROSS_NAME)$(exeext); \
236 rm -f $(bindir)/$(DEMANGLER_INSTALL_NAME)$(exeext); \
237 $(INSTALL_PROGRAM) $(DEMANGLER_PROG) $(bindir)/$(DEMANGLER_INSTALL_NAME)$(exeext); \
238 chmod a+x $(bindir)/$(DEMANGLER_INSTALL_NAME)$(exeext); \
245 c++.install-man: $(srcdir)/cp/g++.1
246 -if [ -f cc1plus$(exeext) ] ; then \
247 if [ -f g++-cross$(exeext) ] ; then \
248 rm -f $(man1dir)/$(GXX_CROSS_NAME)$(manext); \
249 $(INSTALL_DATA) $(srcdir)/cp/g++.1 $(man1dir)/$(GXX_CROSS_NAME)$(manext); \
250 chmod a-x $(man1dir)/$(GXX_CROSS_NAME)$(manext); \
252 rm -f $(man1dir)/$(GXX_INSTALL_NAME)$(manext); \
253 $(INSTALL_DATA) $(srcdir)/cp/g++.1 $(man1dir)/$(GXX_INSTALL_NAME)$(manext); \
254 chmod a-x $(man1dir)/$(GXX_INSTALL_NAME)$(manext); \
259 -rm -rf $(bindir)/$(CXX_INSTALL_NAME)$(exeext)
260 -rm -rf $(bindir)/$(CXX_CROSS_NAME)$(exeext)
261 -rm -rf $(bindir)/$(GXX_INSTALL_NAME)$(exeext)
262 -rm -rf $(bindir)/$(GXX_CROSS_NAME)$(exeext)
263 -rm -rf $(bindir)/$(DEMANGLER_INSTALL_NAME)$(exeext)
264 -rm -rf $(bindir)/$(DEMANGLER_CROSS_NAME)$(exeext)
265 -rm -rf $(man1dir)/$(GXX_INSTALL_NAME)$(manext)
266 -rm -rf $(man1dir)/$(GXX_CROSS_NAME)$(manext)
269 # A lot of the ancillary files are deleted by the main makefile.
270 # We just have to delete files specific to us.
273 -rm -f cp/*$(objext) $(DEMANGLER_PROG)
275 -rm -f cplib2.txt cplib2.ready
277 -rm -f cp/config.status cp/Makefile
278 -rm -f cp/parse.output
280 c++.maintainer-clean:
281 -rm -f cp/parse.c cp/parse.h
284 # The main makefile has already created stage?/cp.
286 c++.stage1: stage1-start
287 -mv cp/*$(objext) stage1/cp
288 c++.stage2: stage2-start
289 -mv cp/*$(objext) stage2/cp
290 c++.stage3: stage3-start
291 -mv cp/*$(objext) stage3/cp
292 c++.stage4: stage4-start
293 -mv cp/*$(objext) stage4/cp
297 # This target creates the files that can be rebuilt, but go in the
298 # distribution anyway. It then copies the files to the distdir directory.
302 cd cp ; $(MAKE) $(FLAGS_TO_PASS) $(CXX_FLAGS_TO_PASS) parse.c hash.h
304 for file in *[0-9a-zA-Z+]; do \
305 $(LN) $$file ../tmp/cp; \
308 for file in *[0-9a-zA-Z+]; do \
309 ln $$file ../../tmp/cp/inc >/dev/null 2>&1 \
310 || cp $$file ../../tmp/cp/inc; \