From 94eafd2f08fbc0bf04bdf84c8a8717200220a1a4 Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Fri, 27 Jan 2023 10:31:12 -0700 Subject: [PATCH] Fix determination of the number of CPU cores on Linux. --- scripts/mkpkg | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/mkpkg b/scripts/mkpkg index 4e857a37e..dd4f4492f 100755 --- a/scripts/mkpkg +++ b/scripts/mkpkg @@ -113,10 +113,10 @@ if ${MAKE} --version 2>&1 | grep GNU >/dev/null; then NJOBS=`sysctl -n hw.ncpu` ;; Linux) - if [ -r /proc/cpuinfo ]; then - for c in `sed -n 's/^cpu cores[ ]*: *//p' /proc/cpuinfo`; do - NJOBS=`expr $NJOBS + $c` - done + if [ -x /usr/bin/nproc ]; then + NJOBS=`/usr/bin/nproc` + elif [ -r /proc/cpuinfo ]; then + NJOBS=`grep ^processor /proc/cpuinfo | wc -l` fi ;; SunOS)