From: Michael Tremer Date: Tue, 7 Nov 2017 14:25:11 +0000 (+0100) Subject: make.sh: Add function to determine how many CPU cores the build host has X-Git-Tag: v2.19-core117~1^2~97 X-Git-Url: http://git.ipfire.org/?p=ipfire-2.x.git;a=commitdiff_plain;h=1445a5ac436b4e29f227059ad8a1a1ceda327a2e make.sh: Add function to determine how many CPU cores the build host has Signed-off-by: Michael Tremer --- diff --git a/make.sh b/make.sh index 948a24d390..d9f779a81d 100755 --- a/make.sh +++ b/make.sh @@ -189,10 +189,7 @@ prepareenv() { set +h LC_ALL=POSIX if [ -z $MAKETUNING ]; then - CPU_COUNT="$(getconf _NPROCESSORS_ONLN 2>/dev/null)" - if [ -z "${CPU_COUNT}" ]; then - CPU_COUNT=1 - fi + CPU_COUNT="$(system_processors)" MAKETUNING="-j$(( ${CPU_COUNT} * 2 + 1 ))" fi diff --git a/tools/make-functions b/tools/make-functions index 1ff4613f3e..676b971012 100644 --- a/tools/make-functions +++ b/tools/make-functions @@ -60,6 +60,10 @@ WARN="\\033[1;35m" FAIL="\\033[1;31m" NORMAL="\\033[0;39m" +system_processors() { + getconf _NPROCESSORS_ONLN 2>/dev/null || echo "1" +} + system_memory() { local key val unit