/[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.18
1# Copyright 1999-2002 Gentoo Technologies, Inc. 1# Copyright 1999-2003 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# $Header: /var/cvsroot/gentoo-x86/eclass/eutils.eclass,v 1.18 2003/02/16 04:26:21 vapier Exp $
4#
3# Author: Martin Schlemmer <azarah@gentoo.org> 5# 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 $ 6#
5# This eclass is for general purpose functions that most ebuilds 7# This eclass is for general purpose functions that most ebuilds
6# have to implement themselves. 8# have to implement themselves.
7# 9#
8# NB: If you add anything, please comment it! 10# NB: If you add anything, please comment it!
9 11
10ECLASS=eutils 12ECLASS=eutils
11INHERITED="$INHERITED $ECLASS" 13INHERITED="$INHERITED $ECLASS"
12 14
13newdepend sys-devel/patch 15newdepend "!bootstrap? ( sys-devel/patch )"
14 16
15DESCRIPTION="Based on the ${ECLASS} eclass" 17DESCRIPTION="Based on the ${ECLASS} eclass"
16 18
17# This function generate linker scripts in /usr/lib for dynamic 19# This function generate linker scripts in /usr/lib for dynamic
18# libs in /lib. This is to fix linking problems when you have 20# libs in /lib. This is to fix linking problems when you have
154 local EPATCH_SOURCE="$1/*.${EPATCH_SUFFIX}" 156 local EPATCH_SOURCE="$1/*.${EPATCH_SUFFIX}"
155 else 157 else
156 if [ ! -d ${EPATCH_SOURCE} ] 158 if [ ! -d ${EPATCH_SOURCE} ]
157 then 159 then
158 echo 160 echo
159 eerror "Cannot find \$EPATCH_SOURCE!" 161 eerror "Cannot find \$EPATCH_SOURCE! Value for \$EPATCH_SOURCE is:"
162 eerror
163 eerror " ${EPATCH_SOURCE}"
160 echo 164 echo
161 die "Cannot find \$EPATCH_SOURCE!" 165 die "Cannot find \$EPATCH_SOURCE!"
162 fi 166 fi
163 167
164 local EPATCH_SOURCE="${EPATCH_SOURCE}/*.${EPATCH_SUFFIX}" 168 local EPATCH_SOURCE="${EPATCH_SOURCE}/*.${EPATCH_SUFFIX}"
309 then 313 then
310 einfo "Done with patching" 314 einfo "Done with patching"
311 fi 315 fi
312} 316}
313 317
318# This function check how many cpu's are present, and then set
319# -j in MAKEOPTS accordingly.
320#
321# Thanks to nall <nall@gentoo.org> for this.
322#
323get_number_of_jobs() {
324 local jobs=0
325
326 if [ ! -r /proc/cpuinfo ]
327 then
328 return 1
329 fi
330
331 # This bit is from H?kan Wessberg <nacka-gentoo@refug.org>, bug #13565.
332 if [ "`egrep "^[[:space:]]*MAKEOPTS=" /etc/make.conf | wc -l`" -gt 0 ]
333 then
334 ADMINOPTS="`egrep "^[[:space:]]*MAKEOPTS=" /etc/make.conf | cut -d= -f2 | sed 's/\"//g'`"
335 ADMINPARAM="`echo ${ADMINOPTS} | gawk '{match($0, /-j *[0-9]*/, opt); print opt[0]}'`"
336 ADMINPARAM="${ADMINPARAM/-j}"
337 fi
338
339 export MAKEOPTS="`echo ${MAKEOPTS} | sed -e 's:-j *[0-9]*::g'`"
340
341 if [ "${ARCH}" = "x86" -o "${ARCH}" = "hppa" ]
342 then
343 # x86 and hppa always has "processor"
344 jobs="$((`grep -c ^processor /proc/cpuinfo` * 2))"
345
346 elif [ "${ARCH}" = "sparc" -o "${ARCH}" = "sparc64" ]
347 then
348 # sparc always has "ncpus active"
349 jobs="$((`grep "^ncpus active" /proc/cpuinfo | sed -e "s/^.*: //"` * 2))"
350
351 elif [ "${ARCH}" = "alpha" ]
352 then
353 # alpha has "cpus active", but only when compiled with SMP
354 if [ "`grep -c "^cpus active" /proc/cpuinfo`" -eq 1 ]
355 then
356 jobs="$((`grep "^cpus active" /proc/cpuinfo | sed -e "s/^.*: //"` * 2))"
357 else
358 jobs=2
359 fi
360
361 elif [ "${ARCH}" = "ppc" ]
362 then
363 # ppc has "processor", but only when compiled with SMP
364 if [ "`grep -c "^processor" /proc/cpuinfo`" -eq 1 ]
365 then
366 jobs="$((`grep -c ^processor /proc/cpuinfo` * 2))"
367 else
368 jobs=2
369 fi
370 elif [ "${ARCH}" = "mips" ]
371 then
372 # mips always has "processor"
373 jobs="$((`grep -c ^processor /proc/cpuinfo` * 2))"
374
375 else
376 jobs="$((`grep -c ^cpu /proc/cpuinfo` * 2))"
377 die "Unknown ARCH -- ${ARCH}!"
378 fi
379
380 # Make sure the number is valid ...
381 if [ "${jobs}" -lt 1 ]
382 then
383 jobs=1
384 fi
385
386 if [ -n "${ADMINPARAM}" ]
387 then
388 if [ "${jobs}" -gt "${ADMINPARAM}" ]
389 then
390 einfo "Setting make jobs to \"-j${ADMINPARAM}\" to ensure successful merge..."
391 export MAKEOPTS="${MAKEOPTS} -j${ADMINPARAM}"
392 else
393 einfo "Setting make jobs to \"-j${jobs}\" to ensure successful merge..."
394 export MAKEOPTS="${MAKEOPTS} -j${jobs}"
395 fi
396 fi
397}
398

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

  ViewVC Help
Powered by ViewVC 1.1.20