common.mk 5.7 KB

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