common.mk 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. #
  2. # Copyright (C) 2006-2012 OpenWrt.org
  3. #
  4. # This is free software, licensed under the GNU General Public License v2.
  5. # See /LICENSE for more information.
  6. #
  7. include $(TOPDIR)/rules.mk
  8. include $(INCLUDE_DIR)/target.mk
  9. PKG_NAME:=uClibc
  10. PKG_VERSION:=$(call qstrip,$(CONFIG_UCLIBC_VERSION))
  11. PKG_SOURCE_URL:=http://www.uclibc.org/downloads
  12. PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
  13. LIBC_SO_VERSION:=$(PKG_VERSION)
  14. PATCH_DIR:=$(PATH_PREFIX)/patches-$(PKG_VERSION)
  15. CONFIG_DIR:=$(PATH_PREFIX)/config-$(PKG_VERSION)
  16. PKG_MD5SUM_0.9.33.2 = a338aaffc56f0f5040e6d9fa8a12eda1
  17. PKG_MD5SUM=$(PKG_MD5SUM_$(PKG_VERSION))
  18. HOST_BUILD_DIR:=$(BUILD_DIR_TOOLCHAIN)/$(PKG_NAME)-$(PKG_VERSION)
  19. include $(INCLUDE_DIR)/toolchain-build.mk
  20. UCLIBC_TARGET_ARCH:=$(shell echo $(ARCH) | sed -e s'/-.*//' \
  21. -e 's/i.86/i386/' \
  22. -e 's/sparc.*/sparc/' \
  23. -e 's/arm.*/arm/g' \
  24. -e 's/m68k.*/m68k/' \
  25. -e 's/ppc/powerpc/g' \
  26. -e 's/v850.*/v850/g' \
  27. -e 's/sh64/sh/' \
  28. -e 's/sh[234].*/sh/' \
  29. -e 's/mips.*/mips/' \
  30. -e 's/mipsel.*/mips/' \
  31. )
  32. GEN_CONFIG=$(SCRIPT_DIR)/kconfig.pl -n \
  33. $(if $(wildcard $(CONFIG_DIR)/common),'+' $(CONFIG_DIR)/common) \
  34. $(if $(CONFIG_UCLIBC_ENABLE_DEBUG),$(if $(wildcard $(CONFIG_DIR)/debug),'+' $(CONFIG_DIR)/debug)) \
  35. $(CONFIG_DIR)/$(ARCH)$(strip \
  36. $(if $(wildcard $(CONFIG_DIR)/$(ARCH).$(BOARD)),.$(BOARD), \
  37. $(if $(CONFIG_MIPS64_ABI),.$(subst ",,$(CONFIG_MIPS64_ABI)), \
  38. $(if $(CONFIG_HAS_SPE_FPU),$(if $(wildcard $(CONFIG_DIR)/$(ARCH).e500),.e500)))))
  39. CPU_CFLAGS = \
  40. -funsigned-char -fno-builtin -fno-asm \
  41. --std=gnu99 -ffunction-sections -fdata-sections \
  42. -Wno-unused-but-set-variable \
  43. $(TARGET_CFLAGS) -ggdb
  44. UCLIBC_MAKE = PATH='$(TOOLCHAIN_DIR)/initial/bin:$(TARGET_PATH)' $(MAKE) $(HOST_JOBS) -C $(HOST_BUILD_DIR) \
  45. $(TARGET_CONFIGURE_OPTS) \
  46. DEVEL_PREFIX=/ \
  47. RUNTIME_PREFIX=/ \
  48. HOSTCC="$(HOSTCC)" \
  49. CPU_CFLAGS="$(CPU_CFLAGS)" \
  50. ARCH="$(CONFIG_ARCH)" \
  51. LIBGCC="$(subst libgcc.a,libgcc_initial.a,$(shell $(TARGET_CC) -print-libgcc-file-name))" \
  52. DOSTRIP=""
  53. define Host/Prepare
  54. $(call Host/Prepare/Default)
  55. $(if $(strip $(QUILT)), \
  56. cd $(HOST_BUILD_DIR); \
  57. if $(QUILT_CMD) next >/dev/null 2>&1; then \
  58. $(QUILT_CMD) push -a; \
  59. fi
  60. )
  61. ln -snf $(PKG_NAME)-$(PKG_VERSION) $(BUILD_DIR_TOOLCHAIN)/$(PKG_NAME)
  62. endef
  63. define Host/Configure
  64. $(GEN_CONFIG) > $(HOST_BUILD_DIR)/.config.new
  65. $(SED) 's,^KERNEL_HEADERS=.*,KERNEL_HEADERS=\"$(BUILD_DIR_TOOLCHAIN)/linux-dev/include\",g' \
  66. -e 's,^.*UCLIBC_HAS_FPU.*,UCLIBC_HAS_FPU=$(if $(CONFIG_SOFT_FLOAT),n,y),g' \
  67. -e 's,^.*UCLIBC_HAS_SOFT_FLOAT.*,UCLIBC_HAS_SOFT_FLOAT=$(if $(CONFIG_SOFT_FLOAT),y,n),g' \
  68. -e 's,^.*UCLIBC_HAS_SHADOW.*,UCLIBC_HAS_SHADOW=$(if $(CONFIG_SHADOW_PASSWORDS),y,n),g' \
  69. -e 's,^.*UCLIBC_HAS_LOCALE.*,UCLIBC_HAS_LOCALE=$(if $(CONFIG_BUILD_NLS),y,n),g' \
  70. -e 's,^.*UCLIBC_BUILD_ALL_LOCALE.*,UCLIBC_BUILD_ALL_LOCALE=$(if $(CONFIG_BUILD_NLS),y,n),g' \
  71. -e 's,^.*UCLIBC_HAS_SSP[^_].*,UCLIBC_HAS_SSP=$(if $(or $(CONFIG_PKG_CC_STACKPROTECTOR_REGULAR),$(CONFIG_PKG_CC_STACKPROTECTOR_STRONG)),y,n),g' \
  72. $(HOST_BUILD_DIR)/.config.new
  73. cmp -s $(HOST_BUILD_DIR)/.config.new $(HOST_BUILD_DIR)/.config.last || { \
  74. cp $(HOST_BUILD_DIR)/.config.new $(HOST_BUILD_DIR)/.config && \
  75. $(MAKE) -C $(HOST_BUILD_DIR) oldconfig KBUILD_HAVE_NLS= HOSTCFLAGS="-DKBUILD_NO_NLS" && \
  76. $(MAKE) -C $(HOST_BUILD_DIR)/extra/config conf KBUILD_HAVE_NLS= HOSTCFLAGS="-DKBUILD_NO_NLS" && \
  77. cp $(HOST_BUILD_DIR)/.config.new $(HOST_BUILD_DIR)/.config.last; \
  78. }
  79. endef
  80. define Host/Clean
  81. rm -rf \
  82. $(HOST_BUILD_DIR) \
  83. $(BUILD_DIR_TOOLCHAIN)/$(PKG_NAME) \
  84. $(BUILD_DIR_TOOLCHAIN)/$(LIBC)-dev
  85. endef