toolchain/gcc: add 6.1.0
[openwrt/openwrt.git] / toolchain / uClibc / common.mk
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
10 PKG_VERSION:=$(call qstrip,$(CONFIG_UCLIBC_VERSION))
11
12 PKG_NAME:=uClibc-ng
13 PKG_SOURCE_URL = http://downloads.uclibc-ng.org/releases/$(PKG_VERSION)/
14 PATCH_DIR:=$(PATH_PREFIX)/patches
15 CONFIG_DIR:=$(PATH_PREFIX)/config
16 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
17 LIBC_SO_VERSION:=$(PKG_VERSION)
18
19 PKG_MD5SUM=8eed7f3635216142c1c5e122874b89c6
20
21 HOST_BUILD_DIR:=$(BUILD_DIR_TOOLCHAIN)/$(PKG_NAME)-$(PKG_VERSION)
22
23 include $(INCLUDE_DIR)/toolchain-build.mk
24
25 UCLIBC_TARGET_ARCH:=$(shell echo $(ARCH) | sed -e s'/-.*//' \
26 -e 's/arc.*/arc/' \
27 -e 's/i.86/i386/' \
28 -e 's/sparc.*/sparc/' \
29 -e 's/arm.*/arm/g' \
30 -e 's/m68k.*/m68k/' \
31 -e 's/ppc/powerpc/g' \
32 -e 's/v850.*/v850/g' \
33 -e 's/sh64/sh/' \
34 -e 's/sh[234].*/sh/' \
35 -e 's/mips.*/mips/' \
36 -e 's/mipsel.*/mips/' \
37 )
38
39 GEN_CONFIG=$(SCRIPT_DIR)/kconfig.pl -n \
40 $(if $(wildcard $(CONFIG_DIR)/common),'+' $(CONFIG_DIR)/common) \
41 $(if $(CONFIG_UCLIBC_ENABLE_DEBUG),$(if $(wildcard $(CONFIG_DIR)/debug),'+' $(CONFIG_DIR)/debug)) \
42 $(CONFIG_DIR)/$(ARCH)$(strip \
43 $(if $(wildcard $(CONFIG_DIR)/$(ARCH).$(BOARD)),.$(BOARD), \
44 $(if $(filter archs,$(subst ",,$(CONFIG_CPU_TYPE))),hs, \
45 $(if $(CONFIG_MIPS64_ABI),.$(subst ",,$(CONFIG_MIPS64_ABI)), \
46 $(if $(CONFIG_HAS_SPE_FPU),$(if $(wildcard $(CONFIG_DIR)/$(ARCH).e500),.e500))))))
47
48 CPU_CFLAGS = \
49 -funsigned-char -fno-builtin -fno-asm \
50 --std=gnu99 -ffunction-sections -fdata-sections \
51 -Wno-unused-but-set-variable \
52 $(TARGET_CFLAGS) -ggdb
53
54 UCLIBC_MAKE = PATH='$(TOOLCHAIN_DIR)/initial/bin:$(TARGET_PATH)' $(MAKE) $(HOST_JOBS) -C $(HOST_BUILD_DIR) \
55 $(TARGET_CONFIGURE_OPTS) \
56 DEVEL_PREFIX=/ \
57 RUNTIME_PREFIX=/ \
58 HOSTCC="$(HOSTCC)" \
59 CPU_CFLAGS="$(CPU_CFLAGS)" \
60 ARCH="$(CONFIG_ARCH)" \
61 LIBGCC="$(subst libgcc.a,libgcc_initial.a,$(shell $(TARGET_CC) -print-libgcc-file-name))" \
62 DOSTRIP=""
63
64 define Host/Prepare
65 $(call Host/Prepare/Default)
66 $(if $(strip $(QUILT)), \
67 cd $(HOST_BUILD_DIR); \
68 if $(QUILT_CMD) next >/dev/null 2>&1; then \
69 $(QUILT_CMD) push -a; \
70 fi
71 )
72 ln -snf $(PKG_NAME)-$(PKG_VERSION) $(BUILD_DIR_TOOLCHAIN)/$(PKG_NAME)
73 endef
74
75 define Host/Configure
76 $(GEN_CONFIG) > $(HOST_BUILD_DIR)/.config.new
77 $(SED) 's,^KERNEL_HEADERS=.*,KERNEL_HEADERS=\"$(BUILD_DIR_TOOLCHAIN)/linux-dev/include\",g' \
78 -e 's,^.*UCLIBC_HAS_FPU.*,UCLIBC_HAS_FPU=$(if $(CONFIG_SOFT_FLOAT),n,y),g' \
79 -e 's,^.*UCLIBC_HAS_SOFT_FLOAT.*,UCLIBC_HAS_SOFT_FLOAT=$(if $(CONFIG_SOFT_FLOAT),y,n),g' \
80 -e 's,^.*UCLIBC_HAS_SHADOW.*,UCLIBC_HAS_SHADOW=$(if $(CONFIG_SHADOW_PASSWORDS),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) oldconfig 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; \
90 }
91 endef
92
93 define Host/Clean
94 rm -rf \
95 $(HOST_BUILD_DIR) \
96 $(BUILD_DIR_TOOLCHAIN)/$(PKG_NAME) \
97 $(BUILD_DIR_TOOLCHAIN)/$(LIBC)-dev
98 endef