From db98116491dc338288aba5834349ef0ce378104b Mon Sep 17 00:00:00 2001 From: Darren Garvey Date: Sat, 13 Jun 2015 12:14:55 +0100 Subject: [PATCH] Build with as many cores as there are on the system. On unix-like systems where we can use /proc/cpuinfo to find the number of cores, use all of them when building, rather than only using 4. Still default to 4 when we don't have /proc/cpuinfo. Apparently you can use $(sysctl -a | grep machdep.cpu | grep thread_count) on Mac, but I don't have one available to try. --- build.sh | 5 ++++- build_ps.sh | 6 ++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/build.sh b/build.sh index 2807db98..ebf4ce37 100755 --- a/build.sh +++ b/build.sh @@ -18,5 +18,8 @@ if [ ! -f config.mk ]; then cp make/config.mk config.mk fi -make -j4 +# Use as many CPUs as the host has to build, or default to +# 4 if we're not on a unix-y system. +num_cpus=$(grep -sc ^processor /proc/cpuinfo || echo 4) +make -j$num_cpus diff --git a/build_ps.sh b/build_ps.sh index b9e44b77..d0028b1e 100755 --- a/build_ps.sh +++ b/build_ps.sh @@ -28,5 +28,7 @@ fi sed -i 's/USE_DIST_PS.*/USE_DIST_PS = 1/' config.mk sed -i 's/PS_PATH.*/PS_PATH = .\/ps-lite/' config.mk -make -j4 -# make $1 +# Use as many CPUs as the host has to build, or default to +# 4 if we're not on a unix-y system. +num_cpus=$(grep -sc ^processor /proc/cpuinfo || echo 4) +make -j$num_cpus