make.sh: Add function to determine how many CPU cores the build host has
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 7 Nov 2017 14:25:11 +0000 (15:25 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 7 Nov 2017 14:25:11 +0000 (15:25 +0100)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
make.sh
tools/make-functions

diff --git a/make.sh b/make.sh
index 948a24d..d9f779a 100755 (executable)
--- 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
index 1ff4613..676b971 100644 (file)
@@ -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