1 # Top level -*- makefile -*- fragment for GNU C++.
2 # Copyright (C) 1994, 1995, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
4 # Free Software Foundation, Inc.
6 #This file is part of GCC.
8 #GCC is free software; you can redistribute it and/or modify
9 #it under the terms of the GNU General Public License as published by
10 #the Free Software Foundation; either version 3, or (at your option)
13 #GCC is distributed in the hope that it will be useful,
14 #but WITHOUT ANY WARRANTY; without even the implied warranty of
15 #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 #GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with GCC; see the file COPYING3. If not see
20 # <http://www.gnu.org/licenses/>.
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.cross, foo.start.encap, foo.rest.encap,
26 # foo.install-common, foo.install-man, foo.install-info, foo.install-pdf,
27 # foo.info, foo.dvi, foo.pdf, foo.html, foo.uninstall,
28 # foo.mostlyclean, foo.clean, foo.distclean,
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 # Actual names to use when installing a native compiler.
40 CXX_INSTALL_NAME := $(shell echo c++|sed '$(program_transform_name)')
41 GXX_INSTALL_NAME := $(shell echo g++|sed '$(program_transform_name)')
42 CXX_TARGET_INSTALL_NAME := $(target_noncanonical)-$(shell echo c++|sed '$(program_transform_name)')
43 GXX_TARGET_INSTALL_NAME := $(target_noncanonical)-$(shell echo g++|sed '$(program_transform_name)')
46 # Define the names for selecting c++ in LANGUAGES.
47 # Note that it would be nice to move the dependency on g++
48 # into the C++ rule, but that needs a little bit of work
49 # to do the right thing within all.cross.
52 # Tell GNU make to ignore these if they exist.
56 ALL_CPPFLAGS := $(ALL_CPPFLAGS) $(DRIVER_DEFINES)
58 # Create the compiler driver for g++.
59 GXX_OBJS = $(GCC_OBJS) cp/g++spec.o intl.o prefix.o version.o
60 g++$(exeext): $(GXX_OBJS) $(EXTRA_GCC_OBJS) $(LIBDEPS)
61 $(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ \
62 $(GXX_OBJS) $(EXTRA_GCC_OBJS) $(LIBS)
64 # Create a version of the g++ driver which calls the cross-compiler.
65 g++-cross$(exeext): g++$(exeext)
66 -rm -f g++-cross$(exeext)
67 cp g++$(exeext) g++-cross$(exeext)
69 # The compiler itself.
70 # Shared with C front end:
71 CXX_C_OBJS = attribs.o c-common.o c-format.o c-pragma.o c-semantics.o c-lex.o \
72 c-dump.o $(CXX_TARGET_OBJS) c-pretty-print.o c-opts.o c-pch.o \
73 c-incpath.o cppdefault.o c-ppoutput.o c-cppbuiltin.o prefix.o \
74 c-gimplify.o c-omp.o tree-inline.o
76 # Language-specific object files for C++ and Objective C++.
77 CXX_AND_OBJCXX_OBJS = cp/call.o cp/decl.o cp/expr.o cp/pt.o cp/typeck2.o \
78 cp/class.o cp/decl2.o cp/error.o cp/lex.o cp/parser.o cp/ptree.o cp/rtti.o \
79 cp/typeck.o cp/cvt.o cp/except.o cp/friend.o cp/init.o cp/method.o \
80 cp/search.o cp/semantics.o cp/tree.o cp/repo.o cp/dump.o cp/optimize.o \
81 cp/mangle.o cp/cp-objcp-common.o cp/name-lookup.o cp/cxx-pretty-print.o \
82 cp/cp-gimplify.o tree-mudflap.o $(CXX_C_OBJS)
84 # Language-specific object files for C++.
85 CXX_OBJS = cp/cp-lang.o stub-objc.o $(CXX_AND_OBJCXX_OBJS)
87 c++_OBJS = $(CXX_OBJS) dummy-checksum.o cc1plus-checksum.o cp/g++spec.o
89 # Use strict warnings for this front end.
90 cp-warn = $(STRICT_WARN) $(CXX_COMPAT_WARN)
92 cc1plus-dummy$(exeext): $(CXX_OBJS) dummy-checksum.o $(BACKEND) $(LIBDEPS)
93 $(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ \
94 $(CXX_OBJS) dummy-checksum.o $(BACKEND) $(LIBS) $(GMPLIBS)
96 cc1plus-checksum.c : cc1plus-dummy$(exeext) build/genchecksum$(build_exeext)
97 build/genchecksum$(build_exeext) cc1plus-dummy$(exeext) > $@
99 cc1plus$(exeext): $(CXX_OBJS) cc1plus-checksum.o $(BACKEND) $(LIBDEPS)
100 $(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ \
101 $(CXX_OBJS) cc1plus-checksum.o $(BACKEND) $(LIBS) $(GMPLIBS)
103 # Special build rules.
104 $(srcdir)/cp/cfns.h: $(srcdir)/cp/cfns.gperf
105 gperf -o -C -E -k '1-6,$$' -j1 -D -N 'libc_name_p' -L ANSI-C \
106 $(srcdir)/cp/cfns.gperf > $(srcdir)/cp/cfns.h
111 c++.all.cross: g++-cross$(exeext)
112 c++.start.encap: g++$(exeext)
124 cd $(srcdir)/cp; etags -o TAGS.sub *.c *.h --language=none \
125 --regex='/DEFTREECODE [(]\([A-Z_]+\)/\1/' cp-tree.def; \
126 etags --include TAGS.sub --include ../TAGS.sub
130 c++.srcman: doc/g++.1
131 -cp -p $^ $(srcdir)/doc
133 # 'make check' in gcc/ looks for check-c++, as do all toplevel C++-related
134 # check targets. However, our DejaGNU framework requires 'check-g++' as its
135 # entry point. We feed the former to the latter here.
136 check-c++ : check-g++
137 # List of targets that can use the generic check- rule and its // variant.
138 lang_checks += check-g++
142 # cc1plus is installed elsewhere as part of $(COMPILERS).
144 # Install the driver program as $(target)-g++
145 # and also as either g++ (if native) or $(tooldir)/bin/g++.
146 c++.install-common: installdirs
147 -rm -f $(DESTDIR)$(bindir)/$(GXX_INSTALL_NAME)$(exeext)
148 -$(INSTALL_PROGRAM) g++$(exeext) $(DESTDIR)$(bindir)/$(GXX_INSTALL_NAME)$(exeext)
149 -chmod a+x $(DESTDIR)$(bindir)/$(GXX_INSTALL_NAME)$(exeext)
150 -rm -f $(DESTDIR)$(bindir)/$(CXX_INSTALL_NAME)$(exeext)
151 -( cd $(DESTDIR)$(bindir) && \
152 $(LN) $(GXX_INSTALL_NAME)$(exeext) $(CXX_INSTALL_NAME)$(exeext) )
153 -if [ -f cc1plus$(exeext) ] ; then \
154 if [ -f g++-cross$(exeext) ] ; then \
155 if [ -d $(DESTDIR)$(gcc_tooldir)/bin/. ] ; then \
156 rm -f $(DESTDIR)$(gcc_tooldir)/bin/g++$(exeext); \
157 $(INSTALL_PROGRAM) g++-cross$(exeext) $(DESTDIR)$(gcc_tooldir)/bin/g++$(exeext); \
158 rm -f $(DESTDIR)$(gcc_tooldir)/bin/c++$(exeext); \
159 ( cd $(DESTDIR)$(gcc_tooldir)/bin && \
160 $(LN) g++$(exeext) c++$(exeext) ); \
163 rm -f $(DESTDIR)$(bindir)/$(GXX_TARGET_INSTALL_NAME)$(exeext); \
164 ( cd $(DESTDIR)$(bindir) && \
165 $(LN) $(GXX_INSTALL_NAME)$(exeext) $(GXX_TARGET_INSTALL_NAME)$(exeext) ); \
166 rm -f $(DESTDIR)$(bindir)/$(CXX_TARGET_INSTALL_NAME)$(exeext); \
167 ( cd $(DESTDIR)$(bindir) && \
168 $(LN) $(CXX_INSTALL_NAME)$(exeext) $(CXX_TARGET_INSTALL_NAME)$(exeext) ); \
172 # We can't use links because not everyone supports them, and we can't use
173 # .so because Irix 6.5 doesn't support them. So just copy the manpage.
177 c++.install-man: $(DESTDIR)$(man1dir)/$(GXX_INSTALL_NAME)$(man1ext)
179 $(DESTDIR)$(man1dir)/$(GXX_INSTALL_NAME)$(man1ext): doc/g++.1 installdirs
181 -$(INSTALL_DATA) $< $@
185 -rm -rf $(DESTDIR)$(bindir)/$(CXX_INSTALL_NAME)$(exeext)
186 -rm -rf $(DESTDIR)$(bindir)/$(GXX_INSTALL_NAME)$(exeext)
187 -rm -rf $(DESTDIR)$(man1dir)/$(GXX_INSTALL_NAME)$(man1ext)
190 # A lot of the ancillary files are deleted by the main makefile.
191 # We just have to delete files specific to us.
196 -rm -f cp/*$(coverageexts)
199 -rm -f cp/config.status cp/Makefile
200 c++.maintainer-clean:
203 # The main makefile has already created stage?/cp.
205 c++.stage1: stage1-start
206 -mv cp/*$(objext) stage1/cp
207 c++.stage2: stage2-start
208 -mv cp/*$(objext) stage2/cp
209 c++.stage3: stage3-start
210 -mv cp/*$(objext) stage3/cp
211 c++.stage4: stage4-start
212 -mv cp/*$(objext) stage4/cp
213 c++.stageprofile: stageprofile-start
214 -mv cp/*$(objext) stageprofile/cp
215 c++.stagefeedback: stagefeedback-start
216 -mv cp/*$(objext) stagefeedback/cp