Make-lang.in 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. # Top level -*- makefile -*- fragment for GNU C++.
  2. # Copyright (C) 1994-2015 Free Software Foundation, Inc.
  3. #This file is part of GCC.
  4. #GCC is free software; you can redistribute it and/or modify
  5. #it under the terms of the GNU General Public License as published by
  6. #the Free Software Foundation; either version 3, or (at your option)
  7. #any later version.
  8. #GCC is distributed in the hope that it will be useful,
  9. #but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. #GNU General Public License for more details.
  12. # You should have received a copy of the GNU General Public License
  13. # along with GCC; see the file COPYING3. If not see
  14. # <http://www.gnu.org/licenses/>.
  15. # This file provides the language dependent support in the main Makefile.
  16. # Each language makefile fragment must provide the following targets:
  17. #
  18. # foo.all.cross, foo.start.encap, foo.rest.encap,
  19. # foo.install-common, foo.install-man, foo.install-info, foo.install-pdf,
  20. # foo.install-html, foo.info, foo.dvi, foo.pdf, foo.html, foo.uninstall,
  21. # foo.mostlyclean, foo.clean, foo.distclean,
  22. # foo.maintainer-clean, foo.stage1, foo.stage2, foo.stage3, foo.stage4
  23. #
  24. # where `foo' is the name of the language.
  25. #
  26. # It should also provide rules for:
  27. #
  28. # - making any compiler driver (eg: g++)
  29. # - the compiler proper (eg: cc1plus)
  30. # - define the names for selecting the language in LANGUAGES.
  31. # Actual names to use when installing a native compiler.
  32. CXX_INSTALL_NAME := $(shell echo c++|sed '$(program_transform_name)')
  33. GXX_INSTALL_NAME := $(shell echo g++|sed '$(program_transform_name)')
  34. CXX_TARGET_INSTALL_NAME := $(target_noncanonical)-$(shell echo c++|sed '$(program_transform_name)')
  35. GXX_TARGET_INSTALL_NAME := $(target_noncanonical)-$(shell echo g++|sed '$(program_transform_name)')
  36. CP_PLUGIN_HEADERS := cp-tree.h cxx-pretty-print.h name-lookup.h type-utils.h
  37. #
  38. # Define the names for selecting c++ in LANGUAGES.
  39. # Note that it would be nice to move the dependency on g++
  40. # into the C++ rule, but that needs a little bit of work
  41. # to do the right thing within all.cross.
  42. c++: cc1plus$(exeext)
  43. # Tell GNU make to ignore these if they exist.
  44. .PHONY: c++
  45. CFLAGS-cp/g++spec.o += $(DRIVER_DEFINES)
  46. # Create the compiler driver for g++.
  47. GXX_OBJS = $(GCC_OBJS) cp/g++spec.o
  48. xg++$(exeext): $(GXX_OBJS) $(EXTRA_GCC_OBJS) libcommon-target.a $(LIBDEPS)
  49. +$(LINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ \
  50. $(GXX_OBJS) $(EXTRA_GCC_OBJS) libcommon-target.a \
  51. $(EXTRA_GCC_LIBS) $(LIBS)
  52. # Create a version of the g++ driver which calls the cross-compiler.
  53. g++-cross$(exeext): xg++$(exeext)
  54. -rm -f g++-cross$(exeext)
  55. cp xg++$(exeext) g++-cross$(exeext)
  56. # The compiler itself.
  57. # Shared with C front end:
  58. CXX_C_OBJS = attribs.o incpath.o \
  59. $(C_COMMON_OBJS) $(CXX_TARGET_OBJS)
  60. # Language-specific object files for C++ and Objective C++.
  61. CXX_AND_OBJCXX_OBJS = cp/call.o cp/decl.o cp/expr.o cp/pt.o cp/typeck2.o \
  62. cp/class.o cp/decl2.o cp/error.o cp/lex.o cp/parser.o cp/ptree.o cp/rtti.o \
  63. cp/typeck.o cp/cvt.o cp/except.o cp/friend.o cp/init.o cp/method.o \
  64. cp/search.o cp/semantics.o cp/tree.o cp/repo.o cp/dump.o cp/optimize.o \
  65. cp/mangle.o cp/cp-objcp-common.o cp/name-lookup.o cp/cxx-pretty-print.o \
  66. cp/cp-cilkplus.o \
  67. cp/cp-gimplify.o cp/cp-array-notation.o cp/lambda.o \
  68. cp/vtable-class-hierarchy.o cp/constexpr.o cp/cp-ubsan.o $(CXX_C_OBJS)
  69. # Language-specific object files for C++.
  70. CXX_OBJS = cp/cp-lang.o c-family/stub-objc.o $(CXX_AND_OBJCXX_OBJS)
  71. c++_OBJS = $(CXX_OBJS) cc1plus-checksum.o cp/g++spec.o
  72. # Use strict warnings for this front end.
  73. cp-warn = $(STRICT_WARN)
  74. # compute checksum over all object files and the options
  75. cc1plus-checksum.c : build/genchecksum$(build_exeext) checksum-options \
  76. $(CXX_OBJS) $(BACKEND) $(LIBDEPS)
  77. build/genchecksum$(build_exeext) $(CXX_OBJS) $(BACKEND) $(LIBDEPS) \
  78. checksum-options > cc1plus-checksum.c.tmp && \
  79. $(srcdir)/../move-if-change cc1plus-checksum.c.tmp cc1plus-checksum.c
  80. cc1plus$(exeext): $(CXX_OBJS) cc1plus-checksum.o $(BACKEND) $(LIBDEPS)
  81. +$(LLINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ \
  82. $(CXX_OBJS) cc1plus-checksum.o $(BACKEND) $(LIBS) $(BACKENDLIBS)
  83. ifeq ($(ENABLE_MAINTAINER_RULES), true)
  84. # Special build rule. This is a maintainer rule, that is only
  85. # available when GCC is configured with --enable-maintainer-mode. In
  86. # other cases, it is not available to avoid triggering rebuilds if a
  87. # user has the source checked out with unusual timestamps.
  88. $(srcdir)/cp/cfns.h: $(srcdir)/cp/cfns.gperf
  89. else
  90. # We keep the rule so that you can still force a rebuild, even if you
  91. # didn't configure GCC with --enable-maintainer-mode, by manually
  92. # deleting the $(srcdir)/cp/cfns.h file.
  93. $(srcdir)/cp/cfns.h:
  94. endif
  95. gperf -o -C -E -k '1-6,$$' -j1 -D -N 'libc_name_p' -L ANSI-C \
  96. $(srcdir)/cp/cfns.gperf --output-file $(srcdir)/cp/cfns.h
  97. #
  98. # Build hooks:
  99. c++.all.cross: g++-cross$(exeext)
  100. c++.start.encap: xg++$(exeext)
  101. c++.rest.encap:
  102. c++.info:
  103. c++.install-info:
  104. c++.dvi:
  105. c++.pdf:
  106. c++.install-pdf:
  107. c++.install-html:
  108. c++.html:
  109. c++.srcinfo:
  110. c++.srcextra:
  111. c++.tags: force
  112. cd $(srcdir)/cp; etags -o TAGS.sub *.c *.h --language=none \
  113. --regex='/DEFTREECODE [(]\([A-Z_]+\)/\1/' cp-tree.def; \
  114. etags --include TAGS.sub --include ../TAGS.sub
  115. c++.man: doc/g++.1
  116. c++.srcman: doc/g++.1
  117. -cp -p $^ $(srcdir)/doc
  118. # 'make check' in gcc/ looks for check-c++, as do all toplevel C++-related
  119. # check targets. However, our DejaGNU framework requires 'check-g++' as its
  120. # entry point. We feed the former to the latter here.
  121. check-c++ : check-g++
  122. # Run the testsute in C++0x mode.
  123. check-c++0x:
  124. @echo Normal 'make check' now runs the testsuite in C++11 mode as well as C++98.
  125. # Run the testsuite with garbage collection at every opportunity.
  126. check-g++-strict-gc:
  127. $(MAKE) RUNTESTFLAGS="$(RUNTESTFLAGS) --extra_opts,--param,ggc-min-heapsize=0,--param,ggc-min-expand=0" \
  128. TESTSUITEDIR="$(TESTSUITEDIR).gc" check-g++
  129. check-c++-subtargets : check-g++-subtargets
  130. # List of targets that can use the generic check- rule and its // variant.
  131. lang_checks += check-g++
  132. lang_checks_parallelized += check-g++
  133. # For description see comment above check_gcc_parallelize in gcc/Makefile.in.
  134. check_g++_parallelize = 10000
  135. #
  136. # Install hooks:
  137. # cc1plus is installed elsewhere as part of $(COMPILERS).
  138. # Install the driver program as $(target)-g++ and $(target)-c++, and
  139. # also as g++ and c++ if native.
  140. c++.install-common: installdirs
  141. -if test "$(enable_as_accelerator)" != "yes" ; then \
  142. rm -f $(DESTDIR)$(bindir)/$(GXX_INSTALL_NAME)$(exeext); \
  143. $(INSTALL_PROGRAM) xg++$(exeext) $(DESTDIR)$(bindir)/$(GXX_INSTALL_NAME)$(exeext); \
  144. chmod a+x $(DESTDIR)$(bindir)/$(GXX_INSTALL_NAME)$(exeext); \
  145. rm -f $(DESTDIR)$(bindir)/$(CXX_INSTALL_NAME)$(exeext); \
  146. ( cd $(DESTDIR)$(bindir) && \
  147. $(LN) $(GXX_INSTALL_NAME)$(exeext) $(CXX_INSTALL_NAME)$(exeext) ); \
  148. if [ -f cc1plus$(exeext) ] ; then \
  149. if [ ! -f g++-cross$(exeext) ] ; then \
  150. rm -f $(DESTDIR)$(bindir)/$(GXX_TARGET_INSTALL_NAME)$(exeext); \
  151. ( cd $(DESTDIR)$(bindir) && \
  152. $(LN) $(GXX_INSTALL_NAME)$(exeext) $(GXX_TARGET_INSTALL_NAME)$(exeext) ); \
  153. rm -f $(DESTDIR)$(bindir)/$(CXX_TARGET_INSTALL_NAME)$(exeext); \
  154. ( cd $(DESTDIR)$(bindir) && \
  155. $(LN) $(CXX_INSTALL_NAME)$(exeext) $(CXX_TARGET_INSTALL_NAME)$(exeext) ); \
  156. fi ; \
  157. fi; \
  158. fi
  159. # We can't use links because not everyone supports them. So just copy the
  160. # manpage.
  161. doc/g++.1: doc/gcc.1
  162. cp $< doc/g++.1
  163. c++.install-man: $(DESTDIR)$(man1dir)/$(GXX_INSTALL_NAME)$(man1ext)
  164. $(DESTDIR)$(man1dir)/$(GXX_INSTALL_NAME)$(man1ext): doc/g++.1 installdirs
  165. -rm -f $@
  166. -$(INSTALL_DATA) $< $@
  167. -chmod a-x $@
  168. c++.install-plugin: installdirs
  169. # We keep the directory structure for files in config and .def files. All
  170. # other files are flattened to a single directory.
  171. headers="$(CP_PLUGIN_HEADERS)"; \
  172. for file in $$headers; do \
  173. path=$(srcdir)/cp/$$file; \
  174. dest=$(plugin_includedir)/cp/$$file; \
  175. echo $(INSTALL_DATA) $$path $(DESTDIR)$$dest; \
  176. dir=`dirname $$dest`; \
  177. $(mkinstalldirs) $(DESTDIR)$$dir; \
  178. $(INSTALL_DATA) $$path $(DESTDIR)$$dest; \
  179. done
  180. c++.uninstall:
  181. -rm -rf $(DESTDIR)$(bindir)/$(CXX_INSTALL_NAME)$(exeext)
  182. -rm -rf $(DESTDIR)$(bindir)/$(GXX_INSTALL_NAME)$(exeext)
  183. -rm -rf $(DESTDIR)$(man1dir)/$(GXX_INSTALL_NAME)$(man1ext)
  184. #
  185. # Clean hooks:
  186. # A lot of the ancillary files are deleted by the main makefile.
  187. # We just have to delete files specific to us.
  188. c++.mostlyclean:
  189. -rm -f doc/g++.1
  190. -rm -f cp/*$(objext)
  191. -rm -f cp/*$(coverageexts)
  192. c++.clean:
  193. c++.distclean:
  194. -rm -f cp/config.status cp/Makefile
  195. -rm -f cxxmain.c
  196. c++.maintainer-clean:
  197. #
  198. # Stage hooks:
  199. # The main makefile has already created stage?/cp.
  200. c++.stage1: stage1-start
  201. -mv cp/*$(objext) stage1/cp
  202. c++.stage2: stage2-start
  203. -mv cp/*$(objext) stage2/cp
  204. c++.stage3: stage3-start
  205. -mv cp/*$(objext) stage3/cp
  206. c++.stage4: stage4-start
  207. -mv cp/*$(objext) stage4/cp
  208. c++.stageprofile: stageprofile-start
  209. -mv cp/*$(objext) stageprofile/cp
  210. c++.stagefeedback: stagefeedback-start
  211. -mv cp/*$(objext) stagefeedback/cp