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

Diff of /eclass/eutils.eclass

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

Revision 1.12 Revision 1.13
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.12 2002/12/14 21:46:25 azarah Exp $ 4# $Header: /var/cvsroot/gentoo-x86/eclass/eutils.eclass,v 1.13 2003/01/17 08:08:48 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
317# -j in MAKEOPTS accordingly. 317# -j in MAKEOPTS accordingly.
318# 318#
319# Thanks to nall <nall@gentoo.org> for this. 319# Thanks to nall <nall@gentoo.org> for this.
320# 320#
321get_number_of_jobs() { 321get_number_of_jobs() {
322 local jobs=0
323
322 if [ ! -r /proc/cpuinfo ] 324 if [ ! -r /proc/cpuinfo ]
323 then 325 then
324 return 1 326 return 1
325 fi 327 fi
326 328
327 export MAKEOPTS="`echo ${MAKEOPTS} | sed -e 's:-j[0-9]*::g'`" 329 export MAKEOPTS="`echo ${MAKEOPTS} | sed -e 's:-j[0-9]*::g'`"
328 330
329 if [ "${ARCH}" = "x86" ] 331 if [ "${ARCH}" = "x86" ]
330 then 332 then
331 # x86 always has "processor" 333 # x86 always has "processor"
332 export MAKEOPTS="${MAKEOPTS} -j$((`grep -c ^processor /proc/cpuinfo` * 2))" 334 jobs="$((`grep -c ^processor /proc/cpuinfo` * 2))"
333 335
334 elif [ "${ARCH}" = "sparc" -o "${ARCH}" = "sparc64" ] 336 elif [ "${ARCH}" = "sparc" -o "${ARCH}" = "sparc64" ]
335 then 337 then
336 # sparc always has "ncpus active" 338 # sparc always has "ncpus active"
337 export MAKEOPTS="${MAKEOPTS} -j$((`grep "^ncpus active" /proc/cpuinfo | sed -e "s/^.*: //"` * 2))" 339 jobs="$((`grep "^ncpus active" /proc/cpuinfo | sed -e "s/^.*: //"` * 2))"
338 340
339 elif [ "${ARCH}" = "alpha" ] 341 elif [ "${ARCH}" = "alpha" ]
340 then 342 then
341 # alpha has "cpus active", but only when compiled with SMP 343 # alpha has "cpus active", but only when compiled with SMP
342 if [ "`grep -c "^cpus active" /proc/cpuinfo`" = "1" ] 344 if [ "`grep -c "^cpus active" /proc/cpuinfo`" -eq 1 ]
343 then 345 then
344 export MAKEOPTS="${MAKEOPTS} -j$((`grep "^cpus active" /proc/cpuinfo | sed -e "s/^.*: //"` * 2))" 346 jobs="$((`grep "^cpus active" /proc/cpuinfo | sed -e "s/^.*: //"` * 2))"
345 else 347 else
346 export MAKEOPTS="${MAKEOPTS} -j2" 348 jobs=2
347 fi 349 fi
348 350
349 elif [ "${ARCH}" = "ppc" ] 351 elif [ "${ARCH}" = "ppc" ]
350 then 352 then
351 # ppc has "processor", but only when compiled with SMP 353 # ppc has "processor", but only when compiled with SMP
352 if [ "`grep -c "^processor" /proc/cpuinfo`" = "1" ] 354 if [ "`grep -c "^processor" /proc/cpuinfo`" -eq 1 ]
353 then 355 then
354 export MAKEOPTS="${MAKEOPTS} -j$((`grep -c ^processor /proc/cpuinfo` * 2))" 356 jobs="$((`grep -c ^processor /proc/cpuinfo` * 2))"
355 else 357 else
356 export MAKEOPTS="${MAKEOPTS} -j2" 358 jobs=2
357 fi 359 fi
360 elif [ "${ARCH}" = "mips" ]
361 then
362 # mips always has "processor"
363 jobs="$((`grep -c ^processor /proc/cpuinfo` * 2))"
364
358 else 365 else
359 export MAKEOPTS="${MAKEOPTS} -j$((`grep -c ^cpu /proc/cpuinfo` * 2))" 366 jobs="$((`grep -c ^cpu /proc/cpuinfo` * 2))"
360 die "Unknown ARCH -- ${ARCH}!" 367 die "Unknown ARCH -- ${ARCH}!"
361 fi 368 fi
369
370 # Make sure the number is valid ...
371 if [ "${jobs}" -lt 1 ]
372 then
373 jobs=1
374 fi
375
376 export MAKEOPTS="${MAKEOPTS} -j${jobs}"
362} 377}
363 378

Legend:
Removed from v.1.12  
changed lines
  Added in v.1.13

  ViewVC Help
Powered by ViewVC 1.1.20