common.mk 5.2 KB

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