From 212187f87cc5ac8dc9219aeef2465722d42c9191 Mon Sep 17 00:00:00 2001 From: joshjdevl Date: Wed, 7 Mar 2018 07:15:01 +0000 Subject: [PATCH] using POSIX getconf for number of available processors http://pubs.opengroup.org/onlinepubs/9699919799/utilities/getconf.html --- dist-build/android-build.sh | 6 +++++- dist-build/ios.sh | 14 +++++++++----- dist-build/nativeclient-pnacl.sh | 6 +++++- dist-build/nativeclient-x86.sh | 5 ++++- dist-build/nativeclient-x86_64.sh | 6 +++++- dist-build/osx.sh | 6 +++++- 6 files changed, 33 insertions(+), 10 deletions(-) diff --git a/dist-build/android-build.sh b/dist-build/android-build.sh index d701c631..193fec61 100755 --- a/dist-build/android-build.sh +++ b/dist-build/android-build.sh @@ -83,6 +83,10 @@ if [ "$NDK_PLATFORM" != "$NDK_PLATFORM_COMPAT" ]; then rm -f config-def.log config-def-compat.log fi + +NPROCESSORS=$(getconf _NPROCESSORS_ONLN) +PROCESSORS=${NPROCESSORS:-3} + make clean && \ -make -j3 install && \ +make -j${PROCESSORS} install && \ echo "libsodium has been installed into ${PREFIX}" diff --git a/dist-build/ios.sh b/dist-build/ios.sh index bf1b7f3d..77c7a229 100755 --- a/dist-build/ios.sh +++ b/dist-build/ios.sh @@ -44,7 +44,11 @@ fi ${LIBSODIUM_ENABLE_MINIMAL_FLAG} \ --prefix="$SIMULATOR32_PREFIX" || exit 1 -make -j3 install || exit 1 + +NPROCESSORS=$(getconf _NPROCESSORS_ONLN) +PROCESSORS=${NPROCESSORS:-3} + +make -j${PROCESSORS} install || exit 1 ## x86_64 simulator export CFLAGS="-O2 -arch x86_64 -isysroot ${SDK} -mios-simulator-version-min=${IOS_SIMULATOR_VERSION_MIN}" @@ -57,7 +61,7 @@ make distclean > /dev/null ${LIBSODIUM_ENABLE_MINIMAL_FLAG} \ --prefix="$SIMULATOR64_PREFIX" -make -j3 install || exit 1 +make -j${PROCESSORS} install || exit 1 # Build for iOS export BASEDIR="${XCODEDIR}/Platforms/iPhoneOS.platform/Developer" @@ -75,7 +79,7 @@ make distclean > /dev/null ${LIBSODIUM_ENABLE_MINIMAL_FLAG} \ --prefix="$IOS32_PREFIX" || exit 1 -make -j3 install || exit 1 +make -j${PROCESSORS} install || exit 1 ## 32-bit armv7s iOS export CFLAGS="-fembed-bitcode -O2 -mthumb -arch armv7s -isysroot ${SDK} -mios-version-min=${IOS_VERSION_MIN}" @@ -88,7 +92,7 @@ make distclean > /dev/null ${LIBSODIUM_ENABLE_MINIMAL_FLAG} \ --prefix="$IOS32s_PREFIX" || exit 1 -make -j3 install || exit 1 +make -j${PROCESSORS} install || exit 1 ## 64-bit iOS export CFLAGS="-fembed-bitcode -O2 -arch arm64 -isysroot ${SDK} -mios-version-min=${IOS_VERSION_MIN} -fembed-bitcode" @@ -101,7 +105,7 @@ make distclean > /dev/null ${LIBSODIUM_ENABLE_MINIMAL_FLAG} \ --prefix="$IOS64_PREFIX" || exit 1 -make -j3 install || exit 1 +make -j${PROCESSORS} install || exit 1 # Create universal binary and include folder rm -fr -- "$PREFIX/include" "$PREFIX/libsodium.a" 2> /dev/null diff --git a/dist-build/nativeclient-pnacl.sh b/dist-build/nativeclient-pnacl.sh index 07e3cce5..c249d1ef 100755 --- a/dist-build/nativeclient-pnacl.sh +++ b/dist-build/nativeclient-pnacl.sh @@ -30,4 +30,8 @@ fi --disable-ssp --without-pthreads \ --prefix="$PREFIX" || exit 1 -make -j3 check && make -j3 install || exit 1 + +NPROCESSORS=$(getconf _NPROCESSORS_ONLN) +PROCESSORS=${NPROCESSORS:-3} + +make -j${PROCESSORS} check && make -j${PROCESSORS} install || exit 1 diff --git a/dist-build/nativeclient-x86.sh b/dist-build/nativeclient-x86.sh index 5516d311..343e7728 100755 --- a/dist-build/nativeclient-x86.sh +++ b/dist-build/nativeclient-x86.sh @@ -23,4 +23,7 @@ fi --disable-ssp --without-pthreads \ --prefix="$PREFIX" || exit 1 -make -j3 check && make -j3 install || exit 1 +NPROCESSORS=$(getconf _NPROCESSORS_ONLN) +PROCESSORS=${NPROCESSORS:-3} + +make -j${PROCESSORS} check && make -j${PROCESSORS} install || exit 1 diff --git a/dist-build/nativeclient-x86_64.sh b/dist-build/nativeclient-x86_64.sh index 8a90c099..b81b8e89 100755 --- a/dist-build/nativeclient-x86_64.sh +++ b/dist-build/nativeclient-x86_64.sh @@ -22,4 +22,8 @@ fi --disable-ssp --without-pthreads \ --prefix="$PREFIX" || exit 1 -make -j3 check && make -j3 install || exit 1 + +NPROCESSORS=$(getconf _NPROCESSORS_ONLN) +PROCESSORS=${NPROCESSORS:-3} + +make -j${PROCESSORS} check && make -j${PROCESSORS} install || exit 1 diff --git a/dist-build/osx.sh b/dist-build/osx.sh index a39857b4..0632bacf 100755 --- a/dist-build/osx.sh +++ b/dist-build/osx.sh @@ -20,7 +20,11 @@ fi ./configure ${LIBSODIUM_ENABLE_MINIMAL_FLAG} \ --prefix="$PREFIX" || exit 1 -make -j3 check && make -j3 install || exit 1 + +NPROCESSORS=$(getconf _NPROCESSORS_ONLN) +PROCESSORS=${NPROCESSORS:-3} + +make -j${PROCESSORS} check && make -j${PROCESSORS} install || exit 1 # Cleanup make distclean > /dev/null