make.sh: Automatically determine parallelism flags.
authorMichael Tremer <michael.tremer@ipfire.org>
Sun, 29 Sep 2013 12:38:41 +0000 (14:38 +0200)
committerMichael Tremer <michael.tremer@ipfire.org>
Sun, 29 Sep 2013 12:42:11 +0000 (14:42 +0200)
make.sh

diff --git a/make.sh b/make.sh
index 2ada02880296d8196dc16fe55b7386635826ccc2..fe3634f0bb19c0d795f863652e77d22a069f6c2b 100755 (executable)
--- a/make.sh
+++ b/make.sh
@@ -179,11 +179,12 @@ prepareenv() {
     set +h
     LC_ALL=POSIX
     if [ -z $MAKETUNING ]; then
     set +h
     LC_ALL=POSIX
     if [ -z $MAKETUNING ]; then
-        if [ "${MACHINE:0:3}" = "arm" ]; then
-            MAKETUNING="-j2"
-        else
-            MAKETUNING="-j6"
-        fi
+       CPU_COUNT="$(getconf _NPROCESSORS_ONLN 2>/dev/null)"
+       if [ -z "${CPU_COUNT}" ]; then
+               CPU_COUNT=1
+       fi
+
+       MAKETUNING="-j$(( ${CPU_COUNT} * 2 + 1 ))"
     fi
     export LFS LC_ALL CFLAGS CXXFLAGS MAKETUNING
     unset CC CXX CPP LD_LIBRARY_PATH LD_PRELOAD
     fi
     export LFS LC_ALL CFLAGS CXXFLAGS MAKETUNING
     unset CC CXX CPP LD_LIBRARY_PATH LD_PRELOAD