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