1 # Top level -*- makefile -*- fragment for GNU C++.
2 # Copyright (C) 1994-2015 Free Software Foundation, Inc.
4 #This file is part of GCC.
6 #GCC 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 3, or (at your option)
11 #GCC 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 GCC; see the file COPYING3. If not see
18 # <http://www.gnu.org/licenses/>.
20 # This file provides the language dependent support in the main Makefile.
21 # Each language makefile fragment must provide the following targets:
23 # foo.all.cross, foo.start.encap, foo.rest.encap,
24 # foo.install-common, foo.install-man, foo.install-info, foo.install-pdf,
25 # foo.install-html, foo.info, foo.dvi, foo.pdf, foo.html, foo.uninstall,
26 # foo.mostlyclean, foo.clean, foo.distclean,
27 # foo.maintainer-clean, foo.stage1, foo.stage2, foo.stage3, foo.stage4
29 # where `foo' is the name of the language.
31 # It should also provide rules for:
33 # - making any compiler driver (eg: g++)
34 # - the compiler proper (eg: cc1plus)
35 # - define the names for selecting the language in LANGUAGES.
37 # Actual names to use when installing a native compiler.
38 CXX_INSTALL_NAME := $(shell echo c++|sed '$(program_transform_name)')
39 GXX_INSTALL_NAME := $(shell echo g++|sed '$(program_transform_name)')
40 CXX_TARGET_INSTALL_NAME := $(target_noncanonical)-$(shell echo c++|sed '$(program_transform_name)')
41 GXX_TARGET_INSTALL_NAME := $(target_noncanonical)-$(shell echo g++|sed '$(program_transform_name)')
42 CP_PLUGIN_HEADERS := cp-tree.h cxx-pretty-print.h name-lookup.h type-utils.h
45 # Define the names for selecting c++ in LANGUAGES.
46 # Note that it would be nice to move the dependency on g++
47 # into the C++ rule, but that needs a little bit of work
48 # to do the right thing within all.cross.
51 # Tell GNU make to ignore these if they exist.
54 CFLAGS-cp/g++spec.o += $(DRIVER_DEFINES)
56 # Create the compiler driver for g++.
57 GXX_OBJS = $(GCC_OBJS) cp/g++spec.o
58 xg++$(exeext): $(GXX_OBJS) $(EXTRA_GCC_OBJS) libcommon-target.a $(LIBDEPS)
59 +$(LINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ \
60 $(GXX_OBJS) $(EXTRA_GCC_OBJS) libcommon-target.a \
61 $(EXTRA_GCC_LIBS) $(LIBS)
63 # Create a version of the g++ driver which calls the cross-compiler.
64 g++-cross$(exeext): xg++$(exeext)
65 -rm -f g++-cross$(exeext)
66 cp xg++$(exeext) g++-cross$(exeext)
68 # The compiler itself.
69 # Shared with C front end:
70 CXX_C_OBJS = attribs.o incpath.o \
71 $(C_COMMON_OBJS) $(CXX_TARGET_OBJS)
73 # Language-specific object files for C++ and Objective C++.
74 CXX_AND_OBJCXX_OBJS = cp/call.o cp/decl.o cp/expr.o cp/pt.o cp/typeck2.o \
75 cp/class.o cp/decl2.o cp/error.o cp/lex.o cp/parser.o cp/ptree.o cp/rtti.o \
76 cp/typeck.o cp/cvt.o cp/except.o cp/friend.o cp/init.o cp/method.o \
77 cp/search.o cp/semantics.o cp/tree.o cp/repo.o cp/dump.o cp/optimize.o \
78 cp/mangle.o cp/cp-objcp-common.o cp/name-lookup.o cp/cxx-pretty-print.o \
80 cp/cp-gimplify.o cp/cp-array-notation.o cp/lambda.o \
81 cp/vtable-class-hierarchy.o cp/constexpr.o cp/cp-ubsan.o $(CXX_C_OBJS)
83 # Language-specific object files for C++.
84 CXX_OBJS = cp/cp-lang.o c-family/stub-objc.o $(CXX_AND_OBJCXX_OBJS)
86 c++_OBJS = $(CXX_OBJS) cc1plus-checksum.o cp/g++spec.o
88 # Use strict warnings for this front end.
89 cp-warn = $(STRICT_WARN)
91 # compute checksum over all object files and the options
92 cc1plus-checksum.c : build/genchecksum$(build_exeext) checksum-options \
93 $(CXX_OBJS) $(BACKEND) $(LIBDEPS)
94 build/genchecksum$(build_exeext) $(CXX_OBJS) $(BACKEND) $(LIBDEPS) \
95 checksum-options > cc1plus-checksum.c.tmp && \
96 $(srcdir)/../move-if-change cc1plus-checksum.c.tmp cc1plus-checksum.c
98 cc1plus$(exeext): $(CXX_OBJS) cc1plus-checksum.o $(BACKEND) $(LIBDEPS)
99 +$(LLINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ \
100 $(CXX_OBJS) cc1plus-checksum.o $(BACKEND) $(LIBS) $(BACKENDLIBS)
102 ifeq ($(ENABLE_MAINTAINER_RULES), true)
103 # Special build rule. This is a maintainer rule, that is only
104 # available when GCC is configured with --enable-maintainer-mode. In
105 # other cases, it is not available to avoid triggering rebuilds if a
106 # user has the source checked out with unusual timestamps.
107 $(srcdir)/cp/cfns.h: $(srcdir)/cp/cfns.gperf
109 # We keep the rule so that you can still force a rebuild, even if you
110 # didn't configure GCC with --enable-maintainer-mode, by manually
111 # deleting the $(srcdir)/cp/cfns.h file.
114 gperf -o -C -E -k '1-6,$$' -j1 -D -N 'libc_name_p' -L ANSI-C \
115 $(srcdir)/cp/cfns.gperf --output-file $(srcdir)/cp/cfns.h
120 c++.all.cross: g++-cross$(exeext)
121 c++.start.encap: xg++$(exeext)
134 cd $(srcdir)/cp; etags -o TAGS.sub *.c *.h --language=none \
135 --regex='/DEFTREECODE [(]\([A-Z_]+\)/\1/' cp-tree.def; \
136 etags --include TAGS.sub --include ../TAGS.sub
140 c++.srcman: doc/g++.1
141 -cp -p $^ $(srcdir)/doc
143 # 'make check' in gcc/ looks for check-c++, as do all toplevel C++-related
144 # check targets. However, our DejaGNU framework requires 'check-g++' as its
145 # entry point. We feed the former to the latter here.
146 check-c++ : check-g++
147 # Run the testsute in C++0x mode.
149 @echo Normal 'make check' now runs the testsuite in C++11 mode as well as C++98.
150 # Run the testsuite with garbage collection at every opportunity.
152 $(MAKE) RUNTESTFLAGS="$(RUNTESTFLAGS) --extra_opts,--param,ggc-min-heapsize=0,--param,ggc-min-expand=0" \
153 TESTSUITEDIR="$(TESTSUITEDIR).gc" check-g++
154 check-c++-subtargets : check-g++-subtargets
155 # List of targets that can use the generic check- rule and its // variant.
156 lang_checks += check-g++
157 lang_checks_parallelized += check-g++
158 # For description see comment above check_gcc_parallelize in gcc/Makefile.in.
159 check_g++_parallelize = 10000
162 # cc1plus is installed elsewhere as part of $(COMPILERS).
164 # Install the driver program as $(target)-g++ and $(target)-c++, and
165 # also as g++ and c++ if native.
166 c++.install-common: installdirs
167 -if test "$(enable_as_accelerator)" != "yes" ; then \
168 rm -f $(DESTDIR)$(bindir)/$(GXX_INSTALL_NAME)$(exeext); \
169 $(INSTALL_PROGRAM) xg++$(exeext) $(DESTDIR)$(bindir)/$(GXX_INSTALL_NAME)$(exeext); \
170 chmod a+x $(DESTDIR)$(bindir)/$(GXX_INSTALL_NAME)$(exeext); \
171 rm -f $(DESTDIR)$(bindir)/$(CXX_INSTALL_NAME)$(exeext); \
172 ( cd $(DESTDIR)$(bindir) && \
173 $(LN) $(GXX_INSTALL_NAME)$(exeext) $(CXX_INSTALL_NAME)$(exeext) ); \
174 if [ -f cc1plus$(exeext) ] ; then \
175 if [ ! -f g++-cross$(exeext) ] ; then \
176 rm -f $(DESTDIR)$(bindir)/$(GXX_TARGET_INSTALL_NAME)$(exeext); \
177 ( cd $(DESTDIR)$(bindir) && \
178 $(LN) $(GXX_INSTALL_NAME)$(exeext) $(GXX_TARGET_INSTALL_NAME)$(exeext) ); \
179 rm -f $(DESTDIR)$(bindir)/$(CXX_TARGET_INSTALL_NAME)$(exeext); \
180 ( cd $(DESTDIR)$(bindir) && \
181 $(LN) $(CXX_INSTALL_NAME)$(exeext) $(CXX_TARGET_INSTALL_NAME)$(exeext) ); \
186 # We can't use links because not everyone supports them. So just copy the
191 c++.install-man: $(DESTDIR)$(man1dir)/$(GXX_INSTALL_NAME)$(man1ext)
193 $(DESTDIR)$(man1dir)/$(GXX_INSTALL_NAME)$(man1ext): doc/g++.1 installdirs
195 -$(INSTALL_DATA) $< $@
198 c++.install-plugin: installdirs
199 # We keep the directory structure for files in config and .def files. All
200 # other files are flattened to a single directory.
201 headers="$(CP_PLUGIN_HEADERS)"; \
202 for file in $$headers; do \
203 path=$(srcdir)/cp/$$file; \
204 dest=$(plugin_includedir)/cp/$$file; \
205 echo $(INSTALL_DATA) $$path $(DESTDIR)$$dest; \
206 dir=`dirname $$dest`; \
207 $(mkinstalldirs) $(DESTDIR)$$dir; \
208 $(INSTALL_DATA) $$path $(DESTDIR)$$dest; \
212 -rm -rf $(DESTDIR)$(bindir)/$(CXX_INSTALL_NAME)$(exeext)
213 -rm -rf $(DESTDIR)$(bindir)/$(GXX_INSTALL_NAME)$(exeext)
214 -rm -rf $(DESTDIR)$(man1dir)/$(GXX_INSTALL_NAME)$(man1ext)
217 # A lot of the ancillary files are deleted by the main makefile.
218 # We just have to delete files specific to us.
223 -rm -f cp/*$(coverageexts)
226 -rm -f cp/config.status cp/Makefile
228 c++.maintainer-clean:
231 # The main makefile has already created stage?/cp.
233 c++.stage1: stage1-start
234 -mv cp/*$(objext) stage1/cp
235 c++.stage2: stage2-start
236 -mv cp/*$(objext) stage2/cp
237 c++.stage3: stage3-start
238 -mv cp/*$(objext) stage3/cp
239 c++.stage4: stage4-start
240 -mv cp/*$(objext) stage4/cp
241 c++.stageprofile: stageprofile-start
242 -mv cp/*$(objext) stageprofile/cp
243 c++.stagefeedback: stagefeedback-start
244 -mv cp/*$(objext) stagefeedback/cp