/[gentoo-x86]/eclass/kernel-2.eclass
Gentoo

Contents of /eclass/kernel-2.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.234 - (show annotations) (download)
Thu May 20 23:11:48 2010 UTC (9 years, 5 months ago) by robbat2
Branch: MAIN
Changes since 1.233: +14 -2 lines
Bug #317297: Some kernel sources packages in overlays have version numbers like -9999 that does not allow us to work out what the actual version number is for functions like kernel_is. They SHOULD have a CKV variable in this case, but without it, they previously went into an infinite loop during the version detection in the eclass.

1 # Copyright 1999-2009 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: /var/cvsroot/gentoo-x86/eclass/kernel-2.eclass,v 1.233 2010/05/02 11:05:28 ulm Exp $
4
5 # Description: kernel.eclass rewrite for a clean base regarding the 2.6
6 # series of kernel with back-compatibility for 2.4
7 #
8 # Original author: John Mylchreest <johnm@gentoo.org>
9 # Maintainer: kernel-misc@gentoo.org
10 #
11 # Please direct your bugs to the current eclass maintainer :)
12
13 # added functionality:
14 # unipatch - a flexible, singular method to extract, add and remove patches.
15
16 # A Couple of env vars are available to effect usage of this eclass
17 # These are as follows:
18 #
19 # K_USEPV - When setting the EXTRAVERSION variable, it should
20 # add PV to the end.
21 # this is useful for thigns like wolk. IE:
22 # EXTRAVERSION would be something like : -wolk-4.19-r1
23 # K_NOSETEXTRAVERSION - if this is set then EXTRAVERSION will not be
24 # automatically set within the kernel Makefile
25 # K_NOUSENAME - if this is set then EXTRAVERSION will not include the
26 # first part of ${PN} in EXTRAVERSION
27 # K_NOUSEPR - if this is set then EXTRAVERSION will not include the
28 # anything based on ${PR}.
29 # K_PREPATCHED - if the patchset is prepatched (ie: mm-sources,
30 # ck-sources, ac-sources) it will use PR (ie: -r5) as
31 # the patchset version for
32 # and not use it as a true package revision
33 # K_EXTRAEINFO - this is a new-line seperated list of einfo displays in
34 # postinst and can be used to carry additional postinst
35 # messages
36 # K_EXTRAELOG - same as K_EXTRAEINFO except using elog instead of einfo
37 # K_EXTRAEWARN - same as K_EXTRAEINFO except using ewarn instead of einfo
38 # K_SYMLINK - if this is set, then forcably create symlink anyway
39 #
40 # K_DEFCONFIG - Allow specifying a different defconfig target.
41 # If length zero, defaults to "defconfig".
42 # K_WANT_GENPATCHES - Apply genpatches to kernel source. Provide any
43 # combination of "base" and "extras"
44 # K_GENPATCHES_VER - The version of the genpatches tarball(s) to apply.
45 # A value of "5" would apply genpatches-2.6.12-5 to
46 # my-sources-2.6.12.ebuild
47 # K_SECURITY_UNSUPPORTED- If set, this kernel is unsupported by Gentoo Security
48 # K_DEBLOB_AVAILABLE - A value of "0" will disable all of the optional deblob
49 # code. If empty, will be set to "1" if deblobbing is
50 # possible. Test ONLY for "1".
51 # K_PREDEBLOBBED - This kernel was already deblobbed elsewhere.
52 # If false, either optional deblobbing will be available
53 # or the license will note the inclusion of freedist
54 # code.
55
56 # H_SUPPORTEDARCH - this should be a space separated list of ARCH's which
57 # can be supported by the headers ebuild
58
59 # UNIPATCH_LIST - space delimetered list of patches to be applied to the
60 # kernel
61 # UNIPATCH_EXCLUDE - an addition var to support exlusion based completely
62 # on "<passedstring>*" and not "<passedno#>_*"
63 # - this should _NOT_ be used from the ebuild as this is
64 # reserved for end users passing excludes from the cli
65 # UNIPATCH_DOCS - space delimemeted list of docs to be installed to
66 # the doc dir
67 # UNIPATCH_STRICTORDER - if this is set places patches into directories of
68 # order, so they are applied in the order passed
69
70 inherit eutils toolchain-funcs versionator multilib
71 EXPORT_FUNCTIONS pkg_setup src_unpack src_compile src_install pkg_preinst pkg_postinst
72
73 # Added by Daniel Ostrow <dostrow@gentoo.org>
74 # This is an ugly hack to get around an issue with a 32-bit userland on ppc64.
75 # I will remove it when I come up with something more reasonable.
76 [[ ${PROFILE_ARCH} == "ppc64" ]] && CHOST="powerpc64-${CHOST#*-}"
77
78 export CTARGET=${CTARGET:-${CHOST}}
79 if [[ ${CTARGET} == ${CHOST} && ${CATEGORY/cross-} != ${CATEGORY} ]]; then
80 export CTARGET=${CATEGORY/cross-}
81 fi
82
83 HOMEPAGE="http://www.kernel.org/ http://www.gentoo.org/ ${HOMEPAGE}"
84 [[ -z ${LICENSE} ]] && \
85 LICENSE="GPL-2"
86
87 # This is the latest KV_PATCH of the deblob tool available from the
88 # libre-sources upstream.
89 [[ -z ${DEBLOB_MAX_VERSION} ]] && DEBLOB_MAX_VERSION=33
90
91 # No need to run scanelf/strip on kernel sources/headers (bug #134453).
92 RESTRICT="binchecks strip"
93
94 # set LINUX_HOSTCFLAGS if not already set
95 [[ -z ${LINUX_HOSTCFLAGS} ]] && \
96 LINUX_HOSTCFLAGS="-Wall -Wstrict-prototypes -Os -fomit-frame-pointer -I${S}/include"
97
98 # debugging functions
99 #==============================================================
100 # this function exists only to help debug kernel-2.eclass
101 # if you are adding new functionality in, put a call to it
102 # at the start of src_unpack, or during SRC_URI/dep generation.
103 debug-print-kernel2-variables() {
104 for v in PVR CKV OKV KV KV_FULL KV_MAJOR KV_MINOR KV_PATCH RELEASETYPE \
105 RELEASE UNIPATCH_LIST_DEFAULT UNIPATCH_LIST_GENPATCHES \
106 UNIPATCH_LIST S KERNEL_URI ; do
107 debug-print "${v}: ${!v}"
108 done
109 }
110
111 #Eclass functions only from here onwards ...
112 #==============================================================
113 handle_genpatches() {
114 local tarball
115 [[ -z ${K_WANT_GENPATCHES} || -z ${K_GENPATCHES_VER} ]] && return 1
116
117 for i in ${K_WANT_GENPATCHES} ; do
118 tarball="genpatches-${OKV}-${K_GENPATCHES_VER}.${i}.tar.bz2"
119 GENPATCHES_URI="${GENPATCHES_URI} mirror://gentoo/${tarball}"
120 UNIPATCH_LIST_GENPATCHES="${UNIPATCH_LIST_GENPATCHES} ${DISTDIR}/${tarball}"
121 done
122 }
123
124 detect_version() {
125 # this function will detect and set
126 # - OKV: Original Kernel Version (2.6.0/2.6.0-test11)
127 # - KV: Kernel Version (2.6.0-gentoo/2.6.0-test11-gentoo-r1)
128 # - EXTRAVERSION: The additional version appended to OKV (-gentoo/-gentoo-r1)
129
130 if [[ -n ${KV_FULL} ]]; then
131 # we will set this for backwards compatibility.
132 KV=${KV_FULL}
133
134 # we know KV_FULL so lets stop here. but not without resetting S
135 S=${WORKDIR}/linux-${KV_FULL}
136 return
137 fi
138
139 # CKV is used as a comparison kernel version, which is used when
140 # PV doesnt reflect the genuine kernel version.
141 # this gets set to the portage style versioning. ie:
142 # CKV=2.6.11_rc4
143 CKV=${CKV:-${PV}}
144 OKV=${OKV:-${CKV}}
145 OKV=${OKV/_beta/-test}
146 OKV=${OKV/_rc/-rc}
147 OKV=${OKV/-r*}
148 OKV=${OKV/_p*}
149
150 KV_MAJOR=$(get_version_component_range 1 ${OKV})
151 KV_MINOR=$(get_version_component_range 2 ${OKV})
152 KV_PATCH=$(get_version_component_range 3 ${OKV})
153
154 if [[ ${KV_MAJOR}${KV_MINOR}${KV_PATCH} -ge 269 ]]; then
155 KV_EXTRA=$(get_version_component_range 4- ${OKV})
156 KV_EXTRA=${KV_EXTRA/[-_]*}
157 else
158 KV_PATCH=$(get_version_component_range 3- ${OKV})
159 fi
160 KV_PATCH=${KV_PATCH/[-_]*}
161
162 local v n=0 missing
163 for v in CKV OKV KV_{MAJOR,MINOR,PATCH} ; do
164 [[ -z ${!v} ]] && n=1 && missing="${missing}${v} ";
165 done
166 [[ $n -eq 1 ]] && \
167 eerror "Missing variables: ${missing}" && \
168 die "Failed to extract kernel version (try explicit CKV in ebuild)!"
169 unset v n missing
170
171 KERNEL_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/linux-${OKV}.tar.bz2"
172
173 RELEASE=${CKV/${OKV}}
174 RELEASE=${RELEASE/_beta}
175 RELEASE=${RELEASE/_rc/-rc}
176 RELEASE=${RELEASE/_pre/-pre}
177 # We cannot trivally call kernel_is here, because it calls us to detect the
178 # version
179 #kernel_is ge 2 6 && RELEASE=${RELEASE/-pre/-git}
180 [ $(($KV_MAJOR * 1000 + $KV_MINOR)) -ge 2006 ] && RELEASE=${RELEASE/-pre/-git}
181 RELEASETYPE=${RELEASE//[0-9]}
182
183 # Now we know that RELEASE is the -rc/-git
184 # and RELEASETYPE is the same but with its numerics stripped
185 # we can work on better sorting EXTRAVERSION.
186 # first of all, we add the release
187 EXTRAVERSION="${RELEASE}"
188 debug-print "0 EXTRAVERSION:${EXTRAVERSION}"
189 [[ -n ${KV_EXTRA} ]] && EXTRAVERSION=".${KV_EXTRA}${EXTRAVERSION}"
190
191 debug-print "1 EXTRAVERSION:${EXTRAVERSION}"
192 if [[ -n "${K_NOUSEPR}" ]]; then
193 # Don't add anything based on PR to EXTRAVERSION
194 debug-print "1.0 EXTRAVERSION:${EXTRAVERSION}"
195 elif [[ -n ${K_PREPATCHED} ]]; then
196 debug-print "1.1 EXTRAVERSION:${EXTRAVERSION}"
197 EXTRAVERSION="${EXTRAVERSION}-${PN/-*}${PR/r}"
198 elif [[ "${ETYPE}" = "sources" ]]; then
199 debug-print "1.2 EXTRAVERSION:${EXTRAVERSION}"
200 # For some sources we want to use the PV in the extra version
201 # This is because upstream releases with a completely different
202 # versioning scheme.
203 case ${PN/-*} in
204 wolk) K_USEPV=1;;
205 vserver) K_USEPV=1;;
206 esac
207
208 [[ -z "${K_NOUSENAME}" ]] && EXTRAVERSION="${EXTRAVERSION}-${PN/-*}"
209 [[ -n "${K_USEPV}" ]] && EXTRAVERSION="${EXTRAVERSION}-${PV//_/-}"
210 [[ -n "${PR//r0}" ]] && EXTRAVERSION="${EXTRAVERSION}-${PR}"
211 fi
212 debug-print "2 EXTRAVERSION:${EXTRAVERSION}"
213
214 # The only messing around which should actually effect this is for KV_EXTRA
215 # since this has to limit OKV to MAJ.MIN.PAT and strip EXTRA off else
216 # KV_FULL evaluates to MAJ.MIN.PAT.EXT.EXT after EXTRAVERSION
217 if [[ -n ${KV_EXTRA} ]]; then
218 OKV="${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}"
219 KERNEL_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/patch-${CKV}.bz2
220 mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/linux-${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}.tar.bz2"
221 UNIPATCH_LIST_DEFAULT="${DISTDIR}/patch-${CKV}.bz2"
222 fi
223
224 # We need to set this using OKV, but we need to set it before we do any
225 # messing around with OKV based on RELEASETYPE
226 KV_FULL=${OKV}${EXTRAVERSION}
227
228 # we will set this for backwards compatibility.
229 S=${WORKDIR}/linux-${KV_FULL}
230 KV=${KV_FULL}
231
232 # -rc-git pulls can be achieved by specifying CKV
233 # for example:
234 # CKV="2.6.11_rc3_pre2"
235 # will pull:
236 # linux-2.6.10.tar.bz2 & patch-2.6.11-rc3.bz2 & patch-2.6.11-rc3-git2.bz2
237
238 if [[ ${RELEASETYPE} == -rc ]] || [[ ${RELEASETYPE} == -pre ]]; then
239 OKV="${KV_MAJOR}.${KV_MINOR}.$((${KV_PATCH} - 1))"
240 KERNEL_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/testing/patch-${CKV//_/-}.bz2
241 mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/linux-${OKV}.tar.bz2"
242 UNIPATCH_LIST_DEFAULT="${DISTDIR}/patch-${CKV//_/-}.bz2"
243 fi
244
245 if [[ ${RELEASETYPE} == -git ]]; then
246 KERNEL_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/snapshots/patch-${OKV}${RELEASE}.bz2
247 mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/linux-${OKV}.tar.bz2"
248 UNIPATCH_LIST_DEFAULT="${DISTDIR}/patch-${OKV}${RELEASE}.bz2"
249 fi
250
251 if [[ ${RELEASETYPE} == -rc-git ]]; then
252 OKV="${KV_MAJOR}.${KV_MINOR}.$((${KV_PATCH} - 1))"
253 KERNEL_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/snapshots/patch-${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${RELEASE}.bz2
254 mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/testing/patch-${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${RELEASE/-git*}.bz2
255 mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/linux-${OKV}.tar.bz2"
256 UNIPATCH_LIST_DEFAULT="${DISTDIR}/patch-${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${RELEASE/-git*}.bz2 ${DISTDIR}/patch-${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${RELEASE}.bz2"
257 fi
258
259 debug-print-kernel2-variables
260
261 handle_genpatches
262 }
263
264 kernel_is() {
265 # ALL of these should be set before we can safely continue this function.
266 # some of the sources have in the past had only one set.
267 local v n=0
268 for v in OKV KV_{MAJOR,MINOR,PATCH} ; do [[ -z ${!v} ]] && n=1 ; done
269 [[ $n -eq 1 ]] && detect_version
270 unset v n
271
272 # Now we can continue
273 local operator test value x=0 y=0 z=0
274
275 case ${1} in
276 lt) operator="-lt"; shift;;
277 gt) operator="-gt"; shift;;
278 le) operator="-le"; shift;;
279 ge) operator="-ge"; shift;;
280 eq) operator="-eq"; shift;;
281 *) operator="-eq";;
282 esac
283
284 for x in ${@}; do
285 for((y=0; y<$((3 - ${#x})); y++)); do value="${value}0"; done
286 value="${value}${x}"
287 z=$((${z} + 1))
288
289 case ${z} in
290 1) for((y=0; y<$((3 - ${#KV_MAJOR})); y++)); do test="${test}0"; done;
291 test="${test}${KV_MAJOR}";;
292 2) for((y=0; y<$((3 - ${#KV_MINOR})); y++)); do test="${test}0"; done;
293 test="${test}${KV_MINOR}";;
294 3) for((y=0; y<$((3 - ${#KV_PATCH})); y++)); do test="${test}0"; done;
295 test="${test}${KV_PATCH}";;
296 *) die "Error in kernel-2_kernel_is(): Too many parameters.";;
297 esac
298 done
299
300 [ ${test} ${operator} ${value} ] && return 0 || return 1
301 }
302
303 kernel_is_2_4() {
304 kernel_is 2 4
305 }
306
307 kernel_is_2_6() {
308 kernel_is 2 6 || kernel_is 2 5
309 }
310
311 # Capture the sources type and set DEPENDs
312 if [[ ${ETYPE} == sources ]]; then
313 DEPEND="!build? ( sys-apps/sed
314 >=sys-devel/binutils-2.11.90.0.31 )"
315 RDEPEND="!build? ( >=sys-libs/ncurses-5.2
316 sys-devel/make )"
317 PDEPEND="!build? ( virtual/dev-manager )"
318
319 PROVIDE="virtual/linux-sources"
320 kernel_is gt 2 4 && PROVIDE="${PROVIDE} virtual/alsa"
321
322 SLOT="${PVR}"
323 DESCRIPTION="Sources for the ${KV_MAJOR}.${KV_MINOR} linux kernel"
324 IUSE="symlink build"
325
326 # Bug #266157, deblob for libre support
327 if [[ -z ${K_PREDEBLOBBED} ]] ; then
328 if [[ -z ${K_DEBLOB_AVAILABLE} ]] ; then
329 kernel_is ge 2 6 27 && \
330 kernel_is le 2 6 ${DEBLOB_MAX_VERSION} && \
331 K_DEBLOB_AVAILABLE=1
332 fi
333 if [[ ${K_DEBLOB_AVAILABLE} == "1" ]] ; then
334 IUSE="${IUSE} deblob"
335 # Reflect that kernels contain firmware blobs unless otherwise
336 # stripped
337 LICENSE="${LICENSE} !deblob? ( freedist )"
338
339 DEBLOB_PV="${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}"
340 DEBLOB_A="deblob-${DEBLOB_PV}"
341 DEBLOB_HOMEPAGE="http://www.fsfla.org/svnwiki/selibre/linux-libre/"
342 HOMEPAGE="${HOMEPAGE} ${DEBLOB_HOMEPAGE}"
343
344 KERNEL_URI="${KERNEL_URI}
345 deblob? (
346 ${DEBLOB_HOMEPAGE}/download/releases/LATEST-${DEBLOB_PV}.N/${DEBLOB_A}
347 )"
348 else
349 # We have no way to deblob older kernels, so just mark them as
350 # tainted with non-libre materials.
351 LICENSE="${LICENSE} freedist"
352 fi
353 fi
354
355 elif [[ ${ETYPE} == headers ]]; then
356 DESCRIPTION="Linux system headers"
357
358 # Since we should NOT honour KBUILD_OUTPUT in headers
359 # lets unset it here.
360 unset KBUILD_OUTPUT
361
362 if [[ ${CTARGET} = ${CHOST} ]]; then
363 DEPEND="!virtual/os-headers"
364 PROVIDE="virtual/os-headers"
365 SLOT="0"
366 else
367 SLOT="${CTARGET}"
368 fi
369 else
370 eerror "Unknown ETYPE=\"${ETYPE}\", must be \"sources\" or \"headers\""
371 die "Unknown ETYPE=\"${ETYPE}\", must be \"sources\" or \"headers\""
372 fi
373
374 # Cross-compile support functions
375 #==============================================================
376 kernel_header_destdir() {
377 [[ ${CTARGET} == ${CHOST} ]] \
378 && echo /usr/include \
379 || echo /usr/${CTARGET}/usr/include
380 }
381
382 cross_pre_c_headers() {
383 use crosscompile_opts_headers-only && [[ ${CHOST} != ${CTARGET} ]]
384 }
385
386 env_setup_xmakeopts() {
387 # Kernel ARCH != portage ARCH
388 export KARCH=$(tc-arch-kernel)
389
390 # When cross-compiling, we need to set the ARCH/CROSS_COMPILE
391 # variables properly or bad things happen !
392 xmakeopts="ARCH=${KARCH}"
393 if [[ ${CTARGET} != ${CHOST} ]] && ! cross_pre_c_headers ; then
394 xmakeopts="${xmakeopts} CROSS_COMPILE=${CTARGET}-"
395 elif type -p ${CHOST}-ar > /dev/null ; then
396 xmakeopts="${xmakeopts} CROSS_COMPILE=${CHOST}-"
397 fi
398 export xmakeopts
399 }
400
401 # Unpack functions
402 #==============================================================
403 unpack_2_4() {
404 # this file is required for other things to build properly,
405 # so we autogenerate it
406 make -s mrproper ${xmakeopts} || die "make mrproper failed"
407 make -s symlinks ${xmakeopts} || die "make symlinks failed"
408 make -s include/linux/version.h ${xmakeopts} || die "make include/linux/version.h failed"
409 echo ">>> version.h compiled successfully."
410 }
411
412 unpack_2_6() {
413 # this file is required for other things to build properly, so we
414 # autogenerate it ... generate a .config to keep version.h build from
415 # spitting out an annoying warning
416 make -s mrproper ${xmakeopts} 2>/dev/null \
417 || die "make mrproper failed"
418
419 # quick fix for bug #132152 which triggers when it cannot include linux
420 # headers (ie, we have not installed it yet)
421 if ! make -s defconfig ${xmakeopts} &>/dev/null 2>&1 ; then
422 touch .config
423 eerror "make defconfig failed."
424 eerror "assuming you dont have any headers installed yet and continuing"
425 epause 5
426 fi
427
428 make -s include/linux/version.h ${xmakeopts} 2>/dev/null \
429 || die "make include/linux/version.h failed"
430 rm -f .config >/dev/null
431 }
432
433 universal_unpack() {
434 cd "${WORKDIR}"
435 unpack linux-${OKV}.tar.bz2
436 if [[ -d "linux" ]]; then
437 mv linux linux-${KV_FULL} \
438 || die "Unable to move source tree to ${KV_FULL}."
439 elif [[ "${OKV}" != "${KV_FULL}" ]]; then
440 mv linux-${OKV} linux-${KV_FULL} \
441 || die "Unable to move source tree to ${KV_FULL}."
442 fi
443 cd "${S}"
444
445 # remove all backup files
446 find . -iname "*~" -exec rm {} \; 2> /dev/null
447
448 # fix a problem on ppc where TOUT writes to /usr/src/linux breaking sandbox
449 # only do this for kernel < 2.6.27 since this file does not exist in later
450 # kernels
451 if [[ ${KV_MAJOR}.${KV_MINOR}.${KV_PATCH} < 2.6.27 ]]
452 then
453 sed -i \
454 -e 's|TOUT := .tmp_gas_check|TOUT := $(T).tmp_gas_check|' \
455 "${S}"/arch/ppc/Makefile
456 else
457 sed -i \
458 -e 's|TOUT := .tmp_gas_check|TOUT := $(T).tmp_gas_check|' \
459 "${S}"/arch/powerpc/Makefile
460 fi
461 }
462
463 unpack_set_extraversion() {
464 cd "${S}"
465 sed -i -e "s:^\(EXTRAVERSION =\).*:\1 ${EXTRAVERSION}:" Makefile
466 cd "${OLDPWD}"
467 }
468
469 # Should be done after patches have been applied
470 # Otherwise patches that modify the same area of Makefile will fail
471 unpack_fix_install_path() {
472 cd "${S}"
473 sed -i -e 's:#export\tINSTALL_PATH:export\tINSTALL_PATH:' Makefile
474 }
475
476 # Compile Functions
477 #==============================================================
478 compile_headers() {
479 env_setup_xmakeopts
480
481 # if we couldnt obtain HOSTCFLAGS from the Makefile,
482 # then set it to something sane
483 local HOSTCFLAGS=$(getfilevar HOSTCFLAGS "${S}"/Makefile)
484 HOSTCFLAGS=${HOSTCFLAGS:--Wall -Wstrict-prototypes -O2 -fomit-frame-pointer}
485
486 if kernel_is 2 4; then
487 yes "" | make oldconfig ${xmakeopts}
488 echo ">>> make oldconfig complete"
489 make dep ${xmakeopts}
490 elif kernel_is 2 6; then
491 # 2.6.18 introduces headers_install which means we dont need any
492 # of this crap anymore :D
493 kernel_is ge 2 6 18 && return 0
494
495 # autoconf.h isnt generated unless it already exists. plus, we have
496 # no guarantee that any headers are installed on the system...
497 [[ -f ${ROOT}/usr/include/linux/autoconf.h ]] \
498 || touch include/linux/autoconf.h
499
500 # if K_DEFCONFIG isn't set, force to "defconfig"
501 # needed by mips
502 if [[ -z ${K_DEFCONFIG} ]]; then
503 if [[ $(KV_to_int ${KV}) -ge $(KV_to_int 2.6.16) ]]; then
504 case ${CTARGET} in
505 powerpc64*) K_DEFCONFIG="ppc64_defconfig";;
506 powerpc*) K_DEFCONFIG="pmac32_defconfig";;
507 *) K_DEFCONFIG="defconfig";;
508 esac
509 else
510 K_DEFCONFIG="defconfig"
511 fi
512 fi
513
514 # if there arent any installed headers, then there also isnt an asm
515 # symlink in /usr/include/, and make defconfig will fail, so we have
516 # to force an include path with $S.
517 HOSTCFLAGS="${HOSTCFLAGS} -I${S}/include/"
518 ln -sf asm-${KARCH} "${S}"/include/asm
519 cross_pre_c_headers && return 0
520
521 make ${K_DEFCONFIG} HOSTCFLAGS="${HOSTCFLAGS}" ${xmakeopts} || die "defconfig failed (${K_DEFCONFIG})"
522 if compile_headers_tweak_config ; then
523 yes "" | make oldconfig HOSTCFLAGS="${HOSTCFLAGS}" ${xmakeopts} || die "2nd oldconfig failed"
524 fi
525 make prepare HOSTCFLAGS="${HOSTCFLAGS}" ${xmakeopts} || die "prepare failed"
526 make prepare-all HOSTCFLAGS="${HOSTCFLAGS}" ${xmakeopts} || die "prepare failed"
527 fi
528 }
529
530 compile_headers_tweak_config() {
531 # some targets can be very very picky, so let's finesse the
532 # .config based upon any info we may have
533 case ${CTARGET} in
534 sh*)
535 sed -i '/CONFIG_CPU_SH/d' .config
536 echo "CONFIG_CPU_SH${CTARGET:2:1}=y" >> .config
537 return 0;;
538 esac
539
540 # no changes, so lets do nothing
541 return 1
542 }
543
544 # install functions
545 #==============================================================
546 install_universal() {
547 #fix silly permissions in tarball
548 cd "${WORKDIR}"
549 chown -R root:0 * >& /dev/null
550 chmod -R a+r-w+X,u+w *
551 cd ${OLDPWD}
552 }
553
554 install_headers() {
555 local ddir=$(kernel_header_destdir)
556
557 # 2.6.18 introduces headers_install which means we dont need any
558 # of this crap anymore :D
559 if kernel_is ge 2 6 18 ; then
560 env_setup_xmakeopts
561 emake headers_install INSTALL_HDR_PATH="${D}"/${ddir}/.. ${xmakeopts} || die
562
563 # let other packages install some of these headers
564 rm -rf "${D}"/${ddir}/sound #alsa-headers
565 rm -rf "${D}"/${ddir}/scsi #glibc/uclibc/etc...
566 return 0
567 fi
568
569 # Do not use "linux/*" as that can cause problems with very long
570 # $S values where the cmdline to cp is too long
571 cd "${S}"
572 dodir ${ddir}/linux
573 cp -pPR "${S}"/include/linux "${D}"/${ddir}/ || die
574 rm -rf "${D}"/${ddir}/linux/modules
575
576 # Handle multilib headers and crap
577 local multi_dirs="" multi_defs=""
578 case $(tc-arch-kernel) in
579 sparc64)
580 multi_dirs="sparc sparc64"
581 multi_defs="!__arch64__ __arch64__"
582 ;;
583 x86_64)
584 multi_dirs="i386 x86_64"
585 multi_defs="__i386__ __x86_64__"
586 ;;
587 ppc64)
588 multi_dirs="ppc ppc64"
589 multi_defs="!__powerpc64__ __powerpc64__"
590 ;;
591 s390x)
592 multi_dirs="s390 s390x"
593 multi_defs="!__s390x__ __s390x__"
594 ;;
595 arm)
596 dodir ${ddir}/asm
597 cp -pPR "${S}"/include/asm/* "${D}"/${ddir}/asm
598 [[ ! -e ${D}/${ddir}/asm/arch ]] && ln -sf arch-ebsa285 "${D}"/${ddir}/asm/arch
599 [[ ! -e ${D}/${ddir}/asm/proc ]] && ln -sf proc-armv "${D}"/${ddir}/asm/proc
600 ;;
601 powerpc)
602 dodir ${ddir}/asm
603 cp -pPR "${S}"/include/asm/* "${D}"/${ddir}/asm
604 if [[ -e "${S}"/include/asm-ppc ]] ; then
605 dodir ${ddir}/asm-ppc
606 cp -pPR "${S}"/include/asm-ppc/* "${D}"/${ddir}/asm-ppc
607 fi
608 ;;
609 *)
610 dodir ${ddir}/asm
611 cp -pPR "${S}"/include/asm/* "${D}"/${ddir}/asm
612 ;;
613 esac
614 if [[ -n ${multi_dirs} ]] ; then
615 local d ml_inc=""
616 for d in ${multi_dirs} ; do
617 dodir ${ddir}/asm-${d}
618 cp -pPR "${S}"/include/asm-${d}/* "${D}"/${ddir}/asm-${d}/ || die "cp asm-${d} failed"
619
620 ml_inc="${ml_inc} ${multi_defs%% *}:${ddir}/asm-${d}"
621 multi_defs=${multi_defs#* }
622 done
623 create_ml_includes ${ddir}/asm ${ml_inc}
624 fi
625
626 if kernel_is 2 6; then
627 dodir ${ddir}/asm-generic
628 cp -pPR "${S}"/include/asm-generic/* "${D}"/${ddir}/asm-generic
629 fi
630
631 # clean up
632 find "${D}" -name '*.orig' -exec rm -f {} \;
633
634 cd ${OLDPWD}
635 }
636
637 install_sources() {
638 local file
639
640 cd "${S}"
641 dodir /usr/src
642 echo ">>> Copying sources ..."
643
644 file="$(find ${WORKDIR} -iname "docs" -type d)"
645 if [[ -n ${file} ]]; then
646 for file in $(find ${file} -type f); do
647 echo "${file//*docs\/}" >> "${S}"/patches.txt
648 echo "===================================================" >> "${S}"/patches.txt
649 cat ${file} >> "${S}"/patches.txt
650 echo "===================================================" >> "${S}"/patches.txt
651 echo "" >> "${S}"/patches.txt
652 done
653 fi
654
655 if [[ ! -f ${S}/patches.txt ]]; then
656 # patches.txt is empty so lets use our ChangeLog
657 [[ -f ${FILESDIR}/../ChangeLog ]] && \
658 echo "Please check the ebuild ChangeLog for more details." \
659 > "${S}"/patches.txt
660 fi
661
662 mv ${WORKDIR}/linux* "${D}"/usr/src
663 }
664
665 # pkg_preinst functions
666 #==============================================================
667 preinst_headers() {
668 local ddir=$(kernel_header_destdir)
669 [[ -L ${ddir}/linux ]] && rm ${ddir}/linux
670 [[ -L ${ddir}/asm ]] && rm ${ddir}/asm
671 }
672
673 # pkg_postinst functions
674 #==============================================================
675 postinst_sources() {
676 local MAKELINK=0
677
678 # if we have USE=symlink, then force K_SYMLINK=1
679 use symlink && K_SYMLINK=1
680
681 # if we're using a deblobbed kernel, it's not supported
682 [[ $K_DEBLOB_AVAILABLE == 1 ]] && \
683 use deblob && \
684 K_SECURITY_UNSUPPORTED=deblob
685
686 # if we are to forcably symlink, delete it if it already exists first.
687 if [[ ${K_SYMLINK} > 0 ]]; then
688 [[ -h ${ROOT}usr/src/linux ]] && rm ${ROOT}usr/src/linux
689 MAKELINK=1
690 fi
691
692 # if the link doesnt exist, lets create it
693 [[ ! -h ${ROOT}usr/src/linux ]] && MAKELINK=1
694
695 if [[ ${MAKELINK} == 1 ]]; then
696 cd "${ROOT}"usr/src
697 ln -sf linux-${KV_FULL} linux
698 cd ${OLDPWD}
699 fi
700
701 # Don't forget to make directory for sysfs
702 [[ ! -d ${ROOT}sys ]] && kernel_is 2 6 && mkdir ${ROOT}sys
703
704 echo
705 elog "If you are upgrading from a previous kernel, you may be interested"
706 elog "in the following document:"
707 elog " - General upgrade guide: http://www.gentoo.org/doc/en/kernel-upgrade.xml"
708 echo
709
710 # if K_EXTRAEINFO is set then lets display it now
711 if [[ -n ${K_EXTRAEINFO} ]]; then
712 echo ${K_EXTRAEINFO} | fmt |
713 while read -s ELINE; do einfo "${ELINE}"; done
714 fi
715
716 # if K_EXTRAELOG is set then lets display it now
717 if [[ -n ${K_EXTRAELOG} ]]; then
718 echo ${K_EXTRAELOG} | fmt |
719 while read -s ELINE; do elog "${ELINE}"; done
720 fi
721
722 # if K_EXTRAEWARN is set then lets display it now
723 if [[ -n ${K_EXTRAEWARN} ]]; then
724 echo ${K_EXTRAEWARN} | fmt |
725 while read -s ELINE; do ewarn "${ELINE}"; done
726 fi
727
728 # optionally display security unsupported message
729 # Start with why
730 if [[ ${K_SECURITY_UNSUPPORTED} = deblob ]]; then
731 ewarn "Deblobbed kernels are UNSUPPORTED by Gentoo Security."
732 elif [[ -n ${K_SECURITY_UNSUPPORTED} ]]; then
733 ewarn "${PN} is UNSUPPORTED by Gentoo Security."
734 fi
735 # And now the general message.
736 if [[ -n ${K_SECURITY_UNSUPPORTED} ]]; then
737 ewarn "This means that it is likely to be vulnerable to recent security issues."
738 ewarn "For specific information on why this kernel is unsupported, please read:"
739 ewarn "http://www.gentoo.org/proj/en/security/kernel.xml"
740 fi
741
742 # warn sparc users that they need to do cross-compiling with >= 2.6.25(bug #214765)
743 KV_MAJOR=$(get_version_component_range 1 ${OKV})
744 KV_MINOR=$(get_version_component_range 2 ${OKV})
745 KV_PATCH=$(get_version_component_range 3 ${OKV})
746 if [[ "$(tc-arch)" = "sparc" ]] \
747 && [[ ${KV_MAJOR}.${KV_MINOR}.${KV_PATCH} > 2.6.24 ]]
748 then
749 echo
750 elog "NOTE: Since 2.6.25 the kernel Makefile has changed in a way that"
751 elog "you now need to do"
752 elog " make CROSS_COMPILE=sparc64-unknown-linux-gnu-"
753 elog "instead of just"
754 elog " make"
755 elog "to compile the kernel. For more information please browse to"
756 elog "https://bugs.gentoo.org/show_bug.cgi?id=214765"
757 echo
758 fi
759 }
760
761 postinst_headers() {
762 elog "Kernel headers are usually only used when recompiling your system libc, as"
763 elog "such, following the installation of newer headers, it is advised that you"
764 elog "re-merge your system libc."
765 elog "Failure to do so will cause your system libc to not make use of newer"
766 elog "features present in the updated kernel headers."
767 }
768
769 # pkg_setup functions
770 #==============================================================
771 setup_headers() {
772 [[ -z ${H_SUPPORTEDARCH} ]] && H_SUPPORTEDARCH=${PN/-*/}
773 for i in ${H_SUPPORTEDARCH}; do
774 [[ $(tc-arch) == "${i}" ]] && H_ACCEPT_ARCH="yes"
775 done
776
777 if [[ ${H_ACCEPT_ARCH} != "yes" ]]; then
778 echo
779 eerror "This version of ${PN} does not support $(tc-arch)."
780 eerror "Please merge the appropriate sources, in most cases"
781 eerror "(but not all) this will be called $(tc-arch)-headers."
782 die "Package unsupported for $(tc-arch)"
783 fi
784 }
785
786 # unipatch
787 #==============================================================
788 unipatch() {
789 local i x y z extention PIPE_CMD UNIPATCH_DROP KPATCH_DIR PATCH_DEPTH ELINE
790 local STRICT_COUNT PATCH_LEVEL myLC_ALL myLANG extglob_bak
791
792 # set to a standard locale to ensure sorts are ordered properly.
793 myLC_ALL="${LC_ALL}"
794 myLANG="${LANG}"
795 LC_ALL="C"
796 LANG=""
797
798 [ -z "${KPATCH_DIR}" ] && KPATCH_DIR="${WORKDIR}/patches/"
799 [ ! -d ${KPATCH_DIR} ] && mkdir -p ${KPATCH_DIR}
800
801 # We're gonna need it when doing patches with a predefined patchlevel
802 extglob_bak=$(shopt -p extglob)
803 shopt -s extglob
804
805 # This function will unpack all passed tarballs, add any passed patches, and remove any passed patchnumbers
806 # usage can be either via an env var or by params
807 # although due to the nature we pass this within this eclass
808 # it shall be by param only.
809 # -z "${UNIPATCH_LIST}" ] && UNIPATCH_LIST="${@}"
810 UNIPATCH_LIST="${@}"
811
812 #unpack any passed tarballs
813 for i in ${UNIPATCH_LIST}; do
814 if echo ${i} | grep -qs -e "\.tar" -e "\.tbz" -e "\.tgz" ; then
815 if [ -n "${UNIPATCH_STRICTORDER}" ]; then
816 unset z
817 STRICT_COUNT=$((10#${STRICT_COUNT} + 1))
818 for((y=0; y<$((6 - ${#STRICT_COUNT})); y++));
819 do z="${z}0";
820 done
821 PATCH_ORDER="${z}${STRICT_COUNT}"
822
823 mkdir -p "${KPATCH_DIR}/${PATCH_ORDER}"
824 pushd "${KPATCH_DIR}/${PATCH_ORDER}" >/dev/null
825 unpack ${i##*/}
826 popd >/dev/null
827 else
828 pushd "${KPATCH_DIR}" >/dev/null
829 unpack ${i##*/}
830 popd >/dev/null
831 fi
832
833 [[ ${i} == *:* ]] && echo ">>> Strict patch levels not currently supported for tarballed patchsets"
834 else
835 extention=${i/*./}
836 extention=${extention/:*/}
837 PIPE_CMD=""
838 case ${extention} in
839 bz2) PIPE_CMD="bzip2 -dc";;
840 patch) PIPE_CMD="cat";;
841 diff) PIPE_CMD="cat";;
842 gz|Z|z) PIPE_CMD="gzip -dc";;
843 ZIP|zip) PIPE_CMD="unzip -p";;
844 *) UNIPATCH_DROP="${UNIPATCH_DROP} ${i/:*/}";;
845 esac
846
847 PATCH_LEVEL=${i/*([^:])?(:)}
848 i=${i/:*/}
849 x=${i/*\//}
850 x=${x/\.${extention}/}
851
852 if [ -n "${PIPE_CMD}" ]; then
853 if [ ! -r "${i}" ]; then
854 echo
855 eerror "FATAL: unable to locate:"
856 eerror "${i}"
857 eerror "for read-only. The file either has incorrect permissions"
858 eerror "or does not exist."
859 die Unable to locate ${i}
860 fi
861
862 if [ -n "${UNIPATCH_STRICTORDER}" ]; then
863 unset z
864 STRICT_COUNT=$((10#${STRICT_COUNT} + 1))
865 for((y=0; y<$((6 - ${#STRICT_COUNT})); y++));
866 do z="${z}0";
867 done
868 PATCH_ORDER="${z}${STRICT_COUNT}"
869
870 mkdir -p ${KPATCH_DIR}/${PATCH_ORDER}/
871 $(${PIPE_CMD} ${i} > ${KPATCH_DIR}/${PATCH_ORDER}/${x}.patch${PATCH_LEVEL})
872 else
873 $(${PIPE_CMD} ${i} > ${KPATCH_DIR}/${x}.patch${PATCH_LEVEL})
874 fi
875 fi
876 fi
877 done
878
879 #populate KPATCH_DIRS so we know where to look to remove the excludes
880 x=${KPATCH_DIR}
881 KPATCH_DIR=""
882 for i in $(find ${x} -type d | sort -n); do
883 KPATCH_DIR="${KPATCH_DIR} ${i}"
884 done
885
886 # do not apply fbcondecor patch to sparc/sparc64 as it breaks boot
887 # bug #272676
888 if [[ "$(tc-arch)" = "sparc" || "$(tc-arch)" = "sparc64" ]]; then
889 if [[ ${KV_MAJOR}.${KV_MINOR}.${KV_PATCH} > 2.6.28 ]]; then
890 UNIPATCH_DROP="${UNIPATCH_DROP} *_fbcondecor-0.9.6.patch"
891 echo
892 ewarn "fbcondecor currently prevents sparc/sparc64 from booting"
893 ewarn "for kernel versions >= 2.6.29. Removing fbcondecor patch."
894 ewarn "See https://bugs.gentoo.org/show_bug.cgi?id=272676 for details"
895 echo
896 fi
897 fi
898
899 #so now lets get rid of the patchno's we want to exclude
900 UNIPATCH_DROP="${UNIPATCH_EXCLUDE} ${UNIPATCH_DROP}"
901 for i in ${UNIPATCH_DROP}; do
902 ebegin "Excluding Patch #${i}"
903 for x in ${KPATCH_DIR}; do rm -f ${x}/${i}* 2>/dev/null; done
904 eend $?
905 done
906
907 # and now, finally, we patch it :)
908 for x in ${KPATCH_DIR}; do
909 for i in $(find ${x} -maxdepth 1 -iname "*.patch*" -or -iname "*.diff*" | sort -n); do
910 STDERR_T="${T}/${i/*\//}"
911 STDERR_T="${STDERR_T/.patch*/.err}"
912
913 [ -z ${i/*.patch*/} ] && PATCH_DEPTH=${i/*.patch/}
914 #[ -z ${i/*.diff*/} ] && PATCH_DEPTH=${i/*.diff/}
915
916 if [ -z "${PATCH_DEPTH}" ]; then PATCH_DEPTH=0; fi
917
918 ebegin "Applying ${i/*\//} (-p${PATCH_DEPTH}+)"
919 while [ ${PATCH_DEPTH} -lt 5 ]; do
920 echo "Attempting Dry-run:" >> ${STDERR_T}
921 echo "cmd: patch -p${PATCH_DEPTH} --no-backup-if-mismatch --dry-run -f < ${i}" >> ${STDERR_T}
922 echo "=======================================================" >> ${STDERR_T}
923 if [ $(patch -p${PATCH_DEPTH} --no-backup-if-mismatch --dry-run -f < ${i} >> ${STDERR_T}) $? -eq 0 ]; then
924 echo "Attempting patch:" > ${STDERR_T}
925 echo "cmd: patch -p${PATCH_DEPTH} --no-backup-if-mismatch -f < ${i}" >> ${STDERR_T}
926 echo "=======================================================" >> ${STDERR_T}
927 if [ $(patch -p${PATCH_DEPTH} --no-backup-if-mismatch -f < ${i} >> ${STDERR_T}) "$?" -eq 0 ]; then
928 eend 0
929 rm ${STDERR_T}
930 break
931 else
932 eend 1
933 eerror "Failed to apply patch ${i/*\//}"
934 eerror "Please attach ${STDERR_T} to any bug you may post."
935 die "Failed to apply ${i/*\//}"
936 fi
937 else
938 PATCH_DEPTH=$((${PATCH_DEPTH} + 1))
939 fi
940 done
941 if [ ${PATCH_DEPTH} -eq 5 ]; then
942 eend 1
943 eerror "Please attach ${STDERR_T} to any bug you may post."
944 die "Unable to dry-run patch."
945 fi
946 done
947 done
948
949 # This is a quick, and kind of nasty hack to deal with UNIPATCH_DOCS which
950 # sit in KPATCH_DIR's. This is handled properly in the unipatch rewrite,
951 # which is why I'm not taking too much time over this.
952 local tmp
953 for i in ${UNIPATCH_DOCS}; do
954 tmp="${tmp} ${i//*\/}"
955 cp -f ${i} "${T}"/
956 done
957 UNIPATCH_DOCS="${tmp}"
958
959 # clean up KPATCH_DIR's - fixes bug #53610
960 for x in ${KPATCH_DIR}; do rm -Rf ${x}; done
961
962 LC_ALL="${myLC_ALL}"
963 LANG="${myLANG}"
964 eval ${extglob_bak}
965 }
966
967 # getfilevar accepts 2 vars as follows:
968 # getfilevar <VARIABLE> <CONFIGFILE>
969 # pulled from linux-info
970
971 getfilevar() {
972 local workingdir basefname basedname xarch=$(tc-arch-kernel)
973
974 if [[ -z ${1} ]] && [[ ! -f ${2} ]]; then
975 echo -e "\n"
976 eerror "getfilevar requires 2 variables, with the second a valid file."
977 eerror " getfilevar <VARIABLE> <CONFIGFILE>"
978 else
979 workingdir=${PWD}
980 basefname=$(basename ${2})
981 basedname=$(dirname ${2})
982 unset ARCH
983
984 cd ${basedname}
985 echo -e "include ${basefname}\ne:\n\t@echo \$(${1})" | \
986 make ${BUILD_FIXES} -s -f - e 2>/dev/null
987 cd ${workingdir}
988
989 ARCH=${xarch}
990 fi
991 }
992
993 detect_arch() {
994 # This function sets ARCH_URI and ARCH_PATCH
995 # with the neccessary info for the arch sepecific compatibility
996 # patchsets.
997
998 local ALL_ARCH LOOP_ARCH COMPAT_URI i
999
1000 # COMPAT_URI is the contents of ${ARCH}_URI
1001 # ARCH_URI is the URI for all the ${ARCH}_URI patches
1002 # ARCH_PATCH is ARCH_URI broken into files for UNIPATCH
1003
1004 ARCH_URI=""
1005 ARCH_PATCH=""
1006 ALL_ARCH="ALPHA AMD64 ARM HPPA IA64 M68K MIPS PPC PPC64 S390 SH SPARC X86"
1007
1008 for LOOP_ARCH in ${ALL_ARCH}; do
1009 COMPAT_URI="${LOOP_ARCH}_URI"
1010 COMPAT_URI="${!COMPAT_URI}"
1011
1012 [[ -n ${COMPAT_URI} ]] && \
1013 ARCH_URI="${ARCH_URI} $(echo ${LOOP_ARCH} | tr '[:upper:]' '[:lower:]')? ( ${COMPAT_URI} )"
1014
1015 if [[ ${LOOP_ARCH} == "$(echo $(tc-arch-kernel) | tr '[:lower:]' '[:upper:]')" ]]; then
1016 for i in ${COMPAT_URI}; do
1017 ARCH_PATCH="${ARCH_PATCH} ${DISTDIR}/${i/*\//}"
1018 done
1019 fi
1020 done
1021 }
1022
1023 # sparc nastiness
1024 #==============================================================
1025 # This script generates the files in /usr/include/asm for sparc systems
1026 # during installation of sys-kernel/linux-headers.
1027 # Will no longer be needed when full 64 bit support is used on sparc64
1028 # systems.
1029 #
1030 # Shamefully ripped from Debian
1031 # ----------------------------------------------------------------------
1032
1033 # Idea borrowed from RedHat's kernel package
1034
1035 # This is gonna get replaced by something in multilib.eclass soon...
1036 # --eradicator
1037 generate_sparc_asm() {
1038 local name
1039
1040 cd $1 || die
1041 mkdir asm
1042
1043 for h in `( ls asm-sparc; ls asm-sparc64 ) | grep '\.h$' | sort -u`; do
1044 name="$(echo $h | tr a-z. A-Z_)"
1045 # common header
1046 echo "/* All asm/ files are generated and point to the corresponding
1047 * file in asm-sparc or asm-sparc64.
1048 */
1049
1050 #ifndef __SPARCSTUB__${name}__
1051 #define __SPARCSTUB__${name}__
1052 " > asm/${h}
1053
1054 # common for sparc and sparc64
1055 if [ -f asm-sparc/$h -a -f asm-sparc64/$h ]; then
1056 echo "#ifdef __arch64__
1057 #include <asm-sparc64/$h>
1058 #else
1059 #include <asm-sparc/$h>
1060 #endif
1061 " >> asm/${h}
1062
1063 # sparc only
1064 elif [ -f asm-sparc/$h ]; then
1065 echo "#ifndef __arch64__
1066 #include <asm-sparc/$h>
1067 #endif
1068 " >> asm/${h}
1069
1070 # sparc64 only
1071 else
1072 echo "#ifdef __arch64__
1073 #include <asm-sparc64/$h>
1074 #endif
1075 " >> asm/${h}
1076 fi
1077
1078 # common footer
1079 echo "#endif /* !__SPARCSTUB__${name}__ */" >> asm/${h}
1080 done
1081 return 0
1082 }
1083
1084 headers___fix() {
1085 # Voodoo to partially fix broken upstream headers.
1086 # note: do not put inline/asm/volatile together (breaks "inline asm volatile")
1087 sed -i \
1088 -e '/^\#define.*_TYPES_H/{:loop n; bloop}' \
1089 -e 's:\<\([us]\(8\|16\|32\|64\)\)\>:__\1:g' \
1090 -e "s/\([[:space:]]\)inline\([[:space:](]\)/\1__inline__\2/g" \
1091 -e "s/\([[:space:]]\)asm\([[:space:](]\)/\1__asm__\2/g" \
1092 -e "s/\([[:space:]]\)volatile\([[:space:](]\)/\1__volatile__\2/g" \
1093 "$@"
1094 }
1095
1096 # common functions
1097 #==============================================================
1098 kernel-2_src_unpack() {
1099 universal_unpack
1100 debug-print "Doing unipatch"
1101
1102 [[ -n ${UNIPATCH_LIST} || -n ${UNIPATCH_LIST_DEFAULT} || -n ${UNIPATCH_LIST_GENPATCHES} ]] && \
1103 unipatch "${UNIPATCH_LIST_DEFAULT} ${UNIPATCH_LIST_GENPATCHES} ${UNIPATCH_LIST}"
1104
1105 debug-print "Doing premake"
1106
1107 # allow ebuilds to massage the source tree after patching but before
1108 # we run misc `make` functions below
1109 [[ $(type -t kernel-2_hook_premake) == "function" ]] && kernel-2_hook_premake
1110
1111 debug-print "Doing epatch_user"
1112 epatch_user
1113
1114 debug-print "Doing unpack_set_extraversion"
1115
1116 [[ -z ${K_NOSETEXTRAVERSION} ]] && unpack_set_extraversion
1117 unpack_fix_install_path
1118
1119 # Setup xmakeopts and cd into sourcetree.
1120 env_setup_xmakeopts
1121 cd "${S}"
1122
1123 # We dont need a version.h for anything other than headers
1124 # at least, I should hope we dont. If this causes problems
1125 # take out the if/fi block and inform me please.
1126 # unpack_2_6 should now be 2.6.17 safe anyways
1127 if [[ ${ETYPE} == headers ]]; then
1128 kernel_is 2 4 && unpack_2_4
1129 kernel_is 2 6 && unpack_2_6
1130 fi
1131
1132 if [[ $K_DEBLOB_AVAILABLE == 1 ]] && use deblob ; then
1133 cp "${DISTDIR}/${DEBLOB_A}" "${T}"
1134 chmod +x "${T}/${DEBLOB_A}"
1135 fi
1136 }
1137
1138 kernel-2_src_compile() {
1139 cd "${S}"
1140 [[ ${ETYPE} == headers ]] && compile_headers
1141
1142 if [[ $K_DEBLOB_AVAILABLE == 1 ]] && use deblob ; then
1143 echo ">>> Running deblob script ..."
1144 sh "${T}/${DEBLOB_A}" --force || \
1145 die "Deblob script failed to run!!!"
1146 fi
1147 }
1148
1149 kernel-2_pkg_preinst() {
1150 [[ ${ETYPE} == headers ]] && preinst_headers
1151 }
1152
1153 kernel-2_src_install() {
1154 install_universal
1155 [[ ${ETYPE} == headers ]] && install_headers
1156 [[ ${ETYPE} == sources ]] && install_sources
1157 }
1158
1159 kernel-2_pkg_postinst() {
1160 [[ ${ETYPE} == headers ]] && postinst_headers
1161 [[ ${ETYPE} == sources ]] && postinst_sources
1162 }
1163
1164 kernel-2_pkg_setup() {
1165 if kernel_is 2 4; then
1166 if [ "$( gcc-major-version )" -eq "4" ] ; then
1167 echo
1168 ewarn "Be warned !! >=sys-devel/gcc-4.0.0 isn't supported with linux-2.4!"
1169 ewarn "Either switch to another gcc-version (via gcc-config) or use a"
1170 ewarn "newer kernel that supports gcc-4."
1171 echo
1172 ewarn "Also be aware that bugreports about gcc-4 not working"
1173 ewarn "with linux-2.4 based ebuilds will be closed as INVALID!"
1174 echo
1175 epause 10
1176 fi
1177 fi
1178
1179 ABI="${KERNEL_ABI}"
1180 [[ ${ETYPE} == headers ]] && setup_headers
1181 [[ ${ETYPE} == sources ]] && echo ">>> Preparing to unpack ..."
1182 }

  ViewVC Help
Powered by ViewVC 1.1.20