Fix typo in t-dimode
[official-gcc.git] / gcc / cp / Make-lang.in
blobde1fc0249e67d9a2af51fa39335768a598a078a8
1 # Top level -*- makefile -*- fragment for GNU C++.
2 #   Copyright (C) 1994-2021 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)
9 #any later version.
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
44 #\f
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.
49 c++: cc1plus$(exeext)
50 c++.serial = cc1plus$(exeext)
52 # Tell GNU make to ignore these if they exist.
53 .PHONY: c++
55 CFLAGS-cp/g++spec.o += $(DRIVER_DEFINES)
57 CFLAGS-cp/module.o += -DHOST_MACHINE=\"$(host)\" \
58         -DTARGET_MACHINE=\"$(target)\"
60 # In non-release builds, use a date-related module version.
61 ifneq ($(DEVPHASE_c),)
62 # Some date's don't grok 'r', if so, simply use today's
63 # date (don't bootstrap at midnight).
64 MODULE_VERSION := $(shell date -r $(srcdir)/cp/module.cc '+%y%m%d-%H%M' \
65   2>/dev/null || date '+%y%m%d-0000' 2>/dev/null || echo 0)
67 CFLAGS-cp/module.o += -DMODULE_VERSION='($(subst -,,$(MODULE_VERSION))U)'
68 endif
70 # Create the compiler driver for g++.
71 GXX_OBJS = $(GCC_OBJS) cp/g++spec.o
72 xg++$(exeext): $(GXX_OBJS) $(EXTRA_GCC_OBJS) libcommon-target.a $(LIBDEPS)
73         +$(LINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ \
74           $(GXX_OBJS) $(EXTRA_GCC_OBJS) libcommon-target.a \
75           $(EXTRA_GCC_LIBS) $(LIBS)
77 # Create a version of the g++ driver which calls the cross-compiler.
78 g++-cross$(exeext): xg++$(exeext)
79         -rm -f g++-cross$(exeext)
80         cp xg++$(exeext) g++-cross$(exeext)
82 # The compiler itself.
83 # Shared with C front end:
84 CXX_C_OBJS = attribs.o incpath.o \
85         $(C_COMMON_OBJS) $(CXX_TARGET_OBJS)
87 # Language-specific object files for C++ and Objective C++.
88 CXX_AND_OBJCXX_OBJS = \
89         cp/call.o cp/class.o cp/constexpr.o cp/constraint.o \
90         cp/coroutines.o cp/cp-gimplify.o \
91         cp/cp-objcp-common.o cp/cp-ubsan.o \
92         cp/cvt.o cp/cxx-pretty-print.o \
93         cp/decl.o cp/decl2.o cp/dump.o \
94         cp/error.o cp/except.o cp/expr.o \
95         cp/friend.o cp/init.o \
96         cp/lambda.o cp/lex.o cp/logic.o \
97         cp/mangle.o cp/mapper-client.o cp/mapper-resolver.o \
98         cp/method.o cp/module.o \
99         cp/name-lookup.o cp/optimize.o \
100         cp/parser.o cp/pt.o cp/ptree.o \
101         cp/rtti.o \
102         cp/search.o cp/semantics.o \
103         cp/tree.o cp/typeck.o cp/typeck2.o \
104         cp/vtable-class-hierarchy.o $(CXX_C_OBJS)
106 ifeq ($(if $(wildcard ../stage_current),$(shell cat \
107   ../stage_current)),stageautofeedback)
108 $(CXX_AND_OBJCXX_OBJS): CFLAGS += -fauto-profile=cc1plus.fda
109 $(CXX_AND_OBJCXX_OBJS): cc1plus.fda
110 endif
112 # Language-specific object files for C++.
113 CXX_OBJS = cp/cp-lang.o c-family/stub-objc.o $(CXX_AND_OBJCXX_OBJS)
115 c++_OBJS = $(CXX_OBJS) cc1plus-checksum.o cp/g++spec.o
117 # Use strict warnings for this front end.
118 cp-warn = $(STRICT_WARN)
120 # compute checksum over all object files and the options
121 # re-use the checksum from the prev-final stage so it passes
122 # the bootstrap comparison and allows comparing of the cc1 binary
123 cc1plus-checksum.c : build/genchecksum$(build_exeext) checksum-options \
124         $(CXX_OBJS) $(BACKEND) $(CODYLIB) $(LIBDEPS) 
125         if [ -f ../stage_final ] \
126            && cmp -s ../stage_current ../stage_final; then \
127            cp ../prev-gcc/cc1plus-checksum.c cc1plus-checksum.c; \
128         else \
129           build/genchecksum$(build_exeext) $(CXX_OBJS) $(BACKEND) $(CODYLIB) $(LIBDEPS) \
130                      checksum-options > cc1plus-checksum.c.tmp &&          \
131           $(srcdir)/../move-if-change cc1plus-checksum.c.tmp cc1plus-checksum.c; \
132         fi
134 cc1plus$(exeext): $(CXX_OBJS) cc1plus-checksum.o $(BACKEND) $(CODYLIB) $(LIBDEPS) $(c++.prev)
135         @$(call LINK_PROGRESS,$(INDEX.c++),start)
136         +$(LLINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ \
137               $(CXX_OBJS) cc1plus-checksum.o $(BACKEND) $(CODYLIB) $(NETLIBS) \
138                 $(LIBS) $(BACKENDLIBS)
139         @$(call LINK_PROGRESS,$(INDEX.c++),end)
141 ifeq ($(ENABLE_MAINTAINER_RULES), true)
142 # Special build rule.  This is a maintainer rule, that is only
143 # available when GCC is configured with --enable-maintainer-mode.  In
144 # other cases, it is not available to avoid triggering rebuilds if a
145 # user has the source checked out with unusual timestamps.
146 $(srcdir)/cp/cfns.h: $(srcdir)/cp/cfns.gperf
147 else
148 # We keep the rule so that you can still force a rebuild, even if you
149 # didn't configure GCC with --enable-maintainer-mode, by manually
150 # deleting the $(srcdir)/cp/cfns.h file.
151 $(srcdir)/cp/cfns.h:
152 endif
153         gperf -o -C -E -k '1-6,$$' -j1 -D -N 'libc_name_p' -L C++ \
154                 $(srcdir)/cp/cfns.gperf --output-file $(srcdir)/cp/cfns.h
156 cc1plus.fda: ../stage1-gcc/cc1plus$(exeext) ../prev-gcc/$(PERF_DATA)
157         $(CREATE_GCOV) -binary ../stage1-gcc/cc1plus$(exeext) -gcov cc1plus.fda -profile ../prev-gcc/$(PERF_DATA) -gcov_version 1
160 # Build hooks:
162 c++.all.cross: g++-cross$(exeext)
163 c++.start.encap: xg++$(exeext)
164 c++.rest.encap:
165 c++.info:
166 c++.install-info:
167 c++.dvi:
168 c++.install-dvi:
169 c++.pdf:
170 c++.install-pdf:
171 c++.install-html:
172 c++.html:
173 c++.srcinfo:
174 c++.srcextra:
176 c++.tags: force
177         cd $(srcdir)/cp; etags -o TAGS.sub *.c *.cc *.h --language=none \
178           --regex='/DEFTREECODE [(]\([A-Z_]+\)/\1/' cp-tree.def; \
179         etags --include TAGS.sub --include ../TAGS.sub
181 c++.man: doc/g++.1
183 c++.srcman: doc/g++.1
184         -cp -p $^ $(srcdir)/doc
186 # C++ selftests
188 # If C++ is enabled, require the selftests to be run for it
189 # at each stage of the build:
190 selftest-c++: s-selftest-c++
192 CPP_SELFTEST_DEPS = cc1plus$(exeext) $(SELFTEST_DEPS)
193 CPP_SELFTEST_FLAGS = -xc++ $(SELFTEST_FLAGS)
195 # Run the C++ selftests
196 s-selftest-c++: $(CPP_SELFTEST_DEPS)
197         $(GCC_FOR_TARGET) $(CPP_SELFTEST_FLAGS)
198         $(STAMP) $@
200 # Convenience method for running C++ selftests under gdb:
201 .PHONY: selftest-c++-gdb
202 selftest-c++-gdb: $(CPP_SELFTEST_DEPS)
203         $(GCC_FOR_TARGET) $(CPP_SELFTEST_FLAGS) \
204           -wrapper gdb,--args
206 # Convenience method for running C++ selftests under valgrind:
207 .PHONY: selftest-c++-valgrind
208 selftest-c++-valgrind: $(CPP_SELFTEST_DEPS)
209         $(GCC_FOR_TARGET) $(CPP_SELFTEST_FLAGS) \
210           -wrapper valgrind,--leak-check=full
212 # 'make check' in gcc/ looks for check-c++, as do all toplevel C++-related
213 # check targets.  However, our DejaGNU framework requires 'check-g++' as its
214 # entry point.  We feed the former to the latter here.
215 check-c++ : check-g++
217 # Run the testsuite in C++17 mode.
218 check-c++1z: check-c++17
219 check-c++17:
220         $(MAKE) RUNTESTFLAGS="$(RUNTESTFLAGS)" GXX_TESTSUITE_STDS=17 check-g++
222 # Run the testsuite in all standard conformance levels.
223 check-c++-all:
224         $(MAKE) RUNTESTFLAGS="$(RUNTESTFLAGS) --stds=98,11,14,17,20,23,impcx" check-g++
226 # Run the testsuite with garbage collection at every opportunity.
227 check-g++-strict-gc:
228         $(MAKE) RUNTESTFLAGS="$(RUNTESTFLAGS) --extra_opts,--param,ggc-min-heapsize=0,--param,ggc-min-expand=0,--param,hash-table-verification-limit=10000" \
229           TESTSUITEDIR="$(TESTSUITEDIR).gc" check-g++
230 check-c++-subtargets : check-g++-subtargets
231 # List of targets that can use the generic check- rule and its // variant.
232 lang_checks += check-g++
233 lang_checks_parallelized += check-g++
234 # For description see the check_$lang_parallelize comment in gcc/Makefile.in.
235 check_g++_parallelize = 10000
237 # Install hooks:
238 # cc1plus is installed elsewhere as part of $(COMPILERS).
240 # Install the driver program as $(target)-g++ and $(target)-c++, and
241 # also as g++ and c++ if native.
242 c++.install-common: installdirs
243         -if test "$(enable_as_accelerator)" != "yes" ; then \
244           rm -f $(DESTDIR)$(bindir)/$(GXX_INSTALL_NAME)$(exeext); \
245           $(INSTALL_PROGRAM) xg++$(exeext) $(DESTDIR)$(bindir)/$(GXX_INSTALL_NAME)$(exeext); \
246           chmod a+x $(DESTDIR)$(bindir)/$(GXX_INSTALL_NAME)$(exeext); \
247           rm -f $(DESTDIR)$(bindir)/$(CXX_INSTALL_NAME)$(exeext); \
248           ( cd $(DESTDIR)$(bindir) && \
249             $(LN) $(GXX_INSTALL_NAME)$(exeext) $(CXX_INSTALL_NAME)$(exeext) ); \
250           if [ -f cc1plus$(exeext) ] ; then \
251             if [ ! -f g++-cross$(exeext) ] ; then \
252               rm -f $(DESTDIR)$(bindir)/$(GXX_TARGET_INSTALL_NAME)$(exeext); \
253               ( cd $(DESTDIR)$(bindir) && \
254                 $(LN) $(GXX_INSTALL_NAME)$(exeext) $(GXX_TARGET_INSTALL_NAME)$(exeext) ); \
255               rm -f $(DESTDIR)$(bindir)/$(CXX_TARGET_INSTALL_NAME)$(exeext); \
256               ( cd $(DESTDIR)$(bindir) && \
257                 $(LN) $(CXX_INSTALL_NAME)$(exeext) $(CXX_TARGET_INSTALL_NAME)$(exeext) ); \
258             fi ; \
259           fi; \
260         fi
262 # We can't use links because not everyone supports them.  So just copy the
263 # manpage.
264 doc/g++.1: doc/gcc.1
265         cp $< doc/g++.1
267 c++.install-man: $(DESTDIR)$(man1dir)/$(GXX_INSTALL_NAME)$(man1ext)
269 $(DESTDIR)$(man1dir)/$(GXX_INSTALL_NAME)$(man1ext): doc/g++.1 installdirs
270         -rm -f $@
271         -$(INSTALL_DATA) $< $@
272         -chmod a-x $@
274 c++.install-plugin: installdirs
275 # We keep the directory structure for files in config and .def files. All
276 # other files are flattened to a single directory.
277         headers="$(CP_PLUGIN_HEADERS)"; \
278         for file in $$headers; do \
279           path=$(srcdir)/cp/$$file; \
280           dest=$(plugin_includedir)/cp/$$file; \
281           echo $(INSTALL_DATA) $$path $(DESTDIR)$$dest; \
282           dir=`dirname $$dest`; \
283           $(mkinstalldirs) $(DESTDIR)$$dir; \
284           $(INSTALL_DATA) $$path $(DESTDIR)$$dest; \
285         done
286 # Install import library.
287 ifeq ($(plugin_implib),yes)
288         $(mkinstalldirs) $(DESTDIR)$(plugin_resourcesdir)
289         $(INSTALL_DATA) cc1plus$(exeext).a $(DESTDIR)/$(plugin_resourcesdir)/cc1plus$(exeext).a
290 endif
292 c++.uninstall:
293         -rm -rf $(DESTDIR)$(bindir)/$(CXX_INSTALL_NAME)$(exeext)
294         -rm -rf $(DESTDIR)$(bindir)/$(GXX_INSTALL_NAME)$(exeext)
295         -rm -rf $(DESTDIR)$(man1dir)/$(GXX_INSTALL_NAME)$(man1ext)
297 # Clean hooks:
298 # A lot of the ancillary files are deleted by the main makefile.
299 # We just have to delete files specific to us.
301 c++.mostlyclean:
302         -rm -f doc/g++.1
303         -rm -f cp/*$(objext)
304         -rm -f cp/*$(coverageexts)
305         -rm -f xg++$(exeext) g++-cross$(exeext) cc1plus$(exeext) cc1plus.fda
306 c++.clean:
307 c++.distclean:
308         -rm -f cp/config.status cp/Makefile
309 c++.maintainer-clean:
311 # Stage hooks:
312 # The main makefile has already created stage?/cp.
314 c++.stage1: stage1-start
315         -mv cp/*$(objext) stage1/cp
316 c++.stage2: stage2-start
317         -mv cp/*$(objext) stage2/cp
318 c++.stage3: stage3-start
319         -mv cp/*$(objext) stage3/cp
320 c++.stage4: stage4-start
321         -mv cp/*$(objext) stage4/cp
322 c++.stageprofile: stageprofile-start
323         -mv cp/*$(objext) stageprofile/cp
324 c++.stagefeedback: stagefeedback-start
325         -mv cp/*$(objext) stagefeedback/cp
326 c++.autostageprofile: stageprofile-start
327         -mv cp/*$(objext) autostageprofile/cp
328 c++.autostagefeedback: stagefeedback-start
329         -mv cp/*$(objext) autostagefeedback/cp