]> git.ipfire.org Git - ipfire-2.x.git/commitdiff
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 948a24d3907f2d68694bb1c28cefcca3156d2150..d9f779a81d6297cbe590c0b75fb56858bb07d3fd 100755 (executable)
--- a/make.sh
+++ b/make.sh
@@ -189,10 +189,7 @@ prepareenv() {
     set +h
     LC_ALL=POSIX
     if [ -z $MAKETUNING ]; then
     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
 
        MAKETUNING="-j$(( ${CPU_COUNT} * 2 + 1 ))"
     fi
index 1ff4613f3ea5c435c3a856cb6a2f6bc6dce85f3c..676b9710120c9bd94fb8972b187cbea3407f3c86 100644 (file)
@@ -60,6 +60,10 @@ WARN="\\033[1;35m"
 FAIL="\\033[1;31m"
 NORMAL="\\033[0;39m"
 
 FAIL="\\033[1;31m"
 NORMAL="\\033[0;39m"
 
+system_processors() {
+       getconf _NPROCESSORS_ONLN 2>/dev/null || echo "1"
+}
+
 system_memory() {
        local key val unit
 
 system_memory() {
        local key val unit