Fix determination of the number of CPU cores on Linux.

This commit is contained in:
Todd C. Miller
2023-01-27 10:31:12 -07:00
parent 3b3089e4f5
commit 94eafd2f08

View File

@@ -113,10 +113,10 @@ if ${MAKE} --version 2>&1 | grep GNU >/dev/null; then
NJOBS=`sysctl -n hw.ncpu` NJOBS=`sysctl -n hw.ncpu`
;; ;;
Linux) Linux)
if [ -r /proc/cpuinfo ]; then if [ -x /usr/bin/nproc ]; then
for c in `sed -n 's/^cpu cores[ ]*: *//p' /proc/cpuinfo`; do NJOBS=`/usr/bin/nproc`
NJOBS=`expr $NJOBS + $c` elif [ -r /proc/cpuinfo ]; then
done NJOBS=`grep ^processor /proc/cpuinfo | wc -l`
fi fi
;; ;;
SunOS) SunOS)