1# Top level -*- makefile -*- fragment for GNU C++. 2# Copyright (C) 1994-2015 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 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 = 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 \ 79 cp/cp-cilkplus.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) 82 83# Language-specific object files for C++. 84CXX_OBJS = cp/cp-lang.o c-family/stub-objc.o $(CXX_AND_OBJCXX_OBJS) 85 86c++_OBJS = $(CXX_OBJS) cc1plus-checksum.o cp/g++spec.o 87 88# Use strict warnings for this front end. 89cp-warn = $(STRICT_WARN) 90 91# compute checksum over all object files and the options 92cc1plus-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 97 98cc1plus$(exeext): $(CXX_OBJS) cc1plus-checksum.o $(BACKEND) $(LIBDEPS) 99 +$(LLINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ \ 100 $(CXX_OBJS) cc1plus-checksum.o $(BACKEND) $(LIBS) $(BACKENDLIBS) 101 102ifeq ($(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 108else 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. 112$(srcdir)/cp/cfns.h: 113endif 114 gperf -o -C -E -k '1-6,$$' -j1 -D -N 'libc_name_p' -L C++ \ 115 $(srcdir)/cp/cfns.gperf --output-file $(srcdir)/cp/cfns.h 116 117# 118# Build hooks: 119 120c++.all.cross: g++-cross$(exeext) 121c++.start.encap: xg++$(exeext) 122c++.rest.encap: 123c++.info: 124c++.install-info: 125c++.dvi: 126c++.pdf: 127c++.install-pdf: 128c++.install-html: 129c++.html: 130c++.srcinfo: 131c++.srcextra: 132 133c++.tags: force 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 137 138c++.man: doc/g++.1 139 140c++.srcman: doc/g++.1 141 -cp -p $^ $(srcdir)/doc 142 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. 146check-c++ : check-g++ 147# Run the testsute in C++0x mode. 148check-c++0x: 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. 151check-g++-strict-gc: 152 $(MAKE) RUNTESTFLAGS="$(RUNTESTFLAGS) --extra_opts,--param,ggc-min-heapsize=0,--param,ggc-min-expand=0" \ 153 TESTSUITEDIR="$(TESTSUITEDIR).gc" check-g++ 154check-c++-subtargets : check-g++-subtargets 155# List of targets that can use the generic check- rule and its // variant. 156lang_checks += check-g++ 157lang_checks_parallelized += check-g++ 158# For description see comment above check_gcc_parallelize in gcc/Makefile.in. 159check_g++_parallelize = 10000 160# 161# Install hooks: 162# cc1plus is installed elsewhere as part of $(COMPILERS). 163 164# Install the driver program as $(target)-g++ and $(target)-c++, and 165# also as g++ and c++ if native. 166c++.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) ); \ 182 fi ; \ 183 fi; \ 184 fi 185 186# We can't use links because not everyone supports them. So just copy the 187# manpage. 188doc/g++.1: doc/gcc.1 189 cp $< doc/g++.1 190 191c++.install-man: $(DESTDIR)$(man1dir)/$(GXX_INSTALL_NAME)$(man1ext) 192 193$(DESTDIR)$(man1dir)/$(GXX_INSTALL_NAME)$(man1ext): doc/g++.1 installdirs 194 -rm -f $@ 195 -$(INSTALL_DATA) $< $@ 196 -chmod a-x $@ 197 198c++.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; \ 209 done 210 211c++.uninstall: 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) 215# 216# Clean hooks: 217# A lot of the ancillary files are deleted by the main makefile. 218# We just have to delete files specific to us. 219 220c++.mostlyclean: 221 -rm -f doc/g++.1 222 -rm -f cp/*$(objext) 223 -rm -f cp/*$(coverageexts) 224c++.clean: 225c++.distclean: 226 -rm -f cp/config.status cp/Makefile 227 -rm -f cxxmain.c 228c++.maintainer-clean: 229# 230# Stage hooks: 231# The main makefile has already created stage?/cp. 232 233c++.stage1: stage1-start 234 -mv cp/*$(objext) stage1/cp 235c++.stage2: stage2-start 236 -mv cp/*$(objext) stage2/cp 237c++.stage3: stage3-start 238 -mv cp/*$(objext) stage3/cp 239c++.stage4: stage4-start 240 -mv cp/*$(objext) stage4/cp 241c++.stageprofile: stageprofile-start 242 -mv cp/*$(objext) stageprofile/cp 243c++.stagefeedback: stagefeedback-start 244 -mv cp/*$(objext) stagefeedback/cp 245