toolchain: add support of ARCv2 architecture
[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 --enable-lto \
13 --with-libelf=$(TOPDIR)/staging_dir/host
14
15 ifdef CONFIG_USE_MUSL
16 GCC_MAKE += gcc_cv_libc_provides_ssp=yes
17 endif
18
19 ifneq ($(CONFIG_SJLJ_EXCEPTIONS),)
20 GCC_CONFIGURE += \
21 --enable-sjlj-exceptions
22 endif
23
24 define CleanupToolchain
25 $(INSTALL_DIR) $(TOOLCHAIN_DIR)/$(REAL_GNU_TARGET_NAME)
26 # Important! Required for limits.h to be fixed.
27 rm -rf $(TOOLCHAIN_DIR)/$(REAL_GNU_TARGET_NAME)/sys-include
28 ln -sf ../include $(TOOLCHAIN_DIR)/$(REAL_GNU_TARGET_NAME)/sys-include
29 rm -rf $(TOOLCHAIN_DIR)/$(REAL_GNU_TARGET_NAME)/lib
30 ln -sf ../lib $(TOOLCHAIN_DIR)/$(REAL_GNU_TARGET_NAME)/lib
31 $(if $(CONFIG_ARCH_64BIT),ln -sf ../lib64 $(TOOLCHAIN_DIR)/$(REAL_GNU_TARGET_NAME)/lib64)
32 endef
33
34 define Host/Configure
35 $(CleanupToolchain)
36 mkdir -p $(GCC_BUILD_DIR)
37 (cd $(GCC_BUILD_DIR) && rm -f config.cache; \
38 $(GCC_CONFIGURE) \
39 );
40 endef
41
42 define Host/Compile
43 +$(GCC_MAKE) $(HOST_JOBS) -C $(GCC_BUILD_DIR) all
44 endef
45
46 define SetupExtraArch
47 for app in $(TOOLCHAIN_DIR)/bin/$(OPTIMIZE_FOR_CPU)*-{gcc,gcc-*,g++}; do \
48 [ -e $$$$app ] || continue; \
49 old_base=$$$$(basename $$$$app); \
50 new_base=$(call qstrip,$(CONFIG_EXTRA_TARGET_ARCH_NAME))-$$$${old_base##$(OPTIMIZE_FOR_CPU)-}; \
51 sed -e "s/@CC_BASE@/$$$$old_base/" \
52 -e 's/@EXTRA_ARCH_OPTS@/$(call qstrip,$(CONFIG_EXTRA_TARGET_ARCH_OPTS))/' \
53 ../files/alternate-arch-cc.in > \
54 $(TOOLCHAIN_DIR)/bin/$$$$new_base; \
55 chmod a+x $(TOOLCHAIN_DIR)/bin/$$$$new_base; \
56 done
57 endef
58
59 define Host/Install
60 $(CleanupToolchain)
61 $(_SINGLE)$(GCC_MAKE) -C $(GCC_BUILD_DIR) install
62 # Set up the symlinks to enable lying about target name.
63 set -e; \
64 (cd $(TOOLCHAIN_DIR); \
65 ln -sf $(REAL_GNU_TARGET_NAME) $(GNU_TARGET_NAME); \
66 cd bin; \
67 for app in $(REAL_GNU_TARGET_NAME)-* ; do \
68 ln -sf $$$${app} \
69 $(GNU_TARGET_NAME)$$$${app##$(REAL_GNU_TARGET_NAME)}; \
70 done; \
71 );
72 $(if $(CONFIG_EXTRA_TARGET_ARCH),$(call SetupExtraArch))
73 $(RM) $(TOOLCHAIN_DIR)/lib/libiberty.a
74 $(SCRIPT_DIR)/patch-specs.sh "$(TOOLCHAIN_DIR)"
75 endef
76
77 $(eval $(call HostBuild))
78