1 # Top level -*- makefile -*- fragment for GNU C++.
2 # Copyright (C) 1994-2018 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 operators.def
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 = \
75 cp/call.o cp/class.o cp/constexpr.o cp/constraint.o \
77 cp/cp-objcp-common.o cp/cp-ubsan.o \
78 cp/cvt.o cp/cxx-pretty-print.o \
79 cp/decl.o cp/decl2.o cp/dump.o \
80 cp/error.o cp/except.o cp/expr.o \
81 cp/friend.o cp/init.o \
82 cp/lambda.o cp/lex.o cp/logic.o \
83 cp/mangle.o cp/method.o \
84 cp/name-lookup.o cp/optimize.o \
85 cp/parser.o cp/pt.o cp/ptree.o \
87 cp/search.o cp/semantics.o \
88 cp/tree.o cp/typeck.o cp/typeck2.o \
89 cp/vtable-class-hierarchy.o $(CXX_C_OBJS)
91 ifeq ($(if $(wildcard ../stage_current),$(shell cat \
92 ../stage_current)),stageautofeedback)
93 $(CXX_AND_OBJCXX_OBJS): CFLAGS += -fauto-profile=cc1plus.fda
94 $(CXX_AND_OBJCXX_OBJS): cc1plus.fda
97 # Language-specific object files for C++.
98 CXX_OBJS = cp/cp-lang.o c-family/stub-objc.o $(CXX_AND_OBJCXX_OBJS)
100 c++_OBJS = $(CXX_OBJS) cc1plus-checksum.o cp/g++spec.o
102 # Use strict warnings for this front end.
103 cp-warn = $(STRICT_WARN)
105 # compute checksum over all object files and the options
106 # re-use the checksum from the prev-final stage so it passes
107 # the bootstrap comparison and allows comparing of the cc1 binary
108 cc1plus-checksum.c : build/genchecksum$(build_exeext) checksum-options \
109 $(CXX_OBJS) $(BACKEND) $(LIBDEPS)
110 if [ -f ../stage_final ] \
111 && cmp -s ../stage_current ../stage_final; then \
112 cp ../prev-gcc/cc1plus-checksum.c cc1plus-checksum.c; \
114 build/genchecksum$(build_exeext) $(CXX_OBJS) $(BACKEND) $(LIBDEPS) \
115 checksum-options > cc1plus-checksum.c.tmp && \
116 $(srcdir)/../move-if-change cc1plus-checksum.c.tmp cc1plus-checksum.c; \
119 cc1plus$(exeext): $(CXX_OBJS) cc1plus-checksum.o $(BACKEND) $(LIBDEPS)
120 +$(LLINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ \
121 $(CXX_OBJS) cc1plus-checksum.o $(BACKEND) $(LIBS) $(BACKENDLIBS)
123 ifeq ($(ENABLE_MAINTAINER_RULES), true)
124 # Special build rule. This is a maintainer rule, that is only
125 # available when GCC is configured with --enable-maintainer-mode. In
126 # other cases, it is not available to avoid triggering rebuilds if a
127 # user has the source checked out with unusual timestamps.
128 $(srcdir)/cp/cfns.h: $(srcdir)/cp/cfns.gperf
130 # We keep the rule so that you can still force a rebuild, even if you
131 # didn't configure GCC with --enable-maintainer-mode, by manually
132 # deleting the $(srcdir)/cp/cfns.h file.
135 gperf -o -C -E -k '1-6,$$' -j1 -D -N 'libc_name_p' -L C++ \
136 $(srcdir)/cp/cfns.gperf --output-file $(srcdir)/cp/cfns.h
138 cc1plus.fda: ../stage1-gcc/cc1plus$(exeext) ../prev-gcc/$(PERF_DATA)
139 $(CREATE_GCOV) -binary ../stage1-gcc/cc1plus$(exeext) -gcov cc1plus.fda -profile ../prev-gcc/$(PERF_DATA) -gcov_version 1
144 c++.all.cross: g++-cross$(exeext)
145 c++.start.encap: xg++$(exeext)
158 cd $(srcdir)/cp; etags -o TAGS.sub *.c *.cc *.h --language=none \
159 --regex='/DEFTREECODE [(]\([A-Z_]+\)/\1/' cp-tree.def; \
160 etags --include TAGS.sub --include ../TAGS.sub
164 c++.srcman: doc/g++.1
165 -cp -p $^ $(srcdir)/doc
167 # 'make check' in gcc/ looks for check-c++, as do all toplevel C++-related
168 # check targets. However, our DejaGNU framework requires 'check-g++' as its
169 # entry point. We feed the former to the latter here.
170 check-c++ : check-g++
172 # Run the testsuite in C++17 mode.
173 check-c++1z: check-c++17
175 $(MAKE) RUNTESTFLAGS="$(RUNTESTFLAGS)" GXX_TESTSUITE_STDS=17 check-g++
177 # Run the testsuite in all standard conformance levels.
179 $(MAKE) RUNTESTFLAGS="$(RUNTESTFLAGS) --stds=98,11,14,17,2a,concepts" check-g++
181 # Run the testsuite with garbage collection at every opportunity.
183 $(MAKE) RUNTESTFLAGS="$(RUNTESTFLAGS) --extra_opts,--param,ggc-min-heapsize=0,--param,ggc-min-expand=0" \
184 TESTSUITEDIR="$(TESTSUITEDIR).gc" check-g++
185 check-c++-subtargets : check-g++-subtargets
186 # List of targets that can use the generic check- rule and its // variant.
187 lang_checks += check-g++
188 lang_checks_parallelized += check-g++
189 # For description see the check_$lang_parallelize comment in gcc/Makefile.in.
190 check_g++_parallelize = 10000
193 # cc1plus is installed elsewhere as part of $(COMPILERS).
195 # Install the driver program as $(target)-g++ and $(target)-c++, and
196 # also as g++ and c++ if native.
197 c++.install-common: installdirs
198 -if test "$(enable_as_accelerator)" != "yes" ; then \
199 rm -f $(DESTDIR)$(bindir)/$(GXX_INSTALL_NAME)$(exeext); \
200 $(INSTALL_PROGRAM) xg++$(exeext) $(DESTDIR)$(bindir)/$(GXX_INSTALL_NAME)$(exeext); \
201 chmod a+x $(DESTDIR)$(bindir)/$(GXX_INSTALL_NAME)$(exeext); \
202 rm -f $(DESTDIR)$(bindir)/$(CXX_INSTALL_NAME)$(exeext); \
203 ( cd $(DESTDIR)$(bindir) && \
204 $(LN) $(GXX_INSTALL_NAME)$(exeext) $(CXX_INSTALL_NAME)$(exeext) ); \
205 if [ -f cc1plus$(exeext) ] ; then \
206 if [ ! -f g++-cross$(exeext) ] ; then \
207 rm -f $(DESTDIR)$(bindir)/$(GXX_TARGET_INSTALL_NAME)$(exeext); \
208 ( cd $(DESTDIR)$(bindir) && \
209 $(LN) $(GXX_INSTALL_NAME)$(exeext) $(GXX_TARGET_INSTALL_NAME)$(exeext) ); \
210 rm -f $(DESTDIR)$(bindir)/$(CXX_TARGET_INSTALL_NAME)$(exeext); \
211 ( cd $(DESTDIR)$(bindir) && \
212 $(LN) $(CXX_INSTALL_NAME)$(exeext) $(CXX_TARGET_INSTALL_NAME)$(exeext) ); \
217 # We can't use links because not everyone supports them. So just copy the
222 c++.install-man: $(DESTDIR)$(man1dir)/$(GXX_INSTALL_NAME)$(man1ext)
224 $(DESTDIR)$(man1dir)/$(GXX_INSTALL_NAME)$(man1ext): doc/g++.1 installdirs
226 -$(INSTALL_DATA) $< $@
229 c++.install-plugin: installdirs
230 # We keep the directory structure for files in config and .def files. All
231 # other files are flattened to a single directory.
232 headers="$(CP_PLUGIN_HEADERS)"; \
233 for file in $$headers; do \
234 path=$(srcdir)/cp/$$file; \
235 dest=$(plugin_includedir)/cp/$$file; \
236 echo $(INSTALL_DATA) $$path $(DESTDIR)$$dest; \
237 dir=`dirname $$dest`; \
238 $(mkinstalldirs) $(DESTDIR)$$dir; \
239 $(INSTALL_DATA) $$path $(DESTDIR)$$dest; \
241 # Install import library.
242 ifeq ($(plugin_implib),yes)
243 $(mkinstalldirs) $(DESTDIR)$(plugin_resourcesdir)
244 $(INSTALL_DATA) cc1plus$(exeext).a $(DESTDIR)/$(plugin_resourcesdir)/cc1plus$(exeext).a
248 -rm -rf $(DESTDIR)$(bindir)/$(CXX_INSTALL_NAME)$(exeext)
249 -rm -rf $(DESTDIR)$(bindir)/$(GXX_INSTALL_NAME)$(exeext)
250 -rm -rf $(DESTDIR)$(man1dir)/$(GXX_INSTALL_NAME)$(man1ext)
253 # A lot of the ancillary files are deleted by the main makefile.
254 # We just have to delete files specific to us.
259 -rm -f cp/*$(coverageexts)
260 -rm -f xg++$(exeext) g++-cross$(exeext) cc1plus$(exeext) cc1plus.fda
263 -rm -f cp/config.status cp/Makefile
265 c++.maintainer-clean:
268 # The main makefile has already created stage?/cp.
270 c++.stage1: stage1-start
271 -mv cp/*$(objext) stage1/cp
272 c++.stage2: stage2-start
273 -mv cp/*$(objext) stage2/cp
274 c++.stage3: stage3-start
275 -mv cp/*$(objext) stage3/cp
276 c++.stage4: stage4-start
277 -mv cp/*$(objext) stage4/cp
278 c++.stageprofile: stageprofile-start
279 -mv cp/*$(objext) stageprofile/cp
280 c++.stagefeedback: stagefeedback-start
281 -mv cp/*$(objext) stagefeedback/cp
282 c++.autostageprofile: stageprofile-start
283 -mv cp/*$(objext) autostageprofile/cp
284 c++.autostagefeedback: stagefeedback-start
285 -mv cp/*$(objext) autostagefeedback/cp