common.mk 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  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-2012 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. ifdef CONFIG_GCC_VERSION_LLVM
  26. PKG_SOURCE_VERSION:=c98c494b72ff875884c0c7286be67f16f9f6d7ab
  27. PKG_REV:=83504
  28. GCC_DIR:=llvm-gcc-4.2-r$(PKG_REV)
  29. PKG_VERSION:=4.2.1
  30. PKG_SOURCE:=$(GCC_DIR).tar.gz
  31. PKG_SOURCE_PROTO:=git
  32. PKG_SOURCE_URL:=git://repo.or.cz/llvm-gcc-4.2.git
  33. PKG_SOURCE_SUBDIR:=$(GCC_DIR)
  34. HOST_BUILD_DIR:=$(BUILD_DIR_TOOLCHAIN)/$(GCC_DIR)
  35. else
  36. ifeq ($(findstring linaro, $(CONFIG_GCC_VERSION)),linaro)
  37. ifeq ($(CONFIG_GCC_VERSION),"4.5-linaro")
  38. PKG_REV:=4.5-2012.02
  39. PKG_VERSION:=4.5.4
  40. PKG_VERSION_MAJOR:=4.5
  41. PKG_MD5SUM:=e05be9ea8eca2ad4c859d35dbab568e7
  42. endif
  43. ifeq ($(CONFIG_GCC_VERSION),"4.6-linaro")
  44. PKG_REV:=4.6-2012.02
  45. PKG_VERSION:=4.6.3
  46. PKG_VERSION_MAJOR:=4.6
  47. PKG_MD5SUM:=2b7887846f8e5ac1ca58fe4dfaabf5a6
  48. endif
  49. ifeq ($(CONFIG_GCC_VERSION),"4.7-linaro")
  50. PKG_REV:=4.7-2012.04
  51. PKG_VERSION:=4.7.1
  52. PKG_VERSION_MAJOR:=4.7
  53. PKG_MD5SUM:=6dab459c1177fc9ae2969e7a39549d44
  54. endif
  55. PKG_SOURCE_URL:=http://launchpad.net/gcc-linaro/$(PKG_VERSION_MAJOR)/$(PKG_REV)/+download/
  56. PKG_SOURCE:=$(PKG_NAME)-linaro-$(PKG_REV).tar.bz2
  57. GCC_DIR:=gcc-linaro-$(PKG_REV)
  58. HOST_BUILD_DIR:=$(BUILD_DIR_TOOLCHAIN)/$(GCC_DIR)
  59. else
  60. PKG_SOURCE_URL:=@GNU/gcc/gcc-$(PKG_VERSION)
  61. PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
  62. ifeq ($(PKG_VERSION),4.4.7)
  63. PKG_MD5SUM:=295709feb4441b04e87dea3f1bab4281
  64. endif
  65. ifeq ($(PKG_VERSION),4.6.2)
  66. PKG_MD5SUM:=028115c4fbfb6cfd75d6369f4a90d87e
  67. endif
  68. ifeq ($(PKG_VERSION),4.7.0)
  69. PKG_MD5SUM:=2a0f1d99fda235c29d40b561f81d9a77
  70. endif
  71. endif
  72. endif
  73. PATCH_DIR=../patches/$(GCC_VERSION)
  74. BUGURL=https://dev.openwrt.org/
  75. include $(INCLUDE_DIR)/toolchain-build.mk
  76. HOST_SOURCE_DIR:=$(HOST_BUILD_DIR)
  77. ifeq ($(GCC_VARIANT),minimal)
  78. GCC_BUILD_DIR:=$(HOST_BUILD_DIR)-$(GCC_VARIANT)
  79. else
  80. HOST_BUILD_DIR:=$(HOST_BUILD_DIR)-$(GCC_VARIANT)
  81. GCC_BUILD_DIR:=$(HOST_BUILD_DIR)
  82. endif
  83. HOST_STAMP_PREPARED:=$(HOST_BUILD_DIR)/.prepared
  84. HOST_STAMP_BUILT:=$(GCC_BUILD_DIR)/.built
  85. HOST_STAMP_CONFIGURED:=$(GCC_BUILD_DIR)/.configured
  86. HOST_STAMP_INSTALLED:=$(STAGING_DIR_HOST)/stamp/.gcc_$(GCC_VARIANT)_installed
  87. SEP:=,
  88. TARGET_LANGUAGES:="c$(if $(CONFIG_INSTALL_LIBSTDCPP),$(SEP)c++)$(if $(CONFIG_INSTALL_LIBGCJ),$(SEP)java)$(if $(CONFIG_INSTALL_GFORTRAN),$(SEP)fortran)"
  89. export libgcc_cv_fixed_point=no
  90. ifdef CONFIG_USE_UCLIBC
  91. export glibcxx_cv_c99_math_tr1=no
  92. endif
  93. GCC_CONFIGURE:= \
  94. SHELL="$(BASH)" \
  95. $(HOST_SOURCE_DIR)/configure \
  96. --prefix=$(TOOLCHAIN_DIR) \
  97. --build=$(GNU_HOST_NAME) \
  98. --host=$(GNU_HOST_NAME) \
  99. --target=$(REAL_GNU_TARGET_NAME) \
  100. --with-gnu-ld \
  101. --enable-target-optspace \
  102. --disable-libgomp \
  103. --disable-libmudflap \
  104. --disable-multilib \
  105. --disable-nls \
  106. $(GRAPHITE_CONFIGURE) \
  107. --with-host-libstdcxx=-lstdc++ \
  108. $(SOFT_FLOAT_CONFIG_OPTION) \
  109. $(call qstrip,$(CONFIG_EXTRA_GCC_CONFIG_OPTIONS)) \
  110. $(if $(CONFIG_mips64)$(CONFIG_mips64el),--with-arch=mips64 --with-abi=64) \
  111. $(if $(CONFIG_GCC_VERSION_LLVM),--enable-llvm=$(BUILD_DIR_BASE)/host/llvm) \
  112. ifeq ($(CONFIG_GCC_LLVM),)
  113. GCC_BUILD_TARGET_LIBGCC:=y
  114. GCC_CONFIGURE+= \
  115. --with-gmp=$(TOPDIR)/staging_dir/host \
  116. --with-mpfr=$(TOPDIR)/staging_dir/host \
  117. --disable-decimal-float
  118. ifneq ($(CONFIG_mips)$(CONFIG_mipsel),)
  119. GCC_CONFIGURE += --with-mips-plt
  120. endif
  121. endif
  122. ifneq ($(CONFIG_GCC_VERSION_4_5)$(CONFIG_GCC_VERSION_4_6),)
  123. GCC_CONFIGURE+= \
  124. --with-mpc=$(TOPDIR)/staging_dir/host
  125. endif
  126. ifneq ($(CONFIG_SSP_SUPPORT),)
  127. GCC_CONFIGURE+= \
  128. --enable-libssp
  129. else
  130. GCC_CONFIGURE+= \
  131. --disable-libssp
  132. endif
  133. ifneq ($(CONFIG_EXTRA_TARGET_ARCH),)
  134. GCC_CONFIGURE+= \
  135. --enable-biarch \
  136. --enable-targets=$(call qstrip,$(CONFIG_EXTRA_TARGET_ARCH_NAME))-linux-$(TARGET_SUFFIX)
  137. endif
  138. ifdef CONFIG_sparc
  139. GCC_CONFIGURE+= --enable-targets=all
  140. endif
  141. ifeq ($(LIBC),uClibc)
  142. GCC_CONFIGURE+= \
  143. --disable-__cxa_atexit
  144. else
  145. GCC_CONFIGURE+= \
  146. --enable-__cxa_atexit
  147. endif
  148. ifneq ($(GCC_ARCH),)
  149. GCC_CONFIGURE+= --with-arch=$(GCC_ARCH)
  150. endif
  151. GCC_MAKE:= \
  152. export SHELL="$(BASH)"; \
  153. $(MAKE) $(TOOLCHAIN_JOBS) \
  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