diff --git a/build.sh b/build.sh index 031f2f023..33a1355c8 100755 --- a/build.sh +++ b/build.sh @@ -2,8 +2,19 @@ ROOT_DIR=$(cd "$(dirname "${BASH_SOURCE:-$0}")"; pwd) +# Determine how many parallel jobs to use for make based on the number of cores +unamestr="$(uname)" +if [[ "$unamestr" == "Linux" ]]; then + PARALLEL=$(nproc) +elif [[ "$unamestr" == "Darwin" ]]; then + PARALLEL=$(sysctl -n hw.ncpu) +else + echo "Unrecognized platform." + exit 1 +fi + mkdir -p "$ROOT_DIR/build" pushd "$ROOT_DIR/build" cmake .. - make install + make install -j$PARALLEL popd diff --git a/thirdparty/build_thirdparty.sh b/thirdparty/build_thirdparty.sh index 6ad79b648..c5e8abc4f 100755 --- a/thirdparty/build_thirdparty.sh +++ b/thirdparty/build_thirdparty.sh @@ -7,12 +7,14 @@ TP_DIR=$(cd "$(dirname "${BASH_SOURCE:-$0}")"; pwd) PREFIX=$TP_DIR/installed # Determine how many parallel jobs to use for make based on the number of cores -if [[ "$OSTYPE" =~ ^linux ]]; then - PARALLEL=$(grep -c processor /proc/cpuinfo) -elif [[ "$OSTYPE" == "darwin"* ]]; then +unamestr="$(uname)" +if [[ "$unamestr" == "Linux" ]]; then + PARALLEL=$(nproc) +elif [[ "$unamestr" == "Darwin" ]]; then PARALLEL=$(sysctl -n hw.ncpu) + echo "Platform is macosx." else - echo Unsupported platform $OSTYPE + echo "Unrecognized platform." exit 1 fi