2017-05-12 Paolo Carlini <paolo.carlini@oracle.com>
[official-gcc.git] / gcc / cp / Make-lang.in
blob85834dd49cac4e5f2f859d00c0789897180912cb
1 # Top level -*- makefile -*- fragment for GNU C++.
2 #   Copyright (C) 1994-2017 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
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)
51 # Tell GNU make to ignore these if they exist.
52 .PHONY: c++
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 = 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 \
82  cp/constraint.o cp/logic.o $(CXX_C_OBJS)
84 ifeq ($(if $(wildcard ../stage_current),$(shell cat \
85   ../stage_current)),stageautofeedback)
86 $(CXX_AND_OBJCXX_OBJS): CFLAGS += -fauto-profile=cc1plus.fda
87 $(CXX_AND_OBJCXX_OBJS): cc1plus.fda
88 endif
90 # Language-specific object files for C++.
91 CXX_OBJS = cp/cp-lang.o c-family/stub-objc.o $(CXX_AND_OBJCXX_OBJS)
93 c++_OBJS = $(CXX_OBJS) cc1plus-checksum.o cp/g++spec.o
95 # Use strict warnings for this front end.
96 cp-warn = $(STRICT_WARN)
98 # compute checksum over all object files and the options
99 # re-use the checksum from the prev-final stage so it passes
100 # the bootstrap comparison and allows comparing of the cc1 binary
101 cc1plus-checksum.c : build/genchecksum$(build_exeext) checksum-options \
102         $(CXX_OBJS) $(BACKEND) $(LIBDEPS) 
103         if [ -f ../stage_final ] \
104            && cmp -s ../stage_current ../stage_final; then \
105            cp ../prev-gcc/cc1plus-checksum.c cc1plus-checksum.c; \
106         else \
107           build/genchecksum$(build_exeext) $(CXX_OBJS) $(BACKEND) $(LIBDEPS) \
108                      checksum-options > cc1plus-checksum.c.tmp &&          \
109           $(srcdir)/../move-if-change cc1plus-checksum.c.tmp cc1plus-checksum.c; \
110         fi
112 cc1plus$(exeext): $(CXX_OBJS) cc1plus-checksum.o $(BACKEND) $(LIBDEPS)
113         +$(LLINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ \
114               $(CXX_OBJS) cc1plus-checksum.o $(BACKEND) $(LIBS) $(BACKENDLIBS)
116 ifeq ($(ENABLE_MAINTAINER_RULES), true)
117 # Special build rule.  This is a maintainer rule, that is only
118 # available when GCC is configured with --enable-maintainer-mode.  In
119 # other cases, it is not available to avoid triggering rebuilds if a
120 # user has the source checked out with unusual timestamps.
121 $(srcdir)/cp/cfns.h: $(srcdir)/cp/cfns.gperf
122 else
123 # We keep the rule so that you can still force a rebuild, even if you
124 # didn't configure GCC with --enable-maintainer-mode, by manually
125 # deleting the $(srcdir)/cp/cfns.h file.
126 $(srcdir)/cp/cfns.h:
127 endif
128         gperf -o -C -E -k '1-6,$$' -j1 -D -N 'libc_name_p' -L C++ \
129                 $(srcdir)/cp/cfns.gperf --output-file $(srcdir)/cp/cfns.h
131 cc1plus.fda: ../stage1-gcc/cc1plus$(exeext) ../prev-gcc/$(PERF_DATA)
132         $(CREATE_GCOV) -binary ../stage1-gcc/cc1plus$(exeext) -gcov cc1plus.fda -profile ../prev-gcc/$(PERF_DATA) -gcov_version 1
135 # Build hooks:
137 c++.all.cross: g++-cross$(exeext)
138 c++.start.encap: xg++$(exeext)
139 c++.rest.encap:
140 c++.info:
141 c++.install-info:
142 c++.dvi:
143 c++.pdf:
144 c++.install-pdf:
145 c++.install-html:
146 c++.html:
147 c++.srcinfo:
148 c++.srcextra:
150 c++.tags: force
151         cd $(srcdir)/cp; etags -o TAGS.sub *.c *.cc *.h --language=none \
152           --regex='/DEFTREECODE [(]\([A-Z_]+\)/\1/' cp-tree.def; \
153         etags --include TAGS.sub --include ../TAGS.sub
155 c++.man: doc/g++.1
157 c++.srcman: doc/g++.1
158         -cp -p $^ $(srcdir)/doc
160 # 'make check' in gcc/ looks for check-c++, as do all toplevel C++-related
161 # check targets.  However, our DejaGNU framework requires 'check-g++' as its
162 # entry point.  We feed the former to the latter here.
163 check-c++ : check-g++
165 # Run the testsuite in C++1z mode.
166 check-c++1z:
167         $(MAKE) RUNTESTFLAGS="$(RUNTESTFLAGS)" GXX_TESTSUITE_STDS=1z check-g++
169 # Run the testsuite in all standard conformance levels.
170 check-c++-all:
171         $(MAKE) RUNTESTFLAGS="$(RUNTESTFLAGS) --stds=98,11,14,1z,concepts" check-g++
173 # Run the testsuite with garbage collection at every opportunity.
174 check-g++-strict-gc:
175         $(MAKE) RUNTESTFLAGS="$(RUNTESTFLAGS) --extra_opts,--param,ggc-min-heapsize=0,--param,ggc-min-expand=0" \
176           TESTSUITEDIR="$(TESTSUITEDIR).gc" check-g++
177 check-c++-subtargets : check-g++-subtargets
178 # List of targets that can use the generic check- rule and its // variant.
179 lang_checks += check-g++
180 lang_checks_parallelized += check-g++
181 # For description see the check_$lang_parallelize comment in gcc/Makefile.in.
182 check_g++_parallelize = 10000
184 # Install hooks:
185 # cc1plus is installed elsewhere as part of $(COMPILERS).
187 # Install the driver program as $(target)-g++ and $(target)-c++, and
188 # also as g++ and c++ if native.
189 c++.install-common: installdirs
190         -if test "$(enable_as_accelerator)" != "yes" ; then \
191           rm -f $(DESTDIR)$(bindir)/$(GXX_INSTALL_NAME)$(exeext); \
192           $(INSTALL_PROGRAM) xg++$(exeext) $(DESTDIR)$(bindir)/$(GXX_INSTALL_NAME)$(exeext); \
193           chmod a+x $(DESTDIR)$(bindir)/$(GXX_INSTALL_NAME)$(exeext); \
194           rm -f $(DESTDIR)$(bindir)/$(CXX_INSTALL_NAME)$(exeext); \
195           ( cd $(DESTDIR)$(bindir) && \
196             $(LN) $(GXX_INSTALL_NAME)$(exeext) $(CXX_INSTALL_NAME)$(exeext) ); \
197           if [ -f cc1plus$(exeext) ] ; then \
198             if [ ! -f g++-cross$(exeext) ] ; then \
199               rm -f $(DESTDIR)$(bindir)/$(GXX_TARGET_INSTALL_NAME)$(exeext); \
200               ( cd $(DESTDIR)$(bindir) && \
201                 $(LN) $(GXX_INSTALL_NAME)$(exeext) $(GXX_TARGET_INSTALL_NAME)$(exeext) ); \
202               rm -f $(DESTDIR)$(bindir)/$(CXX_TARGET_INSTALL_NAME)$(exeext); \
203               ( cd $(DESTDIR)$(bindir) && \
204                 $(LN) $(CXX_INSTALL_NAME)$(exeext) $(CXX_TARGET_INSTALL_NAME)$(exeext) ); \
205             fi ; \
206           fi; \
207         fi
209 # We can't use links because not everyone supports them.  So just copy the
210 # manpage.
211 doc/g++.1: doc/gcc.1
212         cp $< doc/g++.1
214 c++.install-man: $(DESTDIR)$(man1dir)/$(GXX_INSTALL_NAME)$(man1ext)
216 $(DESTDIR)$(man1dir)/$(GXX_INSTALL_NAME)$(man1ext): doc/g++.1 installdirs
217         -rm -f $@
218         -$(INSTALL_DATA) $< $@
219         -chmod a-x $@
221 c++.install-plugin: installdirs
222 # We keep the directory structure for files in config and .def files. All
223 # other files are flattened to a single directory.
224         headers="$(CP_PLUGIN_HEADERS)"; \
225         for file in $$headers; do \
226           path=$(srcdir)/cp/$$file; \
227           dest=$(plugin_includedir)/cp/$$file; \
228           echo $(INSTALL_DATA) $$path $(DESTDIR)$$dest; \
229           dir=`dirname $$dest`; \
230           $(mkinstalldirs) $(DESTDIR)$$dir; \
231           $(INSTALL_DATA) $$path $(DESTDIR)$$dest; \
232         done
234 c++.uninstall:
235         -rm -rf $(DESTDIR)$(bindir)/$(CXX_INSTALL_NAME)$(exeext)
236         -rm -rf $(DESTDIR)$(bindir)/$(GXX_INSTALL_NAME)$(exeext)
237         -rm -rf $(DESTDIR)$(man1dir)/$(GXX_INSTALL_NAME)$(man1ext)
239 # Clean hooks:
240 # A lot of the ancillary files are deleted by the main makefile.
241 # We just have to delete files specific to us.
243 c++.mostlyclean:
244         -rm -f doc/g++.1
245         -rm -f cp/*$(objext)
246         -rm -f cp/*$(coverageexts)
247         -rm -f xg++$(exeext) g++-cross$(exeext) cc1plus$(exeext) cc1plus.fda
248 c++.clean:
249 c++.distclean:
250         -rm -f cp/config.status cp/Makefile
251         -rm -f cxxmain.c
252 c++.maintainer-clean:
254 # Stage hooks:
255 # The main makefile has already created stage?/cp.
257 c++.stage1: stage1-start
258         -mv cp/*$(objext) stage1/cp
259 c++.stage2: stage2-start
260         -mv cp/*$(objext) stage2/cp
261 c++.stage3: stage3-start
262         -mv cp/*$(objext) stage3/cp
263 c++.stage4: stage4-start
264         -mv cp/*$(objext) stage4/cp
265 c++.stageprofile: stageprofile-start
266         -mv cp/*$(objext) stageprofile/cp
267 c++.stagefeedback: stagefeedback-start
268         -mv cp/*$(objext) stagefeedback/cp
269 c++.autostageprofile: stageprofile-start
270         -mv cp/*$(objext) autostageprofile/cp
271 c++.autostagefeedback: stagefeedback-start
272         -mv cp/*$(objext) autostagefeedback/cp