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