Brad Bishop | bec4ebc | 2022-08-03 09:55:16 -0400 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | set -u |
| 3 | |
| 4 | HOST_ARCH=$(uname -m) |
Patrick Williams | 2194f50 | 2022-10-16 14:26:09 -0500 | [diff] [blame] | 5 | VER="11.3.rel1" |
Brad Bishop | bec4ebc | 2022-08-03 09:55:16 -0400 | [diff] [blame] | 6 | |
| 7 | DOWNLOAD_DIR=$1 |
| 8 | TOOLCHAIN_DIR=$2 |
| 9 | TOOLCHAIN_LINK_DIR=$3 |
| 10 | |
| 11 | # These should be already created by .gitlab-ci.yml, but do here if run outside of that env |
| 12 | mkdir -p $DOWNLOAD_DIR $TOOLCHAIN_DIR $TOOLCHAIN_LINK_DIR |
| 13 | |
| 14 | if [ $HOST_ARCH = "aarch64" ]; then |
| 15 | #AArch64 Linux hosted cross compilers |
| 16 | |
| 17 | #AArch32 target with hard float (arm-none-linux-gnueabihf) |
Patrick Williams | 2194f50 | 2022-10-16 14:26:09 -0500 | [diff] [blame] | 18 | 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 Bishop | bec4ebc | 2022-08-03 09:55:16 -0400 | [diff] [blame] | 19 | elif [ $HOST_ARCH = "x86_64" ]; then |
| 20 | #x86_64 Linux hosted cross compilers |
| 21 | |
| 22 | #AArch32 target with hard float (arm-linux-none-gnueabihf) |
Patrick Williams | 2194f50 | 2022-10-16 14:26:09 -0500 | [diff] [blame] | 23 | 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 Bishop | bec4ebc | 2022-08-03 09:55:16 -0400 | [diff] [blame] | 24 | |
| 25 | #AArch64 GNU/Linux target (aarch64-none-linux-gnu) |
Patrick Williams | 2194f50 | 2022-10-16 14:26:09 -0500 | [diff] [blame] | 26 | 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 Bishop | bec4ebc | 2022-08-03 09:55:16 -0400 | [diff] [blame] | 27 | |
| 28 | #AArch64 GNU/Linux target (aarch64_be-none-linux-gnu) |
Patrick Williams | 2194f50 | 2022-10-16 14:26:09 -0500 | [diff] [blame] | 29 | 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 Bishop | bec4ebc | 2022-08-03 09:55:16 -0400 | [diff] [blame] | 30 | else |
| 31 | echo "ERROR - Unknown build arch of $HOST_ARCH" |
| 32 | exit 1 |
| 33 | fi |
| 34 | |
| 35 | for i in arm aarch64 aarch64_be; do |
Patrick Williams | 2194f50 | 2022-10-16 14:26:09 -0500 | [diff] [blame] | 36 | 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 Bishop | bec4ebc | 2022-08-03 09:55:16 -0400 | [diff] [blame] | 38 | continue |
| 39 | fi |
| 40 | |
Patrick Williams | 2194f50 | 2022-10-16 14:26:09 -0500 | [diff] [blame] | 41 | tar -C $TOOLCHAIN_DIR -axvf $DOWNLOAD_DIR/arm-gnu-toolchain-$VER-$HOST_ARCH-$i-none-linux-gnu*.tar.xz |
Brad Bishop | bec4ebc | 2022-08-03 09:55:16 -0400 | [diff] [blame] | 42 | fi |
| 43 | |
| 44 | # Setup a link for the toolchain to use local to the building machine (e.g., not in a shared location) |
Patrick Williams | 2194f50 | 2022-10-16 14:26:09 -0500 | [diff] [blame] | 45 | ln -s $TOOLCHAIN_DIR/arm-gnu-toolchain-$VER-$HOST_ARCH-$i-none-linux-gnu* $TOOLCHAIN_LINK_DIR/$i |
Brad Bishop | bec4ebc | 2022-08-03 09:55:16 -0400 | [diff] [blame] | 46 | done |