From: Andre Noll Date: Tue, 15 Feb 2011 07:28:43 +0000 (+0100) Subject: autogen.sh: Detect number of processors and run parallel make. X-Git-Tag: v0.4.7~16^2 X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=commitdiff_plain;h=5379c6d7b5368100184792219248b48580755aae;hp=c6c03bac20656834d531813cedb6304cf0fef21e autogen.sh: Detect number of processors and run parallel make. On multi-core machines a parallel make is often much faster than a sequential make. This patch teaches autogen.sh to detect the number of processing units available on the build system. It first tries to execute the nproc utility (part of the coreutils package) and falls back to /proc/cpuinfo if nproc was unavailable. If both methods don't work, which is usually the case on non-Linux systems where coreutils are not installed and /proc/cpuinfo does not exist, we use the safe default of n=1. --- diff --git a/autogen.sh b/autogen.sh index a047f7c4..e5000a6f 100755 --- a/autogen.sh +++ b/autogen.sh @@ -1,7 +1,13 @@ #!/bin/sh -echo preparing... +# check if we have multiple processors/cores +n=$(nproc 2>/dev/null) +if [ -z "$n" ]; then + n=$(grep ^processor /proc/cpuinfo 2>/dev/null | wc -l) + [ $n -eq 0 ] && n=1 +fi +echo preparing, parallel=$n... if test -f Makefile; then - make maintainer-clean > /dev/null + make maintainer-clean > /dev/null 2>&1 fi aclocal -I . > /dev/null 2>&1 autoconf @@ -10,4 +16,4 @@ echo configuring... ./configure $@ > /dev/null echo compiling... make clean2 > /dev/null 2>&1 -make > /dev/null +make -j $n > /dev/null