1
0

common.mk 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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_VERSION:=$(call qstrip,$(CONFIG_UCLIBC_VERSION))
  10. PKG_NAME:=uClibc-ng
  11. PKG_SOURCE_URL = http://downloads.uclibc-ng.org/releases/$(PKG_VERSION)/
  12. PATCH_DIR:=$(PATH_PREFIX)/patches
  13. CONFIG_DIR:=$(PATH_PREFIX)/config
  14. PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
  15. LIBC_SO_VERSION:=$(PKG_VERSION)
  16. PKG_HASH:=3c63d9f8c8b98b65fa5c4040d1c8ab1b36e99a16e1093810cedad51ac15c9a9e
  17. HOST_BUILD_DIR:=$(BUILD_DIR_TOOLCHAIN)/$(PKG_NAME)-$(PKG_VERSION)
  18. include $(INCLUDE_DIR)/toolchain-build.mk
  19. UCLIBC_TARGET_ARCH:=$(shell echo $(ARCH) | sed -e s'/-.*//' \
  20. -e 's/arc.*/arc/' \
  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 $(filter archs,$(subst ",,$(CONFIG_CPU_TYPE))),hs, \
  38. $(if $(CONFIG_MIPS64_ABI),.$(subst ",,$(CONFIG_MIPS64_ABI)), \
  39. $(if $(CONFIG_HAS_SPE_FPU),$(if $(wildcard $(CONFIG_DIR)/$(ARCH).e500),.e500))))))
  40. CPU_CFLAGS = \
  41. -funsigned-char -fno-builtin -fno-asm \
  42. --std=gnu99 -ffunction-sections -fdata-sections \
  43. -Wno-unused-but-set-variable \
  44. $(TARGET_CFLAGS) -ggdb
  45. UCLIBC_MAKE = PATH='$(TOOLCHAIN_DIR)/initial/bin:$(TARGET_PATH)' $(MAKE) $(HOST_JOBS) -C $(HOST_BUILD_DIR) \
  46. $(TARGET_CONFIGURE_OPTS) \
  47. DEVEL_PREFIX=/ \
  48. RUNTIME_PREFIX=/ \
  49. HOSTCC="$(HOSTCC)" \
  50. CPU_CFLAGS="$(CPU_CFLAGS)" \
  51. ARCH="$(CONFIG_ARCH)" \
  52. LIBGCC="$(subst libgcc.a,libgcc_initial.a,$(shell $(TARGET_CC) -print-libgcc-file-name))" \
  53. DOSTRIP=""
  54. define Host/Prepare
  55. $(call Host/Prepare/Default)
  56. $(if $(strip $(QUILT)), \
  57. cd $(HOST_BUILD_DIR); \
  58. if $(QUILT_CMD) next >/dev/null 2>&1; then \
  59. $(QUILT_CMD) push -a; \
  60. fi
  61. )
  62. ln -snf $(PKG_NAME)-$(PKG_VERSION) $(BUILD_DIR_TOOLCHAIN)/$(PKG_NAME)
  63. endef
  64. define Host/Configure
  65. $(GEN_CONFIG) > $(HOST_BUILD_DIR)/.config.new
  66. $(SED) 's,^KERNEL_HEADERS=.*,KERNEL_HEADERS=\"$(BUILD_DIR_TOOLCHAIN)/linux-dev/include\",g' \
  67. -e 's,^.*UCLIBC_HAS_FPU.*,UCLIBC_HAS_FPU=$(if $(CONFIG_SOFT_FLOAT),n,y),g' \
  68. -e 's,^.*UCLIBC_HAS_SOFT_FLOAT.*,UCLIBC_HAS_SOFT_FLOAT=$(if $(CONFIG_SOFT_FLOAT),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