2 # Copyright (C) 2006-2020 OpenWrt.org
4 # This is free software, licensed under the GNU General Public License v2.
5 # See /LICENSE for more information.
7 include $(TOPDIR)/rules.mk
8 include $(INCLUDE_DIR)/target.mk
14 PKG_SOURCE_URL = http://downloads.uclibc-ng.org/releases/$(PKG_VERSION)/
15 PATCH_DIR:=$(PATH_PREFIX)/patches
16 CONFIG_DIR:=$(PATH_PREFIX)/config
17 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
18 LIBC_SO_VERSION:=$(PKG_VERSION)
20 PKG_HASH:=e6776229eee8d3f5a1cd29fb4286630e3cb9e97dded4e8f4a3a9bb4fa8c0d5e3
22 HOST_BUILD_DIR:=$(BUILD_DIR_TOOLCHAIN)/$(PKG_NAME)-$(PKG_VERSION)
24 include $(INCLUDE_DIR)/toolchain-build.mk
26 UCLIBC_TARGET_ARCH:=$(shell echo $(ARCH) | sed -e s'/-.*//' \
29 -e 's/sparc.*/sparc/' \
32 -e 's/ppc/powerpc/g' \
33 -e 's/v850.*/v850/g' \
35 -e 's/sh[234].*/sh/' \
37 -e 's/mipsel.*/mips/' \
40 GEN_CONFIG=$(SCRIPT_DIR)/kconfig.pl -n \
41 $(if $(wildcard $(CONFIG_DIR)/common),'+' $(CONFIG_DIR)/common) \
42 $(if $(CONFIG_UCLIBC_ENABLE_DEBUG),$(if $(wildcard $(CONFIG_DIR)/debug),'+' $(CONFIG_DIR)/debug)) \
43 $(CONFIG_DIR)/$(ARCH)$(strip \
44 $(if $(wildcard $(CONFIG_DIR)/$(ARCH).$(BOARD)),.$(BOARD), \
45 $(if $(filter archs,$(subst ",,$(CONFIG_CPU_TYPE))),hs, \
46 $(if $(CONFIG_MIPS64_ABI),.$(subst ",,$(CONFIG_MIPS64_ABI)), \
47 $(if $(CONFIG_HAS_SPE_FPU),$(if $(wildcard $(CONFIG_DIR)/$(ARCH).e500),.e500))))))
50 -funsigned-char -fno-builtin -fno-asm \
51 --std=gnu99 -ffunction-sections -fdata-sections \
52 -Wno-unused-but-set-variable \
53 $(TARGET_CFLAGS) -ggdb
55 UCLIBC_MAKE = PATH='$(TOOLCHAIN_DIR)/initial/bin:$(TARGET_PATH)' $(MAKE) $(HOST_JOBS) -C $(HOST_BUILD_DIR) \
56 $(TARGET_CONFIGURE_OPTS) \
60 CPU_CFLAGS="$(CPU_CFLAGS)" \
61 ARCH="$(CONFIG_ARCH)" \
62 LIBGCC="$(subst libgcc.a,libgcc_initial.a,$(shell $(TARGET_CC) -print-libgcc-file-name))" \
66 $(call Host/Prepare/Default)
67 $(if $(strip $(QUILT)), \
68 cd $(HOST_BUILD_DIR); \
69 if $(QUILT_CMD) next >/dev/null 2>&1; then \
70 $(QUILT_CMD) push -a; \
73 ln -snf $(PKG_NAME)-$(PKG_VERSION) $(BUILD_DIR_TOOLCHAIN)/$(PKG_NAME)
77 $(GEN_CONFIG) > $(HOST_BUILD_DIR)/.config.new
78 $(SED) 's,^KERNEL_HEADERS=.*,KERNEL_HEADERS=\"$(BUILD_DIR_TOOLCHAIN)/linux-dev/include\",g' \
79 -e 's,^.*UCLIBC_HAS_FPU.*,UCLIBC_HAS_FPU=$(if $(CONFIG_SOFT_FLOAT),n,y),g' \
80 -e 's,^.*UCLIBC_HAS_SOFT_FLOAT.*,UCLIBC_HAS_SOFT_FLOAT=$(if $(CONFIG_SOFT_FLOAT),y,n),g' \
81 -e 's,^.*UCLIBC_HAS_LOCALE.*,UCLIBC_HAS_LOCALE=$(if $(CONFIG_BUILD_NLS),y,n),g' \
82 -e 's,^.*UCLIBC_BUILD_ALL_LOCALE.*,UCLIBC_BUILD_ALL_LOCALE=$(if $(CONFIG_BUILD_NLS),y,n),g' \
83 -e 's,^.*UCLIBC_HAS_SSP[^_].*,UCLIBC_HAS_SSP=$(if $(or $(CONFIG_PKG_CC_STACKPROTECTOR_REGULAR),$(CONFIG_PKG_CC_STACKPROTECTOR_STRONG)),y,n),g' \
84 $(HOST_BUILD_DIR)/.config.new
85 cmp -s $(HOST_BUILD_DIR)/.config.new $(HOST_BUILD_DIR)/.config.last || { \
86 cp $(HOST_BUILD_DIR)/.config.new $(HOST_BUILD_DIR)/.config && \
87 $(MAKE) -C $(HOST_BUILD_DIR) olddefconfig KBUILD_HAVE_NLS= HOSTCFLAGS="-DKBUILD_NO_NLS" && \
88 $(MAKE) -C $(HOST_BUILD_DIR)/extra/config conf KBUILD_HAVE_NLS= HOSTCFLAGS="-DKBUILD_NO_NLS" && \
89 cp $(HOST_BUILD_DIR)/.config.new $(HOST_BUILD_DIR)/.config.last; \
96 $(BUILD_DIR_TOOLCHAIN)/$(PKG_NAME) \
97 $(BUILD_DIR_TOOLCHAIN)/$(LIBC)-dev