From: Stefan Schantl Date: Wed, 5 Aug 2009 17:11:02 +0000 (+0200) Subject: Introduced new script: parallelismflags. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c037793a4e0f3d4eb4cde0a3082afb7b43868da8;p=ipfire-3.x.git Introduced new script: parallelismflags. --- diff --git a/src/scripts/parallelismflags b/src/scripts/parallelismflags new file mode 100755 index 000000000..04d102ac5 --- /dev/null +++ b/src/scripts/parallelismflags @@ -0,0 +1,48 @@ +#/bin/bash + +auto= +max= + +while [ $# -gt 0 ]; do + case "${1}" in + --max=*) + max=${1#--max=} + ;; + --auto) + auto=1 + ;; + *) + jobs=${1#-j} + ;; + esac + shift +done + + +if [ -n "${max}" ]; then + + if ! [[ ${jobs} =~ ^[0-9]{1,}$ ]]; then + echo "-j${jobs}" + exit 0 + fi + + if [ ${jobs} -gt ${max} ]; then + echo "-j${max}" + exit 0 + fi + +elif [ "${auto}" = "1" ]; then + mem=$(( $(grep ^MemTotal: /proc/meminfo | awk '{ print $2 }') / 1024)) + memjobs=$(( $mem / 80 )) + + cpus=$(grep ^processor /proc/cpuinfo | wc -l) + + cpujobs=$(( $cpus * 10 )) + + if [ ${memjobs} -lt ${cpujobs} ]; then + echo "-j${memjobs}" + else + echo "-j${cpujobs}" + fi +fi + diff --git a/tools/make-constants b/tools/make-constants index d03a0de67..b6e1b2cba 100644 --- a/tools/make-constants +++ b/tools/make-constants @@ -52,7 +52,7 @@ BUILD_EXTRAS=1 BUILD_DEBUG=0 # Default parallelism options -PARALLELISMFLAGS=-j$(( $(grep processor < /proc/cpuinfo | wc -l) * 2 + 1 )) +PARALLELISMFLAGS=$($BASEDIR/src/scripts/parallelismflags --auto) # Default hostname HOSTNAME=${HOSTNAME-$(cat /proc/sys/kernel/hostname)}