xref: /netbsd-src/external/gpl3/gcc.old/dist/gcc/cp/Make-lang.in (revision 8feb0f0b7eaff0608f8350bbfa3098827b4bb91b)
1# Top level -*- makefile -*- fragment for GNU C++.
2#   Copyright (C) 1994-2020 Free Software Foundation, Inc.
3
4#This file is part of GCC.
5
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.
10
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.
15
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/>.
19
20# This file provides the language dependent support in the main Makefile.
21# Each language makefile fragment must provide the following targets:
22#
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
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.
36
37# Actual names to use when installing a native compiler.
38CXX_INSTALL_NAME := $(shell echo c++|sed '$(program_transform_name)')
39GXX_INSTALL_NAME := $(shell echo g++|sed '$(program_transform_name)')
40CXX_TARGET_INSTALL_NAME := $(target_noncanonical)-$(shell echo c++|sed '$(program_transform_name)')
41GXX_TARGET_INSTALL_NAME := $(target_noncanonical)-$(shell echo g++|sed '$(program_transform_name)')
42CP_PLUGIN_HEADERS := cp-tree.h cxx-pretty-print.h name-lookup.h type-utils.h operators.def
43
44#
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.
49c++: cc1plus$(exeext)
50
51# Tell GNU make to ignore these if they exist.
52.PHONY: c++
53
54CFLAGS-cp/g++spec.o += $(DRIVER_DEFINES)
55
56# Create the compiler driver for g++.
57GXX_OBJS = $(GCC_OBJS) cp/g++spec.o
58xg++$(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)
62
63# Create a version of the g++ driver which calls the cross-compiler.
64g++-cross$(exeext): xg++$(exeext)
65	-rm -f g++-cross$(exeext)
66	cp xg++$(exeext) g++-cross$(exeext)
67
68# The compiler itself.
69# Shared with C front end:
70CXX_C_OBJS = attribs.o incpath.o \
71	$(C_COMMON_OBJS) $(CXX_TARGET_OBJS)
72
73# Language-specific object files for C++ and Objective C++.
74CXX_AND_OBJCXX_OBJS = \
75	cp/call.o cp/class.o cp/constexpr.o cp/constraint.o \
76	cp/coroutines.o cp/cp-gimplify.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 \
86	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)
90
91ifeq ($(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
95endif
96
97# Language-specific object files for C++.
98CXX_OBJS = cp/cp-lang.o c-family/stub-objc.o $(CXX_AND_OBJCXX_OBJS)
99
100c++_OBJS = $(CXX_OBJS) cc1plus-checksum.o cp/g++spec.o
101
102# Use strict warnings for this front end.
103cp-warn = $(STRICT_WARN)
104
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
108cc1plus-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; \
113	else \
114	  build/genchecksum$(build_exeext) $(CXX_OBJS) $(BACKEND) $(LIBDEPS) \
115                     checksum-options > cc1plus-checksum.c.tmp &&	   \
116	  $(SHELL) $(srcdir)/../move-if-change cc1plus-checksum.c.tmp cc1plus-checksum.c; \
117	fi
118
119cc1plus$(exeext): $(CXX_OBJS) cc1plus-checksum.o $(BACKEND) $(LIBDEPS)
120	+$(LLINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ \
121	      $(CXX_OBJS) cc1plus-checksum.o $(BACKEND) $(LIBS) $(BACKENDLIBS)
122
123ifeq ($(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
129	@echo "NOT REBUILDING $@"
130NetBSD_DISABLED_cfns.h:
131else
132# We keep the rule so that you can still force a rebuild, even if you
133# didn't configure GCC with --enable-maintainer-mode, by manually
134# deleting the $(srcdir)/cp/cfns.h file.
135$(srcdir)/cp/cfns.h:
136endif
137	gperf -o -C -E -k '1-6,$$' -j1 -D -N 'libc_name_p' -L C++ \
138		$(srcdir)/cp/cfns.gperf --output-file $(srcdir)/cp/cfns.h
139
140cc1plus.fda: ../stage1-gcc/cc1plus$(exeext) ../prev-gcc/$(PERF_DATA)
141	$(CREATE_GCOV) -binary ../stage1-gcc/cc1plus$(exeext) -gcov cc1plus.fda -profile ../prev-gcc/$(PERF_DATA) -gcov_version 1
142
143#
144# Build hooks:
145
146c++.all.cross: g++-cross$(exeext)
147c++.start.encap: xg++$(exeext)
148c++.rest.encap:
149c++.info:
150c++.install-info:
151c++.dvi:
152c++.pdf:
153c++.install-pdf:
154c++.install-html:
155c++.html:
156c++.srcinfo:
157c++.srcextra:
158
159c++.tags: force
160	cd $(srcdir)/cp; etags -o TAGS.sub *.c *.cc *.h --language=none \
161	  --regex='/DEFTREECODE [(]\([A-Z_]+\)/\1/' cp-tree.def; \
162	etags --include TAGS.sub --include ../TAGS.sub
163
164c++.man: doc/g++.1
165
166c++.srcman: doc/g++.1
167	-cp -p $^ $(srcdir)/doc
168
169# C++ selftests
170
171# If C++ is enabled, require the selftests to be run for it
172# at each stage of the build:
173selftest-c++: s-selftest-c++
174
175CPP_SELFTEST_DEPS = cc1plus$(exeext) $(SELFTEST_DEPS)
176CPP_SELFTEST_FLAGS = -xc++ $(SELFTEST_FLAGS)
177
178# Run the C++ selftests
179s-selftest-c++: $(CPP_SELFTEST_DEPS)
180	$(GCC_FOR_TARGET) $(CPP_SELFTEST_FLAGS)
181	$(STAMP) $@
182
183# Convenience method for running C++ selftests under gdb:
184.PHONY: selftest-c++-gdb
185selftest-c++-gdb: $(CPP_SELFTEST_DEPS)
186	$(GCC_FOR_TARGET) $(CPP_SELFTEST_FLAGS) \
187	  -wrapper gdb,--args
188
189# Convenience method for running C++ selftests under valgrind:
190.PHONY: selftest-c++-valgrind
191selftest-c++-valgrind: $(CPP_SELFTEST_DEPS)
192	$(GCC_FOR_TARGET) $(CPP_SELFTEST_FLAGS) \
193	  -wrapper valgrind,--leak-check=full
194
195# 'make check' in gcc/ looks for check-c++, as do all toplevel C++-related
196# check targets.  However, our DejaGNU framework requires 'check-g++' as its
197# entry point.  We feed the former to the latter here.
198check-c++ : check-g++
199
200# Run the testsuite in C++17 mode.
201check-c++1z: check-c++17
202check-c++17:
203	$(MAKE) RUNTESTFLAGS="$(RUNTESTFLAGS)" GXX_TESTSUITE_STDS=17 check-g++
204
205# Run the testsuite in all standard conformance levels.
206check-c++-all:
207	$(MAKE) RUNTESTFLAGS="$(RUNTESTFLAGS) --stds=98,11,14,17,2a,concepts" check-g++
208
209# Run the testsuite with garbage collection at every opportunity.
210check-g++-strict-gc:
211	$(MAKE) RUNTESTFLAGS="$(RUNTESTFLAGS) --extra_opts,--param,ggc-min-heapsize=0,--param,ggc-min-expand=0" \
212	  TESTSUITEDIR="$(TESTSUITEDIR).gc" check-g++
213check-c++-subtargets : check-g++-subtargets
214# List of targets that can use the generic check- rule and its // variant.
215lang_checks += check-g++
216lang_checks_parallelized += check-g++
217# For description see the check_$lang_parallelize comment in gcc/Makefile.in.
218check_g++_parallelize = 10000
219#
220# Install hooks:
221# cc1plus is installed elsewhere as part of $(COMPILERS).
222
223# Install the driver program as $(target)-g++ and $(target)-c++, and
224# also as g++ and c++ if native.
225c++.install-common: installdirs
226	-if test "$(enable_as_accelerator)" != "yes" ; then \
227	  rm -f $(DESTDIR)$(bindir)/$(GXX_INSTALL_NAME)$(exeext); \
228	  $(INSTALL_PROGRAM) xg++$(exeext) $(DESTDIR)$(bindir)/$(GXX_INSTALL_NAME)$(exeext); \
229	  chmod a+x $(DESTDIR)$(bindir)/$(GXX_INSTALL_NAME)$(exeext); \
230	  rm -f $(DESTDIR)$(bindir)/$(CXX_INSTALL_NAME)$(exeext); \
231	  ( cd $(DESTDIR)$(bindir) && \
232	    $(LN) $(GXX_INSTALL_NAME)$(exeext) $(CXX_INSTALL_NAME)$(exeext) ); \
233	  if [ -f cc1plus$(exeext) ] ; then \
234	    if [ ! -f g++-cross$(exeext) ] ; then \
235	      rm -f $(DESTDIR)$(bindir)/$(GXX_TARGET_INSTALL_NAME)$(exeext); \
236	      ( cd $(DESTDIR)$(bindir) && \
237		$(LN) $(GXX_INSTALL_NAME)$(exeext) $(GXX_TARGET_INSTALL_NAME)$(exeext) ); \
238	      rm -f $(DESTDIR)$(bindir)/$(CXX_TARGET_INSTALL_NAME)$(exeext); \
239	      ( cd $(DESTDIR)$(bindir) && \
240		$(LN) $(CXX_INSTALL_NAME)$(exeext) $(CXX_TARGET_INSTALL_NAME)$(exeext) ); \
241	    fi ; \
242	  fi; \
243	fi
244
245# We can't use links because not everyone supports them.  So just copy the
246# manpage.
247doc/g++.1: doc/gcc.1
248	cp $< doc/g++.1
249
250c++.install-man: $(DESTDIR)$(man1dir)/$(GXX_INSTALL_NAME)$(man1ext)
251
252$(DESTDIR)$(man1dir)/$(GXX_INSTALL_NAME)$(man1ext): doc/g++.1 installdirs
253	-rm -f $@
254	-$(INSTALL_DATA) $< $@
255	-chmod a-x $@
256
257c++.install-plugin: installdirs
258# We keep the directory structure for files in config and .def files. All
259# other files are flattened to a single directory.
260	headers="$(CP_PLUGIN_HEADERS)"; \
261	for file in $$headers; do \
262	  path=$(srcdir)/cp/$$file; \
263	  dest=$(plugin_includedir)/cp/$$file; \
264	  echo $(INSTALL_DATA) $$path $(DESTDIR)$$dest; \
265	  dir=`dirname $$dest`; \
266	  $(mkinstalldirs) $(DESTDIR)$$dir; \
267	  $(INSTALL_DATA) $$path $(DESTDIR)$$dest; \
268	done
269# Install import library.
270ifeq ($(plugin_implib),yes)
271	$(mkinstalldirs) $(DESTDIR)$(plugin_resourcesdir)
272	$(INSTALL_DATA) cc1plus$(exeext).a $(DESTDIR)/$(plugin_resourcesdir)/cc1plus$(exeext).a
273endif
274
275c++.uninstall:
276	-rm -rf $(DESTDIR)$(bindir)/$(CXX_INSTALL_NAME)$(exeext)
277	-rm -rf $(DESTDIR)$(bindir)/$(GXX_INSTALL_NAME)$(exeext)
278	-rm -rf $(DESTDIR)$(man1dir)/$(GXX_INSTALL_NAME)$(man1ext)
279#
280# Clean hooks:
281# A lot of the ancillary files are deleted by the main makefile.
282# We just have to delete files specific to us.
283
284c++.mostlyclean:
285	-rm -f doc/g++.1
286	-rm -f cp/*$(objext)
287	-rm -f cp/*$(coverageexts)
288	-rm -f xg++$(exeext) g++-cross$(exeext) cc1plus$(exeext) cc1plus.fda
289c++.clean:
290c++.distclean:
291	-rm -f cp/config.status cp/Makefile
292	-rm -f cxxmain.c
293c++.maintainer-clean:
294#
295# Stage hooks:
296# The main makefile has already created stage?/cp.
297
298c++.stage1: stage1-start
299	-mv cp/*$(objext) stage1/cp
300c++.stage2: stage2-start
301	-mv cp/*$(objext) stage2/cp
302c++.stage3: stage3-start
303	-mv cp/*$(objext) stage3/cp
304c++.stage4: stage4-start
305	-mv cp/*$(objext) stage4/cp
306c++.stageprofile: stageprofile-start
307	-mv cp/*$(objext) stageprofile/cp
308c++.stagefeedback: stagefeedback-start
309	-mv cp/*$(objext) stagefeedback/cp
310c++.autostageprofile: stageprofile-start
311	-mv cp/*$(objext) autostageprofile/cp
312c++.autostagefeedback: stagefeedback-start
313	-mv cp/*$(objext) autostagefeedback/cp
314