| 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.11 2002/12/04 21:46: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 | |
| … | |
… | |
| 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}" |
| … | |
… | |
| 309 | then |
311 | then |
| 310 | einfo "Done with patching" |
312 | einfo "Done with patching" |
| 311 | fi |
313 | fi |
| 312 | } |
314 | } |
| 313 | |
315 | |
|
|
316 | # This function check how many cpu's are present, and then set |
|
|
317 | # -j in MAKEOPTS accordingly. |
|
|
318 | # |
|
|
319 | # Thanks to nall <nall@gentoo.org> for this. |
|
|
320 | # |
|
|
321 | get_number_of_jobs() { |
|
|
322 | if [ ! -r /proc/cpuinfo ] |
|
|
323 | then |
|
|
324 | return 1 |
|
|
325 | fi |
|
|
326 | |
|
|
327 | export MAKEOPTS="`echo ${MAKEOPTS} | sed -e 's:-j[0-9]*::g'`" |
|
|
328 | |
|
|
329 | if [ "${ARCH}" = "x86" ] |
|
|
330 | then |
|
|
331 | # x86 always has "processor" |
|
|
332 | export MAKEOPTS="${MAKEOPTS} -j$((`grep -c ^processor /proc/cpuinfo` * 2))" |
|
|
333 | |
|
|
334 | elif [ "${ARCH}" = "sparc" -o "${ARCH}" = "sparc64" ] |
|
|
335 | then |
|
|
336 | # sparc always has "ncpus active" |
|
|
337 | export MAKEOPTS="${MAKEOPTS} -j$((`grep "^ncpus active" /proc/cpuinfo | sed -e "s/^.*: //"` * 2))" |
|
|
338 | |
|
|
339 | elif [ "${ARCH}" = "alpha" ] |
|
|
340 | then |
|
|
341 | # alpha has "cpus active", but only when compiled with SMP |
|
|
342 | if [ "`grep -c "^cpus active" /proc/cpuinfo`" = "1" ] |
|
|
343 | then |
|
|
344 | export MAKEOPTS="${MAKEOPTS} -j$((`grep "^cpus active" /proc/cpuinfo | sed -e "s/^.*: //"` * 2))" |
|
|
345 | else |
|
|
346 | export MAKEOPTS="${MAKEOPTS} -j2" |
|
|
347 | fi |
|
|
348 | |
|
|
349 | elif [ "${ARCH}" = "ppc" ] |
|
|
350 | then |
|
|
351 | # ppc has "processor", but only when compiled with SMP |
|
|
352 | if [ "`grep -c "^processor" /proc/cpuinfo`" = "1" ] |
|
|
353 | then |
|
|
354 | export MAKEOPTS="${MAKEOPTS} -j$((`grep -c ^processor /proc/cpuinfo` * 2))" |
|
|
355 | else |
|
|
356 | export MAKEOPTS="${MAKEOPTS} -j2" |
|
|
357 | fi |
|
|
358 | else |
|
|
359 | export MAKEOPTS="${MAKEOPTS} -j$((`grep -c ^cpu /proc/cpuinfo` * 2))" |
|
|
360 | die "Unknown ARCH -- ${ARCH}!" |
|
|
361 | fi |
|
|
362 | } |
|
|
363 | |