common.mk 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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_MD5SUM=64bbe13301ffa6ba30c5c1ddec335583
  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_SHADOW.*,UCLIBC_HAS_SHADOW=$(if $(CONFIG_SHADOW_PASSWORDS),y,n),g' \
  70. -e 's,^.*UCLIBC_HAS_LOCALE.*,UCLIBC_HAS_LOCALE=$(if $(CONFIG_BUILD_NLS),y,n),g' \
  71. -e 's,^.*UCLIBC_BUILD_ALL_LOCALE.*,UCLIBC_BUILD_ALL_LOCALE=$(if $(CONFIG_BUILD_NLS),y,n),g' \
  72. -e 's,^.*UCLIBC_HAS_SSP[^_].*,UCLIBC_HAS_SSP=$(if $(or $(CONFIG_PKG_CC_STACKPROTECTOR_REGULAR),$(CONFIG_PKG_CC_STACKPROTECTOR_STRONG)),y,n),g' \
  73. $(HOST_BUILD_DIR)/.config.new
  74. cmp -s $(HOST_BUILD_DIR)/.config.new $(HOST_BUILD_DIR)/.config.last || { \
  75. cp $(HOST_BUILD_DIR)/.config.new $(HOST_BUILD_DIR)/.config && \
  76. $(MAKE) -C $(HOST_BUILD_DIR) oldconfig KBUILD_HAVE_NLS= HOSTCFLAGS="-DKBUILD_NO_NLS" && \
  77. $(MAKE) -C $(HOST_BUILD_DIR)/extra/config conf KBUILD_HAVE_NLS= HOSTCFLAGS="-DKBUILD_NO_NLS" && \
  78. cp $(HOST_BUILD_DIR)/.config.new $(HOST_BUILD_DIR)/.config.last; \
  79. }
  80. endef
  81. define Host/Clean
  82. rm -rf \
  83. $(HOST_BUILD_DIR) \
  84. $(BUILD_DIR_TOOLCHAIN)/$(PKG_NAME) \
  85. $(BUILD_DIR_TOOLCHAIN)/$(LIBC)-dev
  86. endef