From 61acceb1ca57123e31418fbd43e3a69b87194f12 Mon Sep 17 00:00:00 2001 From: Peter Kalbus Date: Sat, 29 Jan 2022 21:20:10 +0100 Subject: [PATCH] Detect host CPU on MacOS/Linux running on ARM. --- tools/sethost.sh | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/tools/sethost.sh b/tools/sethost.sh index 6be7e920ca..12cb93cde1 100755 --- a/tools/sethost.sh +++ b/tools/sethost.sh @@ -106,6 +106,24 @@ if [ -z "$host" ]; then esac fi +# Detect Host CPU type. +# At least MacOS and Linux can have x86_64 and arm based hosts. + +if [ -z "$cpu" ]; then + case $(uname -m) in + arm64) + cpu=arm + ;; + aarch64) + cpu=arm + ;; + *) + # Assume x86_64 as default + cpu=x86_64 + ;; + esac +fi + WD=`test -d ${0%/*} && cd ${0%/*}; pwd` cd $WD @@ -146,6 +164,11 @@ if [ "X$host" == "Xlinux" -o "X$host" == "Xmacos" -o "X$host" == "Xbsd" ]; then kconfig-tweak --file $nuttx/.config --disable CONFIG_HOST_BSD kconfig-tweak --file $nuttx/.config --enable CONFIG_HOST_LINUX + if [ "X$cpu" == "Xarm" ]; then + echo " Select CONFIG_HOST_ARM=y" + kconfig-tweak --file $nuttx/.config --enable CONFIG_HOST_ARM + fi + elif [ "X$host" == "Xbsd" ]; then echo " Select CONFIG_HOST_BSD=y" kconfig-tweak --file $nuttx/.config --disable CONFIG_HOST_MACOS @@ -157,6 +180,11 @@ if [ "X$host" == "Xlinux" -o "X$host" == "Xmacos" -o "X$host" == "Xbsd" ]; then kconfig-tweak --file $nuttx/.config --disable CONFIG_HOST_LINUX kconfig-tweak --file $nuttx/.config --disable CONFIG_HOST_BSD kconfig-tweak --file $nuttx/.config --enable CONFIG_HOST_MACOS + + if [ "X$cpu" == "Xarm" ]; then + echo " Select CONFIG_HOST_ARM=y" + kconfig-tweak --file $nuttx/.config --enable CONFIG_HOST_ARM + fi fi # Enable the System V ABI