/[gentoo-x86]/eclass/eutils.eclass
Gentoo

Diff of /eclass/eutils.eclass

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.9 Revision 1.10
1# Copyright 1999-2002 Gentoo Technologies, Inc. 1# Copyright 1999-2002 Gentoo Technologies, Inc.
2# Distributed under the terms of the GNU General Public License v2 2# Distributed under the terms of the GNU General Public License v2
3# Author: Martin Schlemmer <azarah@gentoo.org> 3# Author: Martin Schlemmer <azarah@gentoo.org>
4# $Header: /var/cvsroot/gentoo-x86/eclass/eutils.eclass,v 1.9 2002/12/01 15:48:27 azarah Exp $ 4# $Header: /var/cvsroot/gentoo-x86/eclass/eutils.eclass,v 1.10 2002/12/01 23:22:50 azarah Exp $
5# This eclass is for general purpose functions that most ebuilds 5# This eclass is for general purpose functions that most ebuilds
6# have to implement themselves. 6# have to implement themselves.
7# 7#
8# NB: If you add anything, please comment it! 8# NB: If you add anything, please comment it!
9 9
309 then 309 then
310 einfo "Done with patching" 310 einfo "Done with patching"
311 fi 311 fi
312} 312}
313 313
314# This function check how many cpu's are present, and then set
315# -j in MAKEOPTS accordingly.
316#
317# Thanks to nall <nall@gentoo.org> for this.
318#
319get_number_of_jobs() {
320 if [ ! -r /proc/cpuinfo ]
321 then
322 return 1
323 fi
324
325 export MAKEOPTS="`echo ${MAKEOPTS} | sed -e 's:-j[0-9]*::g'`"
326
327 if [ "${ARCH}" = "x86" ]
328 then
329 # x86 always has "processor"
330 export MAKEOPTS="${MAKEOPTS} -j$((`grep -c ^processor /proc/cpuinfo` * 2))"
331
332 elif [ "${ARCH}" = "sparc" -o "${ARCH}" = "sparc64" ]
333 then
334 # sparc always has "ncpus active"
335 export MAKEOPTS="${MAKEOPTS} -j$((`grep "^ncpus active" /proc/cpuinfo | sed -e "s/^.*: //"` * 2))"
336
337 elif [ "${ARCH}" = "alpha" ]
338 then
339 # alpha has "cpus active", but only when compiled with SMP
340 if [ "`grep -c "^cpus active" /proc/cpuinfo`" = "1" ]
341 then
342 export MAKEOPTS="${MAKEOPTS} -j$((`grep "^cpus active" /proc/cpuinfo | sed -e "s/^.*: //"` * 2))"
343 else
344 export MAKEOPTS="${MAKEOPTS} -j2"
345 fi
346
347 elif [ "${ARCH}" = "ppc" ]
348 then
349 # ppc has "processor", but only when compiled with SMP
350 if [ "`grep -c "^processor" /proc/cpuinfo`" = "1" ]
351 then
352 export MAKEOPTS="${MAKEOPTS} -j$((`grep -c ^processor /proc/cpuinfo` * 2))"
353 else
354 export MAKEOPTS="${MAKEOPTS} -j2"
355 fi
356 else
357 export MAKEOPTS="${MAKEOPTS} -j$((`grep -c ^cpu /proc/cpuinfo` * 2))"
358 die "Unknown ARCH -- ${ARCH}!"
359 fi
360}
361

Legend:
Removed from v.1.9  
changed lines
  Added in v.1.10

  ViewVC Help
Powered by ViewVC 1.1.20