env.sh: Use a more portable way of counting online processors

getconf _NPROCESSORS_ONLN should be available on Linux, FreeBSD
and OSX at least:

http://linux.die.net/man/1/getconf
https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man1/getconf.1.html

getconf NPROCESSORS_ONLN is BSD variant which Haiku provides.

One might want to handle Solaris too some day...
cf. https://gist.github.com/jj1bdx/5746298
This commit is contained in:
François Revol 2013-12-27 02:43:01 +01:00 committed by Vincent Sanders
parent 7cb0619fe8
commit ab2f5ccb4b

View File

@ -22,7 +22,7 @@ if [ "x${TARGET_WORKSPACE}" = "x" ]; then
fi
if [ "x${USE_CPUS}" = "x" ]; then
NCPUS=$(grep -c "^processor" /proc/cpuinfo 2>/dev/null)
NCPUS=$(getconf _NPROCESSORS_ONLN 2>/dev/null || getconf NPROCESSORS_ONLN 2>/dev/null)
NCPUS="${NCPUS:-1}"
NCPUS=$((NCPUS * 2))
USE_CPUS="-j${NCPUS}"