common.mk 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  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-2010 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 ($(CONFIG_GCC_VERSION),"linaro")
  37. PKG_REV:=4.5-2011.02-0
  38. PKG_VERSION:=4.5.2
  39. PKG_SOURCE_URL:=http://launchpad.net/gcc-linaro/4.5/4.5-2011.02-0/+download/
  40. PKG_SOURCE:=$(PKG_NAME)-linaro-$(PKG_REV).tar.bz2
  41. PKG_MD5SUM:=d93199c1296e053f57fcc7888b54d488
  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.3.3)
  48. PKG_MD5SUM:=cc3c5565fdb9ab87a05ddb106ba0bd1f
  49. endif
  50. ifeq ($(PKG_VERSION),4.3.5)
  51. PKG_MD5SUM:=e588cfde3bf323f82918589b94f14a15
  52. endif
  53. ifeq ($(PKG_VERSION),4.4.1)
  54. PKG_MD5SUM:=927eaac3d44b22f31f9c83df82f26436
  55. endif
  56. ifeq ($(PKG_VERSION),4.4.5)
  57. PKG_MD5SUM:=44b3192c4c584b9be5243d9e8e7e0ed1
  58. endif
  59. ifeq ($(PKG_VERSION),4.5.2)
  60. PKG_MD5SUM:=d6559145853fbaaa0fd7556ed93bce9a
  61. endif
  62. endif
  63. endif
  64. PATCH_DIR=../patches/$(GCC_VERSION)
  65. BUGURL=https://dev.openwrt.org/
  66. include $(INCLUDE_DIR)/toolchain-build.mk
  67. HOST_SOURCE_DIR:=$(HOST_BUILD_DIR)
  68. ifeq ($(GCC_VARIANT),minimal)
  69. GCC_BUILD_DIR:=$(HOST_BUILD_DIR)-$(GCC_VARIANT)
  70. else
  71. HOST_BUILD_DIR:=$(HOST_BUILD_DIR)-$(GCC_VARIANT)
  72. GCC_BUILD_DIR:=$(HOST_BUILD_DIR)
  73. endif
  74. HOST_STAMP_PREPARED:=$(HOST_BUILD_DIR)/.prepared
  75. HOST_STAMP_BUILT:=$(GCC_BUILD_DIR)/.built
  76. HOST_STAMP_CONFIGURED:=$(GCC_BUILD_DIR)/.configured
  77. HOST_STAMP_INSTALLED:=$(STAGING_DIR_HOST)/stamp/.gcc_$(GCC_VARIANT)_installed
  78. SEP:=,
  79. TARGET_LANGUAGES:="c$(if $(CONFIG_INSTALL_LIBSTDCPP),$(SEP)c++)$(if $(CONFIG_INSTALL_LIBGCJ),$(SEP)java)"
  80. export libgcc_cv_fixed_point=no
  81. ifdef CONFIG_USE_UCLIBC
  82. export glibcxx_cv_c99_math_tr1=no
  83. endif
  84. GCC_CONFIGURE:= \
  85. SHELL="$(BASH)" \
  86. $(HOST_SOURCE_DIR)/configure \
  87. --prefix=$(TOOLCHAIN_DIR) \
  88. --build=$(GNU_HOST_NAME) \
  89. --host=$(GNU_HOST_NAME) \
  90. --target=$(REAL_GNU_TARGET_NAME) \
  91. --with-gnu-ld \
  92. --enable-target-optspace \
  93. --disable-libgomp \
  94. --disable-libmudflap \
  95. --disable-multilib \
  96. --disable-nls \
  97. $(GRAPHITE_CONFIGURE) \
  98. $(if $(CONFIG_GCC_USE_GRAPHITE),--with-host-libstdcxx=-lstdc++) \
  99. $(SOFT_FLOAT_CONFIG_OPTION) \
  100. $(call qstrip,$(CONFIG_EXTRA_GCC_CONFIG_OPTIONS)) \
  101. $(if $(CONFIG_mips64)$(CONFIG_mips64el),--with-arch=mips64 --with-abi=64) \
  102. $(if $(CONFIG_GCC_VERSION_LLVM),--enable-llvm=$(BUILD_DIR_BASE)/host/llvm) \
  103. $(if $(CONFIG_GCC_VERSION_4_3_3_CS)$(CONFIG_GCC_VERSION_4_4_1_CS),--enable-poison-system-directories)
  104. ifneq ($(CONFIG_GCC_VERSION_4_4)$(CONFIG_GCC_VERSION_4_5),)
  105. ifneq ($(CONFIG_mips)$(CONFIG_mipsel),)
  106. GCC_CONFIGURE += --with-mips-plt
  107. endif
  108. endif
  109. ifeq ($(CONFIG_GCC_LLVM),)
  110. GCC_BUILD_TARGET_LIBGCC:=y
  111. GCC_CONFIGURE+= \
  112. --with-gmp=$(TOPDIR)/staging_dir/host \
  113. --with-mpfr=$(TOPDIR)/staging_dir/host \
  114. --disable-decimal-float
  115. endif
  116. ifneq ($(CONFIG_GCC_VERSION_4_5),)
  117. GCC_BUILD_TARGET_LIBGCC:=y
  118. GCC_CONFIGURE+= \
  119. --with-gmp=$(TOPDIR)/staging_dir/host \
  120. --with-mpc=$(TOPDIR)/staging_dir/host \
  121. --with-mpfr=$(TOPDIR)/staging_dir/host \
  122. --disable-decimal-float
  123. endif
  124. ifneq ($(CONFIG_SSP_SUPPORT),)
  125. GCC_CONFIGURE+= \
  126. --enable-libssp
  127. else
  128. GCC_CONFIGURE+= \
  129. --disable-libssp
  130. endif
  131. ifneq ($(CONFIG_EXTRA_TARGET_ARCH),)
  132. GCC_CONFIGURE+= \
  133. --enable-biarch \
  134. --enable-targets=$(call qstrip,$(CONFIG_EXTRA_TARGET_ARCH_NAME))-linux-$(TARGET_SUFFIX)
  135. endif
  136. ifdef CONFIG_sparc
  137. GCC_CONFIGURE+= --enable-targets=all
  138. endif
  139. ifeq ($(LIBC),uClibc)
  140. GCC_CONFIGURE+= \
  141. --disable-__cxa_atexit
  142. else
  143. GCC_CONFIGURE+= \
  144. --enable-__cxa_atexit
  145. endif
  146. ifdef CONFIG_powerpc
  147. TARGET_CFLAGS := $(patsubst -Os,-O2,$(TARGET_CFLAGS))
  148. endif
  149. ifneq ($(GCC_ARCH),)
  150. GCC_CONFIGURE+= --with-arch=$(GCC_ARCH)
  151. endif
  152. GCC_MAKE:= \
  153. export SHELL="$(BASH)"; \
  154. $(MAKE) $(TOOLCHAIN_JOBS) \
  155. CFLAGS_FOR_TARGET="$(TARGET_CFLAGS)" \
  156. CXXFLAGS_FOR_TARGET="$(TARGET_CFLAGS)"
  157. define Host/Prepare
  158. mkdir -p $(GCC_BUILD_DIR)
  159. endef
  160. define Host/Configure
  161. (cd $(GCC_BUILD_DIR) && rm -f config.cache; \
  162. $(GCC_CONFIGURE) \
  163. );
  164. endef
  165. define Host/Clean
  166. rm -rf \
  167. $(STAGING_DIR_HOST)/stamp/.gcc_* \
  168. $(STAGING_DIR_HOST)/stamp/.binutils_* \
  169. $(GCC_BUILD_DIR) \
  170. $(BUILD_DIR_TOOLCHAIN)/$(PKG_NAME) \
  171. $(TOOLCHAIN_DIR)/$(REAL_GNU_TARGET_NAME) \
  172. $(TOOLCHAIN_DIR)/bin/$(REAL_GNU_TARGET_NAME)-gc* \
  173. $(TOOLCHAIN_DIR)/bin/$(REAL_GNU_TARGET_NAME)-c*
  174. endef