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

Diff of /eclass/eutils.eclass

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

Revision 1.10 Revision 1.15
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.10 2002/12/01 23:22:50 azarah Exp $ 4# $Header: /var/cvsroot/gentoo-x86/eclass/eutils.eclass,v 1.15 2003/02/02 19:43:33 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
10ECLASS=eutils 10ECLASS=eutils
11INHERITED="$INHERITED $ECLASS" 11INHERITED="$INHERITED $ECLASS"
12 12
13newdepend sys-devel/patch 13newdepend "!bootstrap? ( sys-devel/patch )"
14 14
15DESCRIPTION="Based on the ${ECLASS} eclass" 15DESCRIPTION="Based on the ${ECLASS} eclass"
16 16
17# This function generate linker scripts in /usr/lib for dynamic 17# This function generate linker scripts in /usr/lib for dynamic
18# libs in /lib. This is to fix linking problems when you have 18# libs in /lib. This is to fix linking problems when you have
154 local EPATCH_SOURCE="$1/*.${EPATCH_SUFFIX}" 154 local EPATCH_SOURCE="$1/*.${EPATCH_SUFFIX}"
155 else 155 else
156 if [ ! -d ${EPATCH_SOURCE} ] 156 if [ ! -d ${EPATCH_SOURCE} ]
157 then 157 then
158 echo 158 echo
159 eerror "Cannot find \$EPATCH_SOURCE!" 159 eerror "Cannot find \$EPATCH_SOURCE! Value for \$EPATCH_SOURCE is:"
160 eerror
161 eerror " ${EPATCH_SOURCE}"
160 echo 162 echo
161 die "Cannot find \$EPATCH_SOURCE!" 163 die "Cannot find \$EPATCH_SOURCE!"
162 fi 164 fi
163 165
164 local EPATCH_SOURCE="${EPATCH_SOURCE}/*.${EPATCH_SUFFIX}" 166 local EPATCH_SOURCE="${EPATCH_SOURCE}/*.${EPATCH_SUFFIX}"
315# -j in MAKEOPTS accordingly. 317# -j in MAKEOPTS accordingly.
316# 318#
317# Thanks to nall <nall@gentoo.org> for this. 319# Thanks to nall <nall@gentoo.org> for this.
318# 320#
319get_number_of_jobs() { 321get_number_of_jobs() {
322 local jobs=0
323
320 if [ ! -r /proc/cpuinfo ] 324 if [ ! -r /proc/cpuinfo ]
321 then 325 then
322 return 1 326 return 1
323 fi 327 fi
324 328
329 # This bit is from H?kan Wessberg <nacka-gentoo@refug.org>, bug #13565.
330 if [ "`egrep "^[[:space:]]*MAKEOPTS=" /etc/make.conf | wc -l`" -gt 0 ]
331 then
332 ADMINOPTS="`egrep "^[[:space:]]*MAKEOPTS=" /etc/make.conf | cut -d= -f2 | sed 's/\"//g'`"
333 ADMINPARAM="${ADMINOPTS##*-j}"
334 ADMINPARAM="${ADMINPARAM%% -*}"
335 fi
336
325 export MAKEOPTS="`echo ${MAKEOPTS} | sed -e 's:-j[0-9]*::g'`" 337 export MAKEOPTS="`echo ${MAKEOPTS} | sed -e 's:-j[0-9]*::g'`"
326 338
327 if [ "${ARCH}" = "x86" ] 339 if [ "${ARCH}" = "x86" ]
328 then 340 then
329 # x86 always has "processor" 341 # x86 always has "processor"
330 export MAKEOPTS="${MAKEOPTS} -j$((`grep -c ^processor /proc/cpuinfo` * 2))" 342 jobs="$((`grep -c ^processor /proc/cpuinfo` * 2))"
331 343
332 elif [ "${ARCH}" = "sparc" -o "${ARCH}" = "sparc64" ] 344 elif [ "${ARCH}" = "sparc" -o "${ARCH}" = "sparc64" ]
333 then 345 then
334 # sparc always has "ncpus active" 346 # sparc always has "ncpus active"
335 export MAKEOPTS="${MAKEOPTS} -j$((`grep "^ncpus active" /proc/cpuinfo | sed -e "s/^.*: //"` * 2))" 347 jobs="$((`grep "^ncpus active" /proc/cpuinfo | sed -e "s/^.*: //"` * 2))"
336 348
337 elif [ "${ARCH}" = "alpha" ] 349 elif [ "${ARCH}" = "alpha" ]
338 then 350 then
339 # alpha has "cpus active", but only when compiled with SMP 351 # alpha has "cpus active", but only when compiled with SMP
340 if [ "`grep -c "^cpus active" /proc/cpuinfo`" = "1" ] 352 if [ "`grep -c "^cpus active" /proc/cpuinfo`" -eq 1 ]
341 then 353 then
342 export MAKEOPTS="${MAKEOPTS} -j$((`grep "^cpus active" /proc/cpuinfo | sed -e "s/^.*: //"` * 2))" 354 jobs="$((`grep "^cpus active" /proc/cpuinfo | sed -e "s/^.*: //"` * 2))"
343 else 355 else
344 export MAKEOPTS="${MAKEOPTS} -j2" 356 jobs=2
345 fi 357 fi
346 358
347 elif [ "${ARCH}" = "ppc" ] 359 elif [ "${ARCH}" = "ppc" ]
348 then 360 then
349 # ppc has "processor", but only when compiled with SMP 361 # ppc has "processor", but only when compiled with SMP
350 if [ "`grep -c "^processor" /proc/cpuinfo`" = "1" ] 362 if [ "`grep -c "^processor" /proc/cpuinfo`" -eq 1 ]
351 then 363 then
352 export MAKEOPTS="${MAKEOPTS} -j$((`grep -c ^processor /proc/cpuinfo` * 2))" 364 jobs="$((`grep -c ^processor /proc/cpuinfo` * 2))"
353 else 365 else
354 export MAKEOPTS="${MAKEOPTS} -j2" 366 jobs=2
355 fi 367 fi
368 elif [ "${ARCH}" = "mips" ]
369 then
370 # mips always has "processor"
371 jobs="$((`grep -c ^processor /proc/cpuinfo` * 2))"
372
356 else 373 else
357 export MAKEOPTS="${MAKEOPTS} -j$((`grep -c ^cpu /proc/cpuinfo` * 2))" 374 jobs="$((`grep -c ^cpu /proc/cpuinfo` * 2))"
358 die "Unknown ARCH -- ${ARCH}!" 375 die "Unknown ARCH -- ${ARCH}!"
359 fi 376 fi
377
378 # Make sure the number is valid ...
379 if [ "${jobs}" -lt 1 ]
380 then
381 jobs=1
382 fi
383
384 if [ -n "${ADMINPARAM}" ]
385 then
386 if [ "${jobs}" -gt "${ADMINPARAM}" ]
387 then
388 einfo "Setting make jobs to \"-j${ADMINPARAM}\" to ensure successful merge..."
389 export MAKEOPTS="${MAKEOPTS} -j${ADMINPARAM}"
390 else
391 einfo "Setting make jobs to \"-j${jobs}\" to ensure successful merge..."
392 export MAKEOPTS="${MAKEOPTS} -j${jobs}"
393 fi
394 fi
360} 395}
361 396

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

  ViewVC Help
Powered by ViewVC 1.1.20