make.sh: Add function to determine how many CPU cores the build host has

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
This commit is contained in:
Michael Tremer
2017-11-07 15:25:11 +01:00
parent 7e1639a481
commit 1445a5ac43
2 changed files with 5 additions and 4 deletions

View File

@@ -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

View 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