summaryrefslogtreecommitdiff
path: root/eclass
diff options
context:
space:
mode:
authorMartin Schlemmer <azarah@gentoo.org>2002-12-01 23:22:50 +0000
committerMartin Schlemmer <azarah@gentoo.org>2002-12-01 23:22:50 +0000
commitdf7c1491e05aa3c9c830837a3171d6978701ce1f (patch)
treecc28863149de66fa84d59a3ab6df7c70a438e4d5 /eclass
parentChanged SRC_URI Homepage and unpack (diff)
downloadgentoo-2-df7c1491e05aa3c9c830837a3171d6978701ce1f.tar.gz
gentoo-2-df7c1491e05aa3c9c830837a3171d6978701ce1f.tar.bz2
gentoo-2-df7c1491e05aa3c9c830837a3171d6978701ce1f.zip
add get_number_of_jobs(), thanks to nall
Diffstat (limited to 'eclass')
-rw-r--r--eclass/eutils.eclass50
1 files changed, 49 insertions, 1 deletions
diff --git a/eclass/eutils.eclass b/eclass/eutils.eclass
index 77dc559ab6d1..28ec6c0e578a 100644
--- a/eclass/eutils.eclass
+++ b/eclass/eutils.eclass
@@ -1,7 +1,7 @@
# Copyright 1999-2002 Gentoo Technologies, Inc.
# Distributed under the terms of the GNU General Public License v2
# Author: Martin Schlemmer <azarah@gentoo.org>
-# $Header: /var/cvsroot/gentoo-x86/eclass/eutils.eclass,v 1.9 2002/12/01 15:48:27 azarah Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/eutils.eclass,v 1.10 2002/12/01 23:22:50 azarah Exp $
# This eclass is for general purpose functions that most ebuilds
# have to implement themselves.
#
@@ -311,3 +311,51 @@ epatch() {
fi
}
+# This function check how many cpu's are present, and then set
+# -j in MAKEOPTS accordingly.
+#
+# Thanks to nall <nall@gentoo.org> for this.
+#
+get_number_of_jobs() {
+ if [ ! -r /proc/cpuinfo ]
+ then
+ return 1
+ fi
+
+ export MAKEOPTS="`echo ${MAKEOPTS} | sed -e 's:-j[0-9]*::g'`"
+
+ if [ "${ARCH}" = "x86" ]
+ then
+ # x86 always has "processor"
+ export MAKEOPTS="${MAKEOPTS} -j$((`grep -c ^processor /proc/cpuinfo` * 2))"
+
+ elif [ "${ARCH}" = "sparc" -o "${ARCH}" = "sparc64" ]
+ then
+ # sparc always has "ncpus active"
+ export MAKEOPTS="${MAKEOPTS} -j$((`grep "^ncpus active" /proc/cpuinfo | sed -e "s/^.*: //"` * 2))"
+
+ elif [ "${ARCH}" = "alpha" ]
+ then
+ # alpha has "cpus active", but only when compiled with SMP
+ if [ "`grep -c "^cpus active" /proc/cpuinfo`" = "1" ]
+ then
+ export MAKEOPTS="${MAKEOPTS} -j$((`grep "^cpus active" /proc/cpuinfo | sed -e "s/^.*: //"` * 2))"
+ else
+ export MAKEOPTS="${MAKEOPTS} -j2"
+ fi
+
+ elif [ "${ARCH}" = "ppc" ]
+ then
+ # ppc has "processor", but only when compiled with SMP
+ if [ "`grep -c "^processor" /proc/cpuinfo`" = "1" ]
+ then
+ export MAKEOPTS="${MAKEOPTS} -j$((`grep -c ^processor /proc/cpuinfo` * 2))"
+ else
+ export MAKEOPTS="${MAKEOPTS} -j2"
+ fi
+ else
+ export MAKEOPTS="${MAKEOPTS} -j$((`grep -c ^cpu /proc/cpuinfo` * 2))"
+ die "Unknown ARCH -- ${ARCH}!"
+ fi
+}
+