/[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.19
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.19 2003/02/16 20:12:26 azarah 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.10 2002/12/01 23:22:50 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
153 then 155 then
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
160 if [ -n "$1" -a "${EPATCH_SOURCE}" = "${WORKDIR}/patch" ]
161 then
162 EPATCH_SOURCE="$1"
163 fi
164
158 echo 165 echo
159 eerror "Cannot find \$EPATCH_SOURCE!" 166 eerror "Cannot find \$EPATCH_SOURCE! Value for \$EPATCH_SOURCE is:"
167 eerror
168 eerror " ${EPATCH_SOURCE}"
160 echo 169 echo
161 die "Cannot find \$EPATCH_SOURCE!" 170 die "Cannot find \$EPATCH_SOURCE!"
162 fi 171 fi
163 172
164 local EPATCH_SOURCE="${EPATCH_SOURCE}/*.${EPATCH_SUFFIX}" 173 local EPATCH_SOURCE="${EPATCH_SOURCE}/*.${EPATCH_SUFFIX}"
253 count=5 262 count=5
254 break 263 break
255 fi 264 fi
256 fi 265 fi
257 266
258 if patch ${popts} --dry-run -f -p${count} < ${PATCH_TARGET} >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/} 2>&1 267 if (cat ${PATCH_TARGET} | patch ${popts} --dry-run -f -p${count}) >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/} 2>&1
259 then 268 then
260 draw_line "***** ${x##*/} *****" > ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/}.real 269 draw_line "***** ${x##*/} *****" > ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/}.real
261 echo >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/}.real 270 echo >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/}.real
262 echo "ACTUALLY APPLYING ${x##*/}..." >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/}.real 271 echo "ACTUALLY APPLYING ${x##*/}..." >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/}.real
263 echo >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/}.real 272 echo >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/}.real
264 draw_line "***** ${x##*/} *****" >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/}.real 273 draw_line "***** ${x##*/} *****" >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/}.real
265 274
266 patch ${popts} -p${count} < ${PATCH_TARGET} >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/}.real 2>&1 275 cat ${PATCH_TARGET} | patch ${popts} -p${count} >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/}.real 2>&1
267 276
268 if [ "$?" -ne 0 ] 277 if [ "$?" -ne 0 ]
269 then 278 then
270 cat ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/}.real >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/} 279 cat ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/}.real >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/}
271 echo 280 echo
315# -j in MAKEOPTS accordingly. 324# -j in MAKEOPTS accordingly.
316# 325#
317# Thanks to nall <nall@gentoo.org> for this. 326# Thanks to nall <nall@gentoo.org> for this.
318# 327#
319get_number_of_jobs() { 328get_number_of_jobs() {
329 local jobs=0
330
320 if [ ! -r /proc/cpuinfo ] 331 if [ ! -r /proc/cpuinfo ]
321 then 332 then
322 return 1 333 return 1
323 fi 334 fi
324 335
336 # This bit is from H?kan Wessberg <nacka-gentoo@refug.org>, bug #13565.
337 if [ "`egrep "^[[:space:]]*MAKEOPTS=" /etc/make.conf | wc -l`" -gt 0 ]
338 then
339 ADMINOPTS="`egrep "^[[:space:]]*MAKEOPTS=" /etc/make.conf | cut -d= -f2 | sed 's/\"//g'`"
340 ADMINPARAM="`echo ${ADMINOPTS} | gawk '{match($0, /-j *[0-9]*/, opt); print opt[0]}'`"
341 ADMINPARAM="${ADMINPARAM/-j}"
342 fi
343
325 export MAKEOPTS="`echo ${MAKEOPTS} | sed -e 's:-j[0-9]*::g'`" 344 export MAKEOPTS="`echo ${MAKEOPTS} | sed -e 's:-j *[0-9]*::g'`"
326 345
327 if [ "${ARCH}" = "x86" ] 346 if [ "${ARCH}" = "x86" -o "${ARCH}" = "hppa" ]
328 then 347 then
329 # x86 always has "processor" 348 # x86 and hppa always has "processor"
330 export MAKEOPTS="${MAKEOPTS} -j$((`grep -c ^processor /proc/cpuinfo` * 2))" 349 jobs="$((`grep -c ^processor /proc/cpuinfo` * 2))"
331 350
332 elif [ "${ARCH}" = "sparc" -o "${ARCH}" = "sparc64" ] 351 elif [ "${ARCH}" = "sparc" -o "${ARCH}" = "sparc64" ]
333 then 352 then
334 # sparc always has "ncpus active" 353 # sparc always has "ncpus active"
335 export MAKEOPTS="${MAKEOPTS} -j$((`grep "^ncpus active" /proc/cpuinfo | sed -e "s/^.*: //"` * 2))" 354 jobs="$((`grep "^ncpus active" /proc/cpuinfo | sed -e "s/^.*: //"` * 2))"
336 355
337 elif [ "${ARCH}" = "alpha" ] 356 elif [ "${ARCH}" = "alpha" ]
338 then 357 then
339 # alpha has "cpus active", but only when compiled with SMP 358 # alpha has "cpus active", but only when compiled with SMP
340 if [ "`grep -c "^cpus active" /proc/cpuinfo`" = "1" ] 359 if [ "`grep -c "^cpus active" /proc/cpuinfo`" -eq 1 ]
341 then 360 then
342 export MAKEOPTS="${MAKEOPTS} -j$((`grep "^cpus active" /proc/cpuinfo | sed -e "s/^.*: //"` * 2))" 361 jobs="$((`grep "^cpus active" /proc/cpuinfo | sed -e "s/^.*: //"` * 2))"
343 else 362 else
344 export MAKEOPTS="${MAKEOPTS} -j2" 363 jobs=2
345 fi 364 fi
346 365
347 elif [ "${ARCH}" = "ppc" ] 366 elif [ "${ARCH}" = "ppc" ]
348 then 367 then
349 # ppc has "processor", but only when compiled with SMP 368 # ppc has "processor", but only when compiled with SMP
350 if [ "`grep -c "^processor" /proc/cpuinfo`" = "1" ] 369 if [ "`grep -c "^processor" /proc/cpuinfo`" -eq 1 ]
351 then 370 then
352 export MAKEOPTS="${MAKEOPTS} -j$((`grep -c ^processor /proc/cpuinfo` * 2))" 371 jobs="$((`grep -c ^processor /proc/cpuinfo` * 2))"
353 else 372 else
354 export MAKEOPTS="${MAKEOPTS} -j2" 373 jobs=2
355 fi 374 fi
375 elif [ "${ARCH}" = "mips" ]
376 then
377 # mips always has "processor"
378 jobs="$((`grep -c ^processor /proc/cpuinfo` * 2))"
379
356 else 380 else
357 export MAKEOPTS="${MAKEOPTS} -j$((`grep -c ^cpu /proc/cpuinfo` * 2))" 381 jobs="$((`grep -c ^cpu /proc/cpuinfo` * 2))"
358 die "Unknown ARCH -- ${ARCH}!" 382 die "Unknown ARCH -- ${ARCH}!"
359 fi 383 fi
384
385 # Make sure the number is valid ...
386 if [ "${jobs}" -lt 1 ]
387 then
388 jobs=1
389 fi
390
391 if [ -n "${ADMINPARAM}" ]
392 then
393 if [ "${jobs}" -gt "${ADMINPARAM}" ]
394 then
395 einfo "Setting make jobs to \"-j${ADMINPARAM}\" to ensure successful merge..."
396 export MAKEOPTS="${MAKEOPTS} -j${ADMINPARAM}"
397 else
398 einfo "Setting make jobs to \"-j${jobs}\" to ensure successful merge..."
399 export MAKEOPTS="${MAKEOPTS} -j${jobs}"
400 fi
401 fi
360} 402}
361 403

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

  ViewVC Help
Powered by ViewVC 1.1.20