common.mk 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. #
  2. # Copyright (C) 2002-2003 Erik Andersen <andersen@uclibc.org>
  3. # Copyright (C) 2004 Manuel Novoa III <mjn3@uclibc.org>
  4. # Copyright (C) 2005-2006 Felix Fietkau <nbd@nbd.name>
  5. # Copyright (C) 2006-2014 OpenWrt.org
  6. #
  7. # This program is free software; you can redistribute it and/or modify
  8. # it under the terms of the GNU General Public License as published by
  9. # the Free Software Foundation; either version 2 of the License, or
  10. # (at your option) any later version.
  11. #
  12. # This program is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. # General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU General Public License
  18. # along with this program; if not, write to the Free Software
  19. # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  20. include $(TOPDIR)/rules.mk
  21. PKG_NAME:=gcc
  22. GCC_VERSION:=$(call qstrip,$(CONFIG_GCC_VERSION))
  23. PKG_VERSION:=$(firstword $(subst +, ,$(GCC_VERSION)))
  24. GCC_DIR:=$(PKG_NAME)-$(PKG_VERSION)
  25. PKG_SOURCE_URL:=@GNU/gcc/gcc-$(PKG_VERSION)
  26. PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
  27. ifeq ($(PKG_VERSION),5.5.0)
  28. PKG_HASH:=530cea139d82fe542b358961130c69cfde8b3d14556370b65823d2f91f0ced87
  29. endif
  30. ifeq ($(PKG_VERSION),7.5.0)
  31. PKG_HASH:=b81946e7f01f90528a1f7352ab08cc602b9ccc05d4e44da4bd501c5a189ee661
  32. endif
  33. ifeq ($(PKG_VERSION),8.3.0)
  34. PKG_HASH:=64baadfe6cc0f4947a84cb12d7f0dfaf45bb58b7e92461639596c21e02d97d2c
  35. endif
  36. PATCH_DIR=../patches/$(GCC_VERSION)
  37. BUGURL=http://bugs.openwrt.org/
  38. PKGVERSION=libreCMC GCC $(PKG_VERSION) $(REVISION)
  39. HOST_BUILD_PARALLEL:=1
  40. include $(INCLUDE_DIR)/toolchain-build.mk
  41. HOST_SOURCE_DIR:=$(HOST_BUILD_DIR)
  42. ifeq ($(GCC_VARIANT),minimal)
  43. GCC_BUILD_DIR:=$(HOST_BUILD_DIR)-$(GCC_VARIANT)
  44. else
  45. HOST_BUILD_DIR:=$(HOST_BUILD_DIR)-$(GCC_VARIANT)
  46. GCC_BUILD_DIR:=$(HOST_BUILD_DIR)
  47. endif
  48. HOST_STAMP_PREPARED:=$(HOST_BUILD_DIR)/.prepared
  49. HOST_STAMP_BUILT:=$(GCC_BUILD_DIR)/.built
  50. HOST_STAMP_CONFIGURED:=$(GCC_BUILD_DIR)/.configured
  51. HOST_STAMP_INSTALLED:=$(HOST_BUILD_PREFIX)/stamp/.gcc_$(GCC_VARIANT)_installed
  52. SEP:=,
  53. TARGET_LANGUAGES:="c,c++$(if $(CONFIG_INSTALL_GFORTRAN),$(SEP)fortran)$(if $(CONFIG_INSTALL_GCCGO),$(SEP)go)"
  54. TAR_OPTIONS += \
  55. --exclude-from='$(CURDIR)/../exclude-testsuite' --exclude=gcc/ada/*.ad* \
  56. --exclude=libjava
  57. export libgcc_cv_fixed_point=no
  58. ifdef CONFIG_USE_UCLIBC
  59. export glibcxx_cv_c99_math_tr1=no
  60. endif
  61. ifdef CONFIG_INSTALL_GCCGO
  62. export libgo_cv_c_split_stack_supported=no
  63. endif
  64. ifdef CONFIG_GCC_USE_GRAPHITE
  65. GRAPHITE_CONFIGURE:= --with-isl=$(TOPDIR)/staging_dir/host
  66. else
  67. GRAPHITE_CONFIGURE:= --without-isl --without-cloog
  68. endif
  69. GCC_CONFIGURE:= \
  70. SHELL="$(BASH)" \
  71. $(if $(shell gcc --version 2>&1 | grep -E "Apple.(LLVM|clang)"), \
  72. CFLAGS="-O2 -fbracket-depth=512 -pipe" \
  73. CXXFLAGS="-O2 -fbracket-depth=512 -pipe" \
  74. ) \
  75. $(HOST_SOURCE_DIR)/configure \
  76. --with-bugurl=$(BUGURL) \
  77. --with-pkgversion="$(PKGVERSION)" \
  78. --prefix=$(TOOLCHAIN_DIR) \
  79. --build=$(GNU_HOST_NAME) \
  80. --host=$(GNU_HOST_NAME) \
  81. --target=$(REAL_GNU_TARGET_NAME) \
  82. --with-gnu-ld \
  83. --enable-target-optspace \
  84. --disable-libgomp \
  85. --disable-libmudflap \
  86. --disable-multilib \
  87. --disable-libmpx \
  88. --disable-nls \
  89. $(GRAPHITE_CONFIGURE) \
  90. --with-host-libstdcxx=-lstdc++ \
  91. $(SOFT_FLOAT_CONFIG_OPTION) \
  92. $(call qstrip,$(CONFIG_EXTRA_GCC_CONFIG_OPTIONS)) \
  93. $(if $(CONFIG_mips64)$(CONFIG_mips64el),--with-arch=mips64 \
  94. --with-abi=$(call qstrip,$(CONFIG_MIPS64_ABI))) \
  95. $(if $(CONFIG_arc),--with-cpu=$(CONFIG_CPU_TYPE)) \
  96. --with-gmp=$(TOPDIR)/staging_dir/host \
  97. --with-mpfr=$(TOPDIR)/staging_dir/host \
  98. --with-mpc=$(TOPDIR)/staging_dir/host \
  99. --disable-decimal-float \
  100. --with-diagnostics-color=auto-if-env
  101. ifneq ($(CONFIG_mips)$(CONFIG_mipsel),)
  102. GCC_CONFIGURE += --with-mips-plt
  103. endif
  104. ifneq ($(CONFIG_GCC_DEFAULT_PIE),)
  105. GCC_CONFIGURE+= \
  106. --enable-default-pie
  107. endif
  108. ifneq ($(CONFIG_GCC_DEFAULT_SSP),)
  109. GCC_CONFIGURE+= \
  110. --enable-default-ssp
  111. endif
  112. ifneq ($(CONFIG_GCC_LIBSSP),)
  113. GCC_CONFIGURE+= \
  114. --enable-libssp
  115. else
  116. GCC_CONFIGURE+= \
  117. --disable-libssp
  118. endif
  119. ifneq ($(CONFIG_EXTRA_TARGET_ARCH),)
  120. GCC_CONFIGURE+= \
  121. --enable-biarch \
  122. --enable-targets=$(call qstrip,$(CONFIG_EXTRA_TARGET_ARCH_NAME))-linux-$(TARGET_SUFFIX)
  123. endif
  124. ifdef CONFIG_sparc
  125. GCC_CONFIGURE+= \
  126. --enable-targets=all \
  127. --with-long-double-128
  128. endif
  129. ifeq ($(LIBC),uClibc)
  130. GCC_CONFIGURE+= \
  131. --disable-__cxa_atexit
  132. else
  133. GCC_CONFIGURE+= \
  134. --enable-__cxa_atexit
  135. endif
  136. ifneq ($(GCC_ARCH),)
  137. GCC_CONFIGURE+= --with-arch=$(GCC_ARCH)
  138. endif
  139. ifeq ($(CONFIG_arm),y)
  140. GCC_CONFIGURE+= \
  141. --with-cpu=$(word 1, $(subst +," ,$(CONFIG_CPU_TYPE)))
  142. ifneq ($(CONFIG_SOFT_FLOAT),y)
  143. GCC_CONFIGURE+= \
  144. --with-fpu=$(word 2, $(subst +, ",$(CONFIG_CPU_TYPE))) \
  145. --with-float=hard
  146. endif
  147. # Do not let TARGET_CFLAGS get poisoned by extra CPU optimization flags
  148. # that do not belong here. The cpu,fpu type should be specified via
  149. # --with-cpu and --with-fpu for ARM and not CFLAGS.
  150. TARGET_CFLAGS:=$(filter-out -m%,$(call qstrip,$(TARGET_CFLAGS)))
  151. endif
  152. ifeq ($(CONFIG_TARGET_x86)$(CONFIG_USE_GLIBC)$(CONFIG_INSTALL_GCCGO),yyy)
  153. TARGET_CFLAGS+=-fno-split-stack
  154. endif
  155. GCC_MAKE:= \
  156. export SHELL="$(BASH)"; \
  157. $(MAKE) \
  158. CFLAGS="$(HOST_CFLAGS)" \
  159. CFLAGS_FOR_TARGET="$(TARGET_CFLAGS)" \
  160. CXXFLAGS_FOR_TARGET="$(TARGET_CFLAGS)" \
  161. GOCFLAGS_FOR_TARGET="$(TARGET_CFLAGS)"
  162. define Host/SetToolchainInfo
  163. $(SED) 's,TARGET_CROSS=.*,TARGET_CROSS=$(REAL_GNU_TARGET_NAME)-,' $(TOOLCHAIN_DIR)/info.mk
  164. $(SED) 's,GCC_VERSION=.*,GCC_VERSION=$(GCC_VERSION),' $(TOOLCHAIN_DIR)/info.mk
  165. endef
  166. ifneq ($(GCC_PREPARE),)
  167. define Host/Prepare
  168. $(call Host/SetToolchainInfo)
  169. $(call Host/Prepare/Default)
  170. ln -snf $(GCC_DIR) $(BUILD_DIR_TOOLCHAIN)/$(PKG_NAME)
  171. $(CP) $(SCRIPT_DIR)/config.{guess,sub} $(HOST_SOURCE_DIR)/
  172. $(SED) 's,^MULTILIB_OSDIRNAMES,# MULTILIB_OSDIRNAMES,' $(HOST_SOURCE_DIR)/gcc/config/*/t-*
  173. $(SED) 'd' $(HOST_SOURCE_DIR)/gcc/DEV-PHASE
  174. $(SED) 's, DATESTAMP,,' $(HOST_SOURCE_DIR)/gcc/version.c
  175. #(cd $(HOST_SOURCE_DIR)/libstdc++-v3; autoconf;);
  176. $(SED) 's,gcc_no_link=yes,gcc_no_link=no,' $(HOST_SOURCE_DIR)/libstdc++-v3/configure
  177. mkdir -p $(GCC_BUILD_DIR)
  178. endef
  179. else
  180. define Host/Prepare
  181. mkdir -p $(GCC_BUILD_DIR)
  182. endef
  183. endif
  184. define Host/Configure
  185. (cd $(GCC_BUILD_DIR) && rm -f config.cache; \
  186. $(GCC_CONFIGURE) \
  187. );
  188. endef
  189. define Host/Clean
  190. rm -rf $(if $(GCC_PREPARE),$(HOST_SOURCE_DIR)) \
  191. $(HOST_BUILD_PREFIX)/stamp/.gcc_* \
  192. $(HOST_BUILD_PREFIX)/stamp/.binutils_* \
  193. $(GCC_BUILD_DIR) \
  194. $(BUILD_DIR_TOOLCHAIN)/$(PKG_NAME) \
  195. $(TOOLCHAIN_DIR)/$(REAL_GNU_TARGET_NAME) \
  196. $(TOOLCHAIN_DIR)/bin/$(REAL_GNU_TARGET_NAME)-gc* \
  197. $(TOOLCHAIN_DIR)/bin/$(REAL_GNU_TARGET_NAME)-c*
  198. endef