Build needed cross toolchain with buildroot for non-x86_64 hosts

The needed precompiled toolchains provided by Arm are only available for
x86_64 hosts. For all other host architectures we build it with
Buildroot itself.

Reviewed-by: Jerome Forissier <jerome@forissier.org>
Tested-by: Jerome Forissier <jerome@forissier.org> (QEMUv8 64/64, host uname -m: aarch64)
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
diff --git a/common.mk b/common.mk
index 4a36d0b..2d2e43b 100644
--- a/common.mk
+++ b/common.mk
@@ -26,6 +26,7 @@
 BASH ?= bash
 ROOT ?= $(shell pwd)/..
 
+UNAME_M				:= $(shell uname -m)
 BUILD_PATH			?= $(ROOT)/build
 LINUX_PATH			?= $(ROOT)/linux
 OPTEE_OS_PATH			?= $(ROOT)/optee_os
@@ -103,9 +104,17 @@
 # Mandatory for autotools (for specifying --host)
 ################################################################################
 ifeq ($(COMPILE_NS_USER),64)
+ifeq ($(UNAME_M),x86_64)
 MULTIARCH			:= aarch64-linux-gnu
 else
+MULTIARCH			:= aarch64-linux
+endif
+else
+ifeq ($(UNAME_M),x86_64)
 MULTIARCH			:= arm-linux-gnueabihf
+else
+MULTIARCH			:= arm-linux
+endif
 endif
 
 ################################################################################
@@ -240,11 +249,15 @@
 DEFCONFIG_GDBSERVER=--br-defconfig build/br-ext/configs/gdbserver.conf
 else
 # Local toolchains (downloaded by "make toolchains")
+ifeq ($(UNAME_M),x86_64)
 ifeq ($(COMPILE_LEGACY),)
 BUILDROOT_TOOLCHAIN=toolchain-aarch$(COMPILE_NS_USER)
 else
 BUILDROOT_TOOLCHAIN=toolchain-aarch$(COMPILE_NS_USER)-legacy
 endif
+else
+BUILDROOT_TOOLCHAIN=toolchain-aarch$(COMPILE_NS_USER)-sdk
+endif
 endif
 
 BR2_PACKAGE_LIBOPENSSL ?= y