gcc: musl comes with its own SSP, so use it instead of libssp
[openwrt/staging/chunkeey.git] / toolchain / gcc / final / Makefile
1 GCC_VARIANT:=final
2
3 include ../common.mk
4
5 GCC_CONFIGURE += \
6 --with-headers=$(TOOLCHAIN_DIR)/include \
7 --disable-libsanitizer \
8 --enable-languages=$(TARGET_LANGUAGES) \
9 --enable-shared \
10 --enable-threads \
11 --with-slibdir=$(TOOLCHAIN_DIR)/lib
12
13 ifneq ($(CONFIG_GCC_VERSION_4_5)$(CONFIG_GCC_VERSION_4_6),)
14 GCC_CONFIGURE += \
15 --enable-lto \
16 --with-libelf=$(TOPDIR)/staging_dir/host
17 endif
18
19 ifdef CONFIG_USE_MUSL
20 GCC_MAKE += gcc_cv_libc_provides_ssp=yes
21 endif
22
23 ifneq ($(CONFIG_SJLJ_EXCEPTIONS),)
24 GCC_CONFIGURE += \
25 --enable-sjlj-exceptions
26 endif
27
28 define CleanupToolchain
29 $(INSTALL_DIR) $(TOOLCHAIN_DIR)/$(REAL_GNU_TARGET_NAME)
30 # Important! Required for limits.h to be fixed.
31 rm -rf $(TOOLCHAIN_DIR)/$(REAL_GNU_TARGET_NAME)/sys-include
32 ln -sf ../include $(TOOLCHAIN_DIR)/$(REAL_GNU_TARGET_NAME)/sys-include
33 rm -rf $(TOOLCHAIN_DIR)/$(REAL_GNU_TARGET_NAME)/lib
34 ln -sf ../lib $(TOOLCHAIN_DIR)/$(REAL_GNU_TARGET_NAME)/lib
35 $(if $(CONFIG_ARCH_64BIT),ln -sf ../lib64 $(TOOLCHAIN_DIR)/$(REAL_GNU_TARGET_NAME)/lib64)
36 endef
37
38 define Host/Configure
39 $(CleanupToolchain)
40 mkdir -p $(GCC_BUILD_DIR)
41 (cd $(GCC_BUILD_DIR) && rm -f config.cache; \
42 $(GCC_CONFIGURE) \
43 );
44 endef
45
46 define Host/Compile
47 +$(GCC_MAKE) $(HOST_JOBS) -C $(GCC_BUILD_DIR) all
48 endef
49
50 define SetupExtraArch
51 for app in $(TOOLCHAIN_DIR)/bin/$(OPTIMIZE_FOR_CPU)*-{gcc,gcc-*,g++}; do \
52 [ -e $$$$app ] || continue; \
53 old_base=$$$$(basename $$$$app); \
54 new_base=$(call qstrip,$(CONFIG_EXTRA_TARGET_ARCH_NAME))-$$$${old_base##$(OPTIMIZE_FOR_CPU)-}; \
55 sed -e "s/@CC_BASE@/$$$$old_base/" \
56 -e 's/@EXTRA_ARCH_OPTS@/$(call qstrip,$(CONFIG_EXTRA_TARGET_ARCH_OPTS))/' \
57 ../files/alternate-arch-cc.in > \
58 $(TOOLCHAIN_DIR)/bin/$$$$new_base; \
59 chmod a+x $(TOOLCHAIN_DIR)/bin/$$$$new_base; \
60 done
61 endef
62
63 define Host/Install
64 $(CleanupToolchain)
65 $(_SINGLE)$(GCC_MAKE) -C $(GCC_BUILD_DIR) install
66 # Set up the symlinks to enable lying about target name.
67 set -e; \
68 (cd $(TOOLCHAIN_DIR); \
69 ln -sf $(REAL_GNU_TARGET_NAME) $(GNU_TARGET_NAME); \
70 cd bin; \
71 for app in $(REAL_GNU_TARGET_NAME)-* ; do \
72 ln -sf $$$${app} \
73 $(GNU_TARGET_NAME)$$$${app##$(REAL_GNU_TARGET_NAME)}; \
74 done; \
75 );
76 $(if $(CONFIG_EXTRA_TARGET_ARCH),$(call SetupExtraArch))
77 $(RM) $(TOOLCHAIN_DIR)/lib/libiberty.a
78 $(SCRIPT_DIR)/patch-specs.sh "$(TOOLCHAIN_DIR)"
79 endef
80
81 $(eval $(call HostBuild))
82