]>
Commit | Line | Data |
---|---|---|
90a83261 | 1 | # Top level -*- makefile -*- fragment for GNU C++. |
fbd26352 | 2 | # Copyright (C) 1994-2019 Free Software Foundation, Inc. |
6e498b5c | 3 | |
5d1e9c98 | 4 | #This file is part of GCC. |
6e498b5c | 5 | |
5d1e9c98 | 6 | #GCC is free software; you can redistribute it and/or modify |
6e498b5c | 7 | #it under the terms of the GNU General Public License as published by |
aa139c3f | 8 | #the Free Software Foundation; either version 3, or (at your option) |
6e498b5c | 9 | #any later version. |
10 | ||
5d1e9c98 | 11 | #GCC is distributed in the hope that it will be useful, |
6e498b5c | 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. | |
15 | ||
aa139c3f | 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/>. | |
6e498b5c | 19 | |
20 | # This file provides the language dependent support in the main Makefile. | |
21 | # Each language makefile fragment must provide the following targets: | |
22 | # | |
ae6555f9 | 23 | # foo.all.cross, foo.start.encap, foo.rest.encap, |
26e296a8 | 24 | # foo.install-common, foo.install-man, foo.install-info, foo.install-pdf, |
fb433b0b | 25 | # foo.install-html, foo.info, foo.dvi, foo.pdf, foo.html, foo.uninstall, |
80e909c6 | 26 | # foo.mostlyclean, foo.clean, foo.distclean, |
a8514488 | 27 | # foo.maintainer-clean, foo.stage1, foo.stage2, foo.stage3, foo.stage4 |
6e498b5c | 28 | # |
29 | # where `foo' is the name of the language. | |
30 | # | |
31 | # It should also provide rules for: | |
32 | # | |
33 | # - making any compiler driver (eg: g++) | |
34 | # - the compiler proper (eg: cc1plus) | |
35 | # - define the names for selecting the language in LANGUAGES. | |
6e498b5c | 36 | |
ddb9bca7 | 37 | # Actual names to use when installing a native compiler. |
88a86c80 | 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)') | |
482ccb7f | 42 | CP_PLUGIN_HEADERS := cp-tree.h cxx-pretty-print.h name-lookup.h type-utils.h operators.def |
ddb9bca7 | 43 | |
6686e84d | 44 | #\f |
6e498b5c | 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. | |
9f30f9e7 | 49 | c++: cc1plus$(exeext) |
6e498b5c | 50 | |
c9db0571 | 51 | # Tell GNU make to ignore these if they exist. |
9f30f9e7 | 52 | .PHONY: c++ |
c9db0571 | 53 | |
4c42ae66 | 54 | CFLAGS-cp/g++spec.o += $(DRIVER_DEFINES) |
b0df6589 | 55 | |
6e498b5c | 56 | # Create the compiler driver for g++. |
4c42ae66 | 57 | GXX_OBJS = $(GCC_OBJS) cp/g++spec.o |
3e54888f | 58 | xg++$(exeext): $(GXX_OBJS) $(EXTRA_GCC_OBJS) libcommon-target.a $(LIBDEPS) |
70293f47 | 59 | +$(LINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ \ |
76fd9e61 | 60 | $(GXX_OBJS) $(EXTRA_GCC_OBJS) libcommon-target.a \ |
61 | $(EXTRA_GCC_LIBS) $(LIBS) | |
6e498b5c | 62 | |
63 | # Create a version of the g++ driver which calls the cross-compiler. | |
3e54888f | 64 | g++-cross$(exeext): xg++$(exeext) |
b0df6589 | 65 | -rm -f g++-cross$(exeext) |
3e54888f | 66 | cp xg++$(exeext) g++-cross$(exeext) |
6e498b5c | 67 | |
f357ac87 | 68 | # The compiler itself. |
69 | # Shared with C front end: | |
eb65953e | 70 | CXX_C_OBJS = attribs.o incpath.o \ |
7bedc3a0 | 71 | $(C_COMMON_OBJS) $(CXX_TARGET_OBJS) |
f357ac87 | 72 | |
11a35d8f | 73 | # Language-specific object files for C++ and Objective C++. |
03f335a5 | 74 | CXX_AND_OBJCXX_OBJS = \ |
75 | cp/call.o cp/class.o cp/constexpr.o cp/constraint.o \ | |
efa02472 | 76 | cp/cp-gimplify.o \ |
03f335a5 | 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 \ | |
86 | cp/repo.o cp/rtti.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) | |
11a35d8f | 90 | |
6eb2402f | 91 | ifeq ($(if $(wildcard ../stage_current),$(shell cat \ |
92 | ../stage_current)),stageautofeedback) | |
b4c71cbb | 93 | $(CXX_AND_OBJCXX_OBJS): CFLAGS += -fauto-profile=cc1plus.fda |
94 | $(CXX_AND_OBJCXX_OBJS): cc1plus.fda | |
95 | endif | |
96 | ||
11a35d8f | 97 | # Language-specific object files for C++. |
7bedc3a0 | 98 | CXX_OBJS = cp/cp-lang.o c-family/stub-objc.o $(CXX_AND_OBJCXX_OBJS) |
f357ac87 | 99 | |
18cfeada | 100 | c++_OBJS = $(CXX_OBJS) cc1plus-checksum.o cp/g++spec.o |
6fb2153a | 101 | |
9e91bfe8 | 102 | # Use strict warnings for this front end. |
9d61b2aa | 103 | cp-warn = $(STRICT_WARN) |
f357ac87 | 104 | |
18cfeada | 105 | # compute checksum over all object files and the options |
0bd2fc6e | 106 | # re-use the checksum from the prev-final stage so it passes |
107 | # the bootstrap comparison and allows comparing of the cc1 binary | |
18cfeada | 108 | cc1plus-checksum.c : build/genchecksum$(build_exeext) checksum-options \ |
109 | $(CXX_OBJS) $(BACKEND) $(LIBDEPS) | |
0bd2fc6e | 110 | if [ -f ../stage_final ] \ |
111 | && cmp -s ../stage_current ../stage_final; then \ | |
112 | cp ../prev-gcc/cc1plus-checksum.c cc1plus-checksum.c; \ | |
113 | else \ | |
114 | build/genchecksum$(build_exeext) $(CXX_OBJS) $(BACKEND) $(LIBDEPS) \ | |
18cfeada | 115 | checksum-options > cc1plus-checksum.c.tmp && \ |
0bd2fc6e | 116 | $(srcdir)/../move-if-change cc1plus-checksum.c.tmp cc1plus-checksum.c; \ |
117 | fi | |
f1035767 | 118 | |
f1035767 | 119 | cc1plus$(exeext): $(CXX_OBJS) cc1plus-checksum.o $(BACKEND) $(LIBDEPS) |
be5f9e46 | 120 | +$(LLINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ \ |
268a100a | 121 | $(CXX_OBJS) cc1plus-checksum.o $(BACKEND) $(LIBS) $(BACKENDLIBS) |
f357ac87 | 122 | |
141d02d1 | 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. | |
f357ac87 | 128 | $(srcdir)/cp/cfns.h: $(srcdir)/cp/cfns.gperf |
141d02d1 | 129 | else |
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. | |
133 | $(srcdir)/cp/cfns.h: | |
134 | endif | |
ec1cc026 | 135 | gperf -o -C -E -k '1-6,$$' -j1 -D -N 'libc_name_p' -L C++ \ |
141d02d1 | 136 | $(srcdir)/cp/cfns.gperf --output-file $(srcdir)/cp/cfns.h |
f357ac87 | 137 | |
b4c71cbb | 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 | |
140 | ||
6686e84d | 141 | #\f |
6e498b5c | 142 | # Build hooks: |
143 | ||
05988adb | 144 | c++.all.cross: g++-cross$(exeext) |
3e54888f | 145 | c++.start.encap: xg++$(exeext) |
05988adb | 146 | c++.rest.encap: |
ca6eabd1 | 147 | c++.info: |
352ea6ae | 148 | c++.install-info: |
149 | c++.dvi: | |
51f93521 | 150 | c++.pdf: |
26e296a8 | 151 | c++.install-pdf: |
fb433b0b | 152 | c++.install-html: |
352ea6ae | 153 | c++.html: |
ca6eabd1 | 154 | c++.srcinfo: |
a6b4c5a9 | 155 | c++.srcextra: |
6e498b5c | 156 | |
975d01b5 | 157 | c++.tags: force |
56c12fd4 | 158 | cd $(srcdir)/cp; etags -o TAGS.sub *.c *.cc *.h --language=none \ |
39aebbc3 | 159 | --regex='/DEFTREECODE [(]\([A-Z_]+\)/\1/' cp-tree.def; \ |
160 | etags --include TAGS.sub --include ../TAGS.sub | |
975d01b5 | 161 | |
ca6eabd1 | 162 | c++.man: doc/g++.1 |
163 | ||
164 | c++.srcman: doc/g++.1 | |
165 | -cp -p $^ $(srcdir)/doc | |
215d428d | 166 | |
bdb69048 | 167 | # C++ selftests |
168 | ||
169 | # If C++ is enabled, require the selftests to be run for it | |
170 | # at each stage of the build: | |
171 | selftest-c++: s-selftest-c++ | |
172 | ||
173 | CPP_SELFTEST_DEPS = cc1plus$(exeext) $(SELFTEST_DEPS) | |
174 | CPP_SELFTEST_FLAGS = -xc++ $(SELFTEST_FLAGS) | |
175 | ||
176 | # Run the C++ selftests | |
177 | s-selftest-c++: $(CPP_SELFTEST_DEPS) | |
178 | $(GCC_FOR_TARGET) $(CPP_SELFTEST_FLAGS) | |
179 | $(STAMP) $@ | |
180 | ||
181 | # Convenience method for running C++ selftests under gdb: | |
182 | .PHONY: selftest-c++-gdb | |
183 | selftest-c++-gdb: $(CPP_SELFTEST_DEPS) | |
184 | $(GCC_FOR_TARGET) $(CPP_SELFTEST_FLAGS) \ | |
185 | -wrapper gdb,--args | |
186 | ||
187 | # Convenience method for running C++ selftests under valgrind: | |
188 | .PHONY: selftest-c++-valgrind | |
189 | selftest-c++-valgrind: $(CPP_SELFTEST_DEPS) | |
190 | $(GCC_FOR_TARGET) $(CPP_SELFTEST_FLAGS) \ | |
191 | -wrapper valgrind,--leak-check=full | |
192 | ||
a00dec3b | 193 | # 'make check' in gcc/ looks for check-c++, as do all toplevel C++-related |
194 | # check targets. However, our DejaGNU framework requires 'check-g++' as its | |
195 | # entry point. We feed the former to the latter here. | |
71a3866b | 196 | check-c++ : check-g++ |
0001fd8d | 197 | |
40e2decb | 198 | # Run the testsuite in C++17 mode. |
199 | check-c++1z: check-c++17 | |
200 | check-c++17: | |
201 | $(MAKE) RUNTESTFLAGS="$(RUNTESTFLAGS)" GXX_TESTSUITE_STDS=17 check-g++ | |
0001fd8d | 202 | |
203 | # Run the testsuite in all standard conformance levels. | |
204 | check-c++-all: | |
234c25a6 | 205 | $(MAKE) RUNTESTFLAGS="$(RUNTESTFLAGS) --stds=98,11,14,17,2a,concepts" check-g++ |
0001fd8d | 206 | |
cf797b5e | 207 | # Run the testsuite with garbage collection at every opportunity. |
208 | check-g++-strict-gc: | |
209 | $(MAKE) RUNTESTFLAGS="$(RUNTESTFLAGS) --extra_opts,--param,ggc-min-heapsize=0,--param,ggc-min-expand=0" \ | |
210 | TESTSUITEDIR="$(TESTSUITEDIR).gc" check-g++ | |
a0d20ccb | 211 | check-c++-subtargets : check-g++-subtargets |
a00dec3b | 212 | # List of targets that can use the generic check- rule and its // variant. |
71a3866b | 213 | lang_checks += check-g++ |
a0d20ccb | 214 | lang_checks_parallelized += check-g++ |
eeec71b4 | 215 | # For description see the check_$lang_parallelize comment in gcc/Makefile.in. |
eb9bd3cc | 216 | check_g++_parallelize = 10000 |
6686e84d | 217 | #\f |
6e498b5c | 218 | # Install hooks: |
219 | # cc1plus is installed elsewhere as part of $(COMPILERS). | |
220 | ||
955edcde | 221 | # Install the driver program as $(target)-g++ and $(target)-c++, and |
222 | # also as g++ and c++ if native. | |
414d46fe | 223 | c++.install-common: installdirs |
a3d93be3 | 224 | -if test "$(enable_as_accelerator)" != "yes" ; then \ |
225 | rm -f $(DESTDIR)$(bindir)/$(GXX_INSTALL_NAME)$(exeext); \ | |
226 | $(INSTALL_PROGRAM) xg++$(exeext) $(DESTDIR)$(bindir)/$(GXX_INSTALL_NAME)$(exeext); \ | |
227 | chmod a+x $(DESTDIR)$(bindir)/$(GXX_INSTALL_NAME)$(exeext); \ | |
228 | rm -f $(DESTDIR)$(bindir)/$(CXX_INSTALL_NAME)$(exeext); \ | |
229 | ( cd $(DESTDIR)$(bindir) && \ | |
230 | $(LN) $(GXX_INSTALL_NAME)$(exeext) $(CXX_INSTALL_NAME)$(exeext) ); \ | |
231 | if [ -f cc1plus$(exeext) ] ; then \ | |
232 | if [ ! -f g++-cross$(exeext) ] ; then \ | |
233 | rm -f $(DESTDIR)$(bindir)/$(GXX_TARGET_INSTALL_NAME)$(exeext); \ | |
234 | ( cd $(DESTDIR)$(bindir) && \ | |
235 | $(LN) $(GXX_INSTALL_NAME)$(exeext) $(GXX_TARGET_INSTALL_NAME)$(exeext) ); \ | |
236 | rm -f $(DESTDIR)$(bindir)/$(CXX_TARGET_INSTALL_NAME)$(exeext); \ | |
237 | ( cd $(DESTDIR)$(bindir) && \ | |
238 | $(LN) $(CXX_INSTALL_NAME)$(exeext) $(CXX_TARGET_INSTALL_NAME)$(exeext) ); \ | |
239 | fi ; \ | |
240 | fi; \ | |
6e498b5c | 241 | fi |
242 | ||
5641963c | 243 | # We can't use links because not everyone supports them. So just copy the |
244 | # manpage. | |
ca6eabd1 | 245 | doc/g++.1: doc/gcc.1 |
49e86385 | 246 | cp $< doc/g++.1 |
a7a78208 | 247 | |
9031d10b | 248 | c++.install-man: $(DESTDIR)$(man1dir)/$(GXX_INSTALL_NAME)$(man1ext) |
ca6eabd1 | 249 | |
01ac74a6 | 250 | $(DESTDIR)$(man1dir)/$(GXX_INSTALL_NAME)$(man1ext): doc/g++.1 installdirs |
ca6eabd1 | 251 | -rm -f $@ |
252 | -$(INSTALL_DATA) $< $@ | |
253 | -chmod a-x $@ | |
6e498b5c | 254 | |
c02b6f4e | 255 | c++.install-plugin: installdirs |
256 | # We keep the directory structure for files in config and .def files. All | |
257 | # other files are flattened to a single directory. | |
258 | headers="$(CP_PLUGIN_HEADERS)"; \ | |
259 | for file in $$headers; do \ | |
260 | path=$(srcdir)/cp/$$file; \ | |
261 | dest=$(plugin_includedir)/cp/$$file; \ | |
262 | echo $(INSTALL_DATA) $$path $(DESTDIR)$$dest; \ | |
263 | dir=`dirname $$dest`; \ | |
264 | $(mkinstalldirs) $(DESTDIR)$$dir; \ | |
265 | $(INSTALL_DATA) $$path $(DESTDIR)$$dest; \ | |
266 | done | |
864319e6 | 267 | # Install import library. |
268 | ifeq ($(plugin_implib),yes) | |
269 | $(mkinstalldirs) $(DESTDIR)$(plugin_resourcesdir) | |
270 | $(INSTALL_DATA) cc1plus$(exeext).a $(DESTDIR)/$(plugin_resourcesdir)/cc1plus$(exeext).a | |
271 | endif | |
c02b6f4e | 272 | |
6e498b5c | 273 | c++.uninstall: |
b113996a | 274 | -rm -rf $(DESTDIR)$(bindir)/$(CXX_INSTALL_NAME)$(exeext) |
b113996a | 275 | -rm -rf $(DESTDIR)$(bindir)/$(GXX_INSTALL_NAME)$(exeext) |
b113996a | 276 | -rm -rf $(DESTDIR)$(man1dir)/$(GXX_INSTALL_NAME)$(man1ext) |
6686e84d | 277 | #\f |
6e498b5c | 278 | # Clean hooks: |
279 | # A lot of the ancillary files are deleted by the main makefile. | |
280 | # We just have to delete files specific to us. | |
281 | ||
282 | c++.mostlyclean: | |
ca6eabd1 | 283 | -rm -f doc/g++.1 |
05988adb | 284 | -rm -f cp/*$(objext) |
d5a37d75 | 285 | -rm -f cp/*$(coverageexts) |
b4c71cbb | 286 | -rm -f xg++$(exeext) g++-cross$(exeext) cc1plus$(exeext) cc1plus.fda |
6e498b5c | 287 | c++.clean: |
288 | c++.distclean: | |
289 | -rm -f cp/config.status cp/Makefile | |
e53d55e7 | 290 | -rm -f cxxmain.c |
a8514488 | 291 | c++.maintainer-clean: |
6686e84d | 292 | #\f |
6e498b5c | 293 | # Stage hooks: |
294 | # The main makefile has already created stage?/cp. | |
295 | ||
860740a7 | 296 | c++.stage1: stage1-start |
a14eefe6 | 297 | -mv cp/*$(objext) stage1/cp |
860740a7 | 298 | c++.stage2: stage2-start |
a14eefe6 | 299 | -mv cp/*$(objext) stage2/cp |
860740a7 | 300 | c++.stage3: stage3-start |
a14eefe6 | 301 | -mv cp/*$(objext) stage3/cp |
860740a7 | 302 | c++.stage4: stage4-start |
a14eefe6 | 303 | -mv cp/*$(objext) stage4/cp |
ef3bb540 | 304 | c++.stageprofile: stageprofile-start |
305 | -mv cp/*$(objext) stageprofile/cp | |
306 | c++.stagefeedback: stagefeedback-start | |
307 | -mv cp/*$(objext) stagefeedback/cp | |
b4c71cbb | 308 | c++.autostageprofile: stageprofile-start |
309 | -mv cp/*$(objext) autostageprofile/cp | |
310 | c++.autostagefeedback: stagefeedback-start | |
311 | -mv cp/*$(objext) autostagefeedback/cp |