summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xutil/xcompile/xcompile19
1 files changed, 19 insertions, 0 deletions
diff --git a/util/xcompile/xcompile b/util/xcompile/xcompile
index a1856e4232..d8779264ec 100755
--- a/util/xcompile/xcompile
+++ b/util/xcompile/xcompile
@@ -66,10 +66,29 @@ else
die "no host compiler found"
fi
+# try to find the core count using various methods
+CORES="$(getconf _NPROCESSORS_ONLN 2>/dev/null)"
+if [ -z "$CORES" ]; then
+ NPROC=$(command -v nproc)
+ if [ -n "$NPROC" ]; then
+ CORES="$($NPROC)"
+ fi
+fi
+if [ -z "$CORES" ]; then
+ SYSCTL=$(command -v sysctl)
+ if [ -n "$SYSCTL" ]; then
+ CORES="$(${SYSCTL} -n hw.ncpu 2>/dev/null)"
+ fi
+fi
+if [ -z "$CORES" ] && [ -f /proc/cpuinfo ]; then
+ CORES="$(grep 'processor' /proc/cpuinfo 2>/dev/null | wc -l)"
+fi
+
cat <<EOF
# platform agnostic and host tools
IASL:=${IASL}
HOSTCC?=${HOSTCC}
+CPUS?=${CORES}
EOF