1################################################################################
2#
3# toolchain-external-codescape-mti-mips
4#
5################################################################################
6
7TOOLCHAIN_EXTERNAL_CODESCAPE_MTI_MIPS_VERSION = 2018.09-02
8TOOLCHAIN_EXTERNAL_CODESCAPE_MTI_MIPS_SITE = https://codescape.mips.com/components/toolchain/$(TOOLCHAIN_EXTERNAL_CODESCAPE_MTI_MIPS_VERSION)
9TOOLCHAIN_EXTERNAL_CODESCAPE_MTI_MIPS_STRIP_COMPONENTS = 2
10
11ifeq ($(HOSTARCH),x86)
12TOOLCHAIN_EXTERNAL_CODESCAPE_MTI_MIPS_SOURCE = Codescape.GNU.Tools.Package.$(TOOLCHAIN_EXTERNAL_CODESCAPE_MTI_MIPS_VERSION).for.MIPS.MTI.Linux.CentOS-6.x86.tar.gz
13else
14TOOLCHAIN_EXTERNAL_CODESCAPE_MTI_MIPS_SOURCE = Codescape.GNU.Tools.Package.$(TOOLCHAIN_EXTERNAL_CODESCAPE_MTI_MIPS_VERSION).for.MIPS.MTI.Linux.CentOS-6.x86_64.tar.gz
15endif
16
17# Special fixup for Codescape MIPS toolchains, that have bin-<abi> and
18# sbin-<abi> directories. We create symlinks bin -> bin-<abi> and sbin
19# -> sbin-<abi> so that the rest of Buildroot can find the toolchain
20# tools in the appropriate location.
21ifeq ($(BR2_MIPS_OABI32),y)
22TOOLCHAIN_EXTERNAL_CODESCAPE_MTI_MIPS_BIN_DIR_SUFFIX = o32
23else ifeq ($(BR2_MIPS_NABI32),y)
24TOOLCHAIN_EXTERNAL_CODESCAPE_MTI_MIPS_BIN_DIR_SUFFIX = n32
25else ifeq ($(BR2_MIPS_NABI64),y)
26TOOLCHAIN_EXTERNAL_CODESCAPE_MTI_MIPS_BIN_DIR_SUFFIX = n64
27endif
28
29define TOOLCHAIN_EXTERNAL_CODESCAPE_MTI_MIPS_STAGING_FIXUPS
30	rmdir $(STAGING_DIR)/usr/bin $(STAGING_DIR)/usr/sbin
31	ln -sf bin-$(TOOLCHAIN_EXTERNAL_CODESCAPE_MTI_MIPS_BIN_DIR_SUFFIX) $(STAGING_DIR)/usr/bin
32	ln -sf sbin-$(TOOLCHAIN_EXTERNAL_CODESCAPE_MTI_MIPS_BIN_DIR_SUFFIX) $(STAGING_DIR)/usr/sbin
33endef
34
35# The Codescape toolchain uses a sysroot layout that places them
36# side-by-side instead of nested like multilibs. A symlink is needed
37# much like for the nested sysroots which are handled in
38# copy_toolchain_sysroot but there is not enough information in there
39# to determine whether the sysroot layout was nested or side-by-side.
40# Add the symlink here for now.
41define TOOLCHAIN_EXTERNAL_CODESCAPE_MTI_MIPS_SYMLINK
42	$(Q)ARCH_SYSROOT_DIR="$(call toolchain_find_sysroot,$(TOOLCHAIN_EXTERNAL_CC) $(TOOLCHAIN_EXTERNAL_CFLAGS))"; \
43	ARCH_SUBDIR=`basename $${ARCH_SYSROOT_DIR}`; \
44	ln -snf . $(STAGING_DIR)/$${ARCH_SUBDIR}
45endef
46
47TOOLCHAIN_EXTERNAL_CODESCAPE_MTI_MIPS_POST_INSTALL_STAGING_HOOKS += \
48	TOOLCHAIN_EXTERNAL_CODESCAPE_MTI_MIPS_STAGING_FIXUPS \
49	TOOLCHAIN_EXTERNAL_CODESCAPE_MTI_MIPS_SYMLINK
50
51$(eval $(toolchain-external-package))
52