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

Diff of /eclass/eutils.eclass

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

Revision 1.8 Revision 1.12
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.8 2002/12/01 12:34:23 azarah Exp $ 4# $Header: /var/cvsroot/gentoo-x86/eclass/eutils.eclass,v 1.12 2002/12/14 21:46:25 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
90# Default options for patch 90# Default options for patch
91EPATCH_OPTS="" 91EPATCH_OPTS=""
92# List of patches not to apply. Not this is only file names, 92# List of patches not to apply. Not this is only file names,
93# and not the full path .. 93# and not the full path ..
94EPATCH_EXCLUDE="" 94EPATCH_EXCLUDE=""
95# Change the printed message for a single patch.
96EPATCH_SINGLE_MSG=""
95 97
96# This function is for bulk patching, or in theory for just one 98# This function is for bulk patching, or in theory for just one
97# or two patches. 99# or two patches.
98# 100#
99# It should work with .bz2, .gz, .zip and plain text patches. 101# It should work with .bz2, .gz, .zip and plain text patches.
152 local EPATCH_SOURCE="$1/*.${EPATCH_SUFFIX}" 154 local EPATCH_SOURCE="$1/*.${EPATCH_SUFFIX}"
153 else 155 else
154 if [ ! -d ${EPATCH_SOURCE} ] 156 if [ ! -d ${EPATCH_SOURCE} ]
155 then 157 then
156 echo 158 echo
157 eerror "Cannot find \$EPATCH_SOURCE!" 159 eerror "Cannot find \$EPATCH_SOURCE! Value for \$EPATCH_SOURCE is:"
160 eerror
161 eerror " ${EPATCH_SOURCE}"
158 echo 162 echo
159 die "Cannot find \$EPATCH_SOURCE!" 163 die "Cannot find \$EPATCH_SOURCE!"
160 fi 164 fi
161 165
162 local EPATCH_SOURCE="${EPATCH_SOURCE}/*.${EPATCH_SUFFIX}" 166 local EPATCH_SOURCE="${EPATCH_SOURCE}/*.${EPATCH_SUFFIX}"
190 # New ARCH dependant patch naming scheme... 194 # New ARCH dependant patch naming scheme...
191 # 195 #
192 # ???_arch_foo.patch 196 # ???_arch_foo.patch
193 # 197 #
194 if [ -f ${x} ] && \ 198 if [ -f ${x} ] && \
195 [ -n "$1" -o "${x/_all_}" != "${x}" -o "`eval echo \$\{x/_${ARCH}_\}`" != "${x}" ] 199 [ "${SINGLE_PATCH}" = "yes" -o "${x/_all_}" != "${x}" -o "`eval echo \$\{x/_${ARCH}_\}`" != "${x}" ]
196 then 200 then
197 local count=0 201 local count=0
198 local popts="${EPATCH_OPTS}" 202 local popts="${EPATCH_OPTS}"
199 203
200 if [ -n "${EPATCH_EXCLUDE}" ] 204 if [ -n "${EPATCH_EXCLUDE}" ]
201 then 205 then
202 if [ "${EPATCH_EXCLUDE/${x##*/}}" != "${EPATCH_EXCLUDE}" ] 206 if [ "`eval echo \$\{EPATCH_EXCLUDE/${x##*/}\}`" != "${EPATCH_EXCLUDE}" ]
203 then 207 then
204 continue 208 continue
205 fi 209 fi
206 fi 210 fi
207 211
208 if [ "${SINGLE_PATCH}" = "yes" ] 212 if [ "${SINGLE_PATCH}" = "yes" ]
209 then 213 then
214 if [ -n "${EPATCH_SINGLE_MSG}" ]
215 then
216 einfo "${EPATCH_SINGLE_MSG}"
217 else
210 einfo "Applying ${x##*/}..." 218 einfo "Applying ${x##*/}..."
219 fi
211 else 220 else
212 einfo " ${x##*/}..." 221 einfo " ${x##*/}..."
213 fi 222 fi
214 223
215 echo "***** ${x##*/} *****" > ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/} 224 echo "***** ${x##*/} *****" > ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/}
302 then 311 then
303 einfo "Done with patching" 312 einfo "Done with patching"
304 fi 313 fi
305} 314}
306 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#
321get_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

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

  ViewVC Help
Powered by ViewVC 1.1.20