#!/bin/bash

if [ "$ARCH" = "x64" ]; then
	export TOOLCHAIN_PATH=/opt/x86-64--uclibc--stable-2025.08-1
	export PATH=$TOOLCHAIN_PATH/bin:$PATH
	export CROSS_COMPILE=x86_64-linux-
elif [ "$ARCH" = "mips32" ]; then
	export TOOLCHAIN_PATH=/opt/mips32--uclibc--stable-2025.08-1
	export PATH=$TOOLCHAIN_PATH/bin:$PATH
	export CROSS_COMPILE=mips-linux-
elif [ "$ARCH" = "arm32" ]; then
	export TOOLCHAIN_PATH=/opt/armv7-eabihf--uclibc--stable-2025.08-1
	export PATH=$TOOLCHAIN_PATH/bin:$PATH
	export CROSS_COMPILE=arm-linux-
elif [ "$ARCH" = "arm64" ]; then
	export TOOLCHAIN_PATH=/opt/aarch64--uclibc--stable-2025.08-1
	export PATH=$TOOLCHAIN_PATH/bin:$PATH
	export CROSS_COMPILE=aarch64-linux-
else
	echo "Unsupported arch '$ARCH'"
	exit 1
fi
export CC=${CROSS_COMPILE}gcc
echo "Running $@"
"$@"
