common.mk 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  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@openwrt.org>
  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. ifeq ($(findstring linaro, $(CONFIG_GCC_VERSION)),linaro)
  26. LINARO_RELEASE:=
  27. ifeq ($(CONFIG_GCC_VERSION),"4.6-linaro")
  28. PKG_REV:=4.6-2013.05
  29. PKG_VERSION:=4.6.4
  30. PKG_VERSION_MAJOR:=4.6
  31. PKG_MD5SUM:=26b48802ae1203cd99415026fbf56ed7
  32. PKG_COMP:=bz2
  33. endif
  34. ifeq ($(CONFIG_GCC_VERSION),"4.8-linaro")
  35. PKG_REV:=4.8-2014.04
  36. PKG_VERSION:=4.8.3
  37. PKG_VERSION_MAJOR:=4.8
  38. PKG_MD5SUM:=5ba2f3a449b1658ccc09d27cc7ab3c03
  39. PKG_COMP:=xz
  40. endif
  41. ifneq ($(LINARO_RELEASE),)
  42. PKG_SOURCE_URL:=http://releases.linaro.org/$(LINARO_RELEASE)/components/toolchain/gcc-linaro/$(PKG_VERSION_MAJOR)
  43. else
  44. PKG_SOURCE_URL:=http://launchpad.net/gcc-linaro/$(PKG_VERSION_MAJOR)/$(PKG_REV)/+download/
  45. endif
  46. PKG_SOURCE:=$(PKG_NAME)-linaro-$(PKG_REV).tar.$(PKG_COMP)
  47. GCC_DIR:=gcc-linaro-$(PKG_REV)
  48. HOST_BUILD_DIR:=$(BUILD_DIR_TOOLCHAIN)/$(GCC_DIR)
  49. else
  50. PKG_SOURCE_URL:=@GNU/gcc/gcc-$(PKG_VERSION)
  51. PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
  52. ifeq ($(PKG_VERSION),4.6.3)
  53. PKG_MD5SUM:=773092fe5194353b02bb0110052a972e
  54. endif
  55. ifeq ($(PKG_VERSION),4.8.0)
  56. PKG_MD5SUM:=e6040024eb9e761c3bea348d1fa5abb0
  57. endif
  58. endif
  59. PATCH_DIR=../patches/$(GCC_VERSION)
  60. BUGURL=https://dev.openwrt.org/
  61. ifeq ($(findstring linaro, $(CONFIG_GCC_VERSION)),linaro)
  62. PKGVERSION=OpenWrt/Linaro GCC $(PKG_REV) $(REVISION)
  63. else
  64. PKGVERSION=OpenWrt GCC $(PKG_VERSION) $(REVISION)
  65. endif
  66. HOST_BUILD_PARALLEL:=1
  67. include $(INCLUDE_DIR)/toolchain-build.mk
  68. HOST_SOURCE_DIR:=$(HOST_BUILD_DIR)
  69. ifeq ($(GCC_VARIANT),minimal)
  70. GCC_BUILD_DIR:=$(HOST_BUILD_DIR)-$(GCC_VARIANT)
  71. else
  72. HOST_BUILD_DIR:=$(HOST_BUILD_DIR)-$(GCC_VARIANT)
  73. GCC_BUILD_DIR:=$(HOST_BUILD_DIR)
  74. endif
  75. HOST_STAMP_PREPARED:=$(HOST_BUILD_DIR)/.prepared
  76. HOST_STAMP_BUILT:=$(GCC_BUILD_DIR)/.built
  77. HOST_STAMP_CONFIGURED:=$(GCC_BUILD_DIR)/.configured
  78. HOST_STAMP_INSTALLED:=$(STAGING_DIR_HOST)/stamp/.gcc_$(GCC_VARIANT)_installed
  79. SEP:=,
  80. TARGET_LANGUAGES:="c,c++$(if $(CONFIG_INSTALL_LIBGCJ),$(SEP)java)$(if $(CONFIG_INSTALL_GFORTRAN),$(SEP)fortran)"
  81. export libgcc_cv_fixed_point=no
  82. ifdef CONFIG_USE_UCLIBC
  83. export glibcxx_cv_c99_math_tr1=no
  84. endif
  85. GCC_CONFIGURE:= \
  86. SHELL="$(BASH)" \
  87. $(if $(shell gcc --version 2>&1 | grep LLVM), \
  88. CFLAGS="-O2 -fbracket-depth=512 -pipe" \
  89. CXXFLAGS="-O2 -fbracket-depth=512 -pipe" \
  90. ) \
  91. $(HOST_SOURCE_DIR)/configure \
  92. --with-bugurl=$(BUGURL) \
  93. --with-pkgversion="$(PKGVERSION)" \
  94. --prefix=$(TOOLCHAIN_DIR) \
  95. --build=$(GNU_HOST_NAME) \
  96. --host=$(GNU_HOST_NAME) \
  97. --target=$(REAL_GNU_TARGET_NAME) \
  98. --with-gnu-ld \
  99. --enable-target-optspace \
  100. --disable-libgomp \
  101. --disable-libmudflap \
  102. --disable-multilib \
  103. --disable-nls \
  104. $(GRAPHITE_CONFIGURE) \
  105. --with-host-libstdcxx=-lstdc++ \
  106. $(SOFT_FLOAT_CONFIG_OPTION) \
  107. $(call qstrip,$(CONFIG_EXTRA_GCC_CONFIG_OPTIONS)) \
  108. $(if $(CONFIG_mips64)$(CONFIG_mips64el),--with-arch=mips64 \
  109. --with-abi=$(subst ",,$(CONFIG_MIPS64_ABI))) \
  110. --with-gmp=$(TOPDIR)/staging_dir/host \
  111. --with-mpfr=$(TOPDIR)/staging_dir/host \
  112. --with-mpc=$(TOPDIR)/staging_dir/host \
  113. --disable-decimal-float
  114. ifneq ($(CONFIG_mips)$(CONFIG_mipsel),)
  115. GCC_CONFIGURE += --with-mips-plt
  116. endif
  117. ifneq ($(CONFIG_SSP_SUPPORT),)
  118. GCC_CONFIGURE+= \
  119. --enable-libssp
  120. else
  121. GCC_CONFIGURE+= \
  122. --disable-libssp
  123. endif
  124. ifneq ($(CONFIG_EXTRA_TARGET_ARCH),)
  125. GCC_CONFIGURE+= \
  126. --enable-biarch \
  127. --enable-targets=$(call qstrip,$(CONFIG_EXTRA_TARGET_ARCH_NAME))-linux-$(TARGET_SUFFIX)
  128. endif
  129. ifdef CONFIG_sparc
  130. GCC_CONFIGURE+= \
  131. --enable-targets=all \
  132. --with-long-double-128
  133. endif
  134. ifeq ($(LIBC),uClibc)
  135. GCC_CONFIGURE+= \
  136. --disable-__cxa_atexit
  137. else
  138. GCC_CONFIGURE+= \
  139. --enable-__cxa_atexit
  140. endif
  141. ifneq ($(GCC_ARCH),)
  142. GCC_CONFIGURE+= --with-arch=$(GCC_ARCH)
  143. endif
  144. ifneq ($(CONFIG_SOFT_FLOAT),y)
  145. ifeq ($(CONFIG_arm),y)
  146. GCC_CONFIGURE+= \
  147. --with-float=hard
  148. endif
  149. endif
  150. GCC_MAKE:= \
  151. export SHELL="$(BASH)"; \
  152. $(MAKE) \
  153. CFLAGS="$(HOST_CFLAGS)" \
  154. CFLAGS_FOR_TARGET="$(TARGET_CFLAGS)" \
  155. CXXFLAGS_FOR_TARGET="$(TARGET_CFLAGS)"
  156. define Host/Prepare
  157. mkdir -p $(GCC_BUILD_DIR)
  158. endef
  159. define Host/Configure
  160. (cd $(GCC_BUILD_DIR) && rm -f config.cache; \
  161. $(GCC_CONFIGURE) \
  162. );
  163. endef
  164. define Host/Clean
  165. rm -rf \
  166. $(STAGING_DIR_HOST)/stamp/.gcc_* \
  167. $(STAGING_DIR_HOST)/stamp/.binutils_* \
  168. $(GCC_BUILD_DIR) \
  169. $(BUILD_DIR_TOOLCHAIN)/$(PKG_NAME) \
  170. $(TOOLCHAIN_DIR)/$(REAL_GNU_TARGET_NAME) \
  171. $(TOOLCHAIN_DIR)/bin/$(REAL_GNU_TARGET_NAME)-gc* \
  172. $(TOOLCHAIN_DIR)/bin/$(REAL_GNU_TARGET_NAME)-c*
  173. endef