common.mk 3.4 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_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/avr32.*/avr32/g' \
  25. -e 's/m68k.*/m68k/' \
  26. -e 's/ppc/powerpc/g' \
  27. -e 's/v850.*/v850/g' \
  28. -e 's/sh64/sh/' \
  29. -e 's/sh[234].*/sh/' \
  30. -e 's/mips.*/mips/' \
  31. -e 's/mipsel.*/mips/' \
  32. -e 's/cris.*/cris/' \
  33. )
  34. GEN_CONFIG=$(SCRIPT_DIR)/kconfig.pl -n \
  35. $(if $(wildcard $(CONFIG_DIR)/common),'+' $(CONFIG_DIR)/common) \
  36. $(if $(CONFIG_UCLIBC_ENABLE_DEBUG),$(if $(wildcard $(CONFIG_DIR)/debug),'+' $(CONFIG_DIR)/debug)) \
  37. $(CONFIG_DIR)/$(ARCH)$(strip \
  38. $(if $(wildcard $(CONFIG_DIR)/$(ARCH).$(BOARD)),.$(BOARD), \
  39. $(if $(CONFIG_MIPS64_ABI),.$(subst ",,$(CONFIG_MIPS64_ABI)), \
  40. $(if $(CONFIG_HAS_SPE_FPU),$(if $(wildcard $(CONFIG_DIR)/$(ARCH).e500),.e500)))))
  41. CPU_CFLAGS = \
  42. -funsigned-char -fno-builtin -fno-asm \
  43. --std=gnu99 -ffunction-sections -fdata-sections \
  44. -Wno-unused-but-set-variable \
  45. $(TARGET_CFLAGS) -ggdb
  46. UCLIBC_MAKE = PATH='$(TOOLCHAIN_DIR)/initial/bin:$(TARGET_PATH)' $(MAKE) $(HOST_JOBS) -C $(HOST_BUILD_DIR) \
  47. $(TARGET_CONFIGURE_OPTS) \
  48. DEVEL_PREFIX=/ \
  49. RUNTIME_PREFIX=/ \
  50. HOSTCC="$(HOSTCC)" \
  51. CPU_CFLAGS="$(CPU_CFLAGS)" \
  52. ARCH="$(CONFIG_ARCH)" \
  53. LIBGCC="$(subst libgcc.a,libgcc_initial.a,$(shell $(TARGET_CC) -print-libgcc-file-name))" \
  54. DOSTRIP=""
  55. define Host/Prepare
  56. $(call Host/Prepare/Default)
  57. $(if $(strip $(QUILT)), \
  58. cd $(HOST_BUILD_DIR); \
  59. if $(QUILT_CMD) next >/dev/null 2>&1; then \
  60. $(QUILT_CMD) push -a; \
  61. fi
  62. )
  63. ln -snf $(PKG_NAME)-$(PKG_VERSION) $(BUILD_DIR_TOOLCHAIN)/$(PKG_NAME)
  64. endef
  65. define Host/Configure
  66. $(GEN_CONFIG) > $(HOST_BUILD_DIR)/.config.new
  67. $(SED) 's,^KERNEL_HEADERS=.*,KERNEL_HEADERS=\"$(BUILD_DIR_TOOLCHAIN)/linux-dev/include\",g' \
  68. -e 's,^.*UCLIBC_HAS_FPU.*,UCLIBC_HAS_FPU=$(if $(CONFIG_SOFT_FLOAT),n,y),g' \
  69. -e 's,^.*UCLIBC_HAS_SOFT_FLOAT.*,UCLIBC_HAS_SOFT_FLOAT=$(if $(CONFIG_SOFT_FLOAT),y,n),g' \
  70. -e 's,^.*UCLIBC_HAS_SHADOW.*,UCLIBC_HAS_SHADOW=$(if $(CONFIG_SHADOW_PASSWORDS),y,n),g' \
  71. -e 's,^.*UCLIBC_HAS_LOCALE.*,UCLIBC_HAS_LOCALE=$(if $(CONFIG_BUILD_NLS),y,n),g' \
  72. -e 's,^.*UCLIBC_BUILD_ALL_LOCALE.*,UCLIBC_BUILD_ALL_LOCALE=$(if $(CONFIG_BUILD_NLS),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