blob: ed334bf34e7edc915f69a4662c03cf11eea3a6bc [file] [log] [blame]
Brad Bishopbec4ebc2022-08-03 09:55:16 -04001#!/bin/bash
2set -u
3
4HOST_ARCH=$(uname -m)
Patrick Williams2194f502022-10-16 14:26:09 -05005VER="11.3.rel1"
Brad Bishopbec4ebc2022-08-03 09:55:16 -04006
7DOWNLOAD_DIR=$1
8TOOLCHAIN_DIR=$2
9TOOLCHAIN_LINK_DIR=$3
10
11# These should be already created by .gitlab-ci.yml, but do here if run outside of that env
12mkdir -p $DOWNLOAD_DIR $TOOLCHAIN_DIR $TOOLCHAIN_LINK_DIR
13
14if [ $HOST_ARCH = "aarch64" ]; then
15 #AArch64 Linux hosted cross compilers
16
17 #AArch32 target with hard float (arm-none-linux-gnueabihf)
Patrick Williams2194f502022-10-16 14:26:09 -050018 wget -P $DOWNLOAD_DIR -nc https://developer.arm.com/-/media/Files/downloads/gnu/$VER/binrel/arm-gnu-toolchain-$VER-$HOST_ARCH-arm-none-linux-gnueabihf.tar.xz
Brad Bishopbec4ebc2022-08-03 09:55:16 -040019elif [ $HOST_ARCH = "x86_64" ]; then
20 #x86_64 Linux hosted cross compilers
21
22 #AArch32 target with hard float (arm-linux-none-gnueabihf)
Patrick Williams2194f502022-10-16 14:26:09 -050023 wget -P $DOWNLOAD_DIR -nc https://developer.arm.com/-/media/Files/downloads/gnu/$VER/binrel/arm-gnu-toolchain-$VER-$HOST_ARCH-arm-none-linux-gnueabihf.tar.xz
Brad Bishopbec4ebc2022-08-03 09:55:16 -040024
25 #AArch64 GNU/Linux target (aarch64-none-linux-gnu)
Patrick Williams2194f502022-10-16 14:26:09 -050026 wget -P $DOWNLOAD_DIR -nc https://developer.arm.com/-/media/Files/downloads/gnu/$VER/binrel/arm-gnu-toolchain-$VER-$HOST_ARCH-aarch64-none-linux-gnu.tar.xz
Brad Bishopbec4ebc2022-08-03 09:55:16 -040027
28 #AArch64 GNU/Linux target (aarch64_be-none-linux-gnu)
Patrick Williams2194f502022-10-16 14:26:09 -050029 wget -P $DOWNLOAD_DIR -nc https://developer.arm.com/-/media/Files/downloads/gnu/$VER/binrel/arm-gnu-toolchain-$VER-$HOST_ARCH-aarch64_be-none-linux-gnu.tar.xz
Brad Bishopbec4ebc2022-08-03 09:55:16 -040030else
31 echo "ERROR - Unknown build arch of $HOST_ARCH"
32 exit 1
33fi
34
35for i in arm aarch64 aarch64_be; do
Patrick Williams2194f502022-10-16 14:26:09 -050036 if [ ! -d $TOOLCHAIN_DIR/arm-gnu-toolchain-$VER-$HOST_ARCH-$i-none-linux-gnu*/ ]; then
37 if [ ! -f $DOWNLOAD_DIR/arm-gnu-toolchain-$VER-$HOST_ARCH-$i-none-linux-gnu*.tar.xz ]; then
Brad Bishopbec4ebc2022-08-03 09:55:16 -040038 continue
39 fi
40
Patrick Williams2194f502022-10-16 14:26:09 -050041 tar -C $TOOLCHAIN_DIR -axvf $DOWNLOAD_DIR/arm-gnu-toolchain-$VER-$HOST_ARCH-$i-none-linux-gnu*.tar.xz
Brad Bishopbec4ebc2022-08-03 09:55:16 -040042 fi
43
44 # Setup a link for the toolchain to use local to the building machine (e.g., not in a shared location)
Patrick Williams2194f502022-10-16 14:26:09 -050045 ln -s $TOOLCHAIN_DIR/arm-gnu-toolchain-$VER-$HOST_ARCH-$i-none-linux-gnu* $TOOLCHAIN_LINK_DIR/$i
Brad Bishopbec4ebc2022-08-03 09:55:16 -040046done