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

Diff of /eclass/kernel-2.eclass

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

Revision 1.159 Revision 1.200
1# Copyright 1999-2005 Gentoo Foundation 1# Copyright 1999-2005 Gentoo Foundation
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/kernel-2.eclass,v 1.159 2006/02/17 22:18:20 swegener Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/kernel-2.eclass,v 1.200 2007/01/02 01:43:34 dsd Exp $
4 4
5# Description: kernel.eclass rewrite for a clean base regarding the 2.6 5# Description: kernel.eclass rewrite for a clean base regarding the 2.6
6# series of kernel with back-compatibility for 2.4 6# series of kernel with back-compatibility for 2.4
7# 7#
8# Maintainer: John Mylchreest <johnm@gentoo.org> 8# Maintainer: John Mylchreest <johnm@gentoo.org>
21# EXTRAVERSION would be something like : -wolk-4.19-r1 21# EXTRAVERSION would be something like : -wolk-4.19-r1
22# K_NOSETEXTRAVERSION - if this is set then EXTRAVERSION will not be 22# K_NOSETEXTRAVERSION - if this is set then EXTRAVERSION will not be
23# automatically set within the kernel Makefile 23# automatically set within the kernel Makefile
24# K_NOUSENAME - if this is set then EXTRAVERSION will not include the 24# K_NOUSENAME - if this is set then EXTRAVERSION will not include the
25# first part of ${PN} in EXTRAVERSION 25# first part of ${PN} in EXTRAVERSION
26# K_NOUSEPR - if this is set then EXTRAVERSION will not include the
27# anything based on ${PR}.
26# K_PREPATCHED - if the patchset is prepatched (ie: mm-sources, 28# K_PREPATCHED - if the patchset is prepatched (ie: mm-sources,
27# ck-sources, ac-sources) it will use PR (ie: -r5) as 29# ck-sources, ac-sources) it will use PR (ie: -r5) as
28# the patchset version for 30# the patchset version for
29# and not use it as a true package revision 31# and not use it as a true package revision
30# K_EXTRAEINFO - this is a new-line seperated list of einfo displays in 32# K_EXTRAEINFO - this is a new-line seperated list of einfo displays in
38# K_WANT_GENPATCHES - Apply genpatches to kernel source. Provide any 40# K_WANT_GENPATCHES - Apply genpatches to kernel source. Provide any
39# combination of "base" and "extras" 41# combination of "base" and "extras"
40# K_GENPATCHES_VER - The version of the genpatches tarball(s) to apply. 42# K_GENPATCHES_VER - The version of the genpatches tarball(s) to apply.
41# A value of "5" would apply genpatches-2.6.12-5 to 43# A value of "5" would apply genpatches-2.6.12-5 to
42# my-sources-2.6.12.ebuild 44# my-sources-2.6.12.ebuild
45# K_SECURITY_UNSUPPORTED- If set, this kernel is unsupported by Gentoo Security
43 46
44# H_SUPPORTEDARCH - this should be a space separated list of ARCH's which 47# H_SUPPORTEDARCH - this should be a space separated list of ARCH's which
45# can be supported by the headers ebuild 48# can be supported by the headers ebuild
46 49
47# UNIPATCH_LIST - space delimetered list of patches to be applied to the 50# UNIPATCH_LIST - space delimetered list of patches to be applied to the
53# UNIPATCH_DOCS - space delimemeted list of docs to be installed to 56# UNIPATCH_DOCS - space delimemeted list of docs to be installed to
54# the doc dir 57# the doc dir
55# UNIPATCH_STRICTORDER - if this is set places patches into directories of 58# UNIPATCH_STRICTORDER - if this is set places patches into directories of
56# order, so they are applied in the order passed 59# order, so they are applied in the order passed
57 60
58inherit toolchain-funcs versionator multilib 61inherit eutils toolchain-funcs versionator multilib
59EXPORT_FUNCTIONS pkg_setup src_unpack src_compile src_install \ 62EXPORT_FUNCTIONS pkg_setup src_unpack src_compile src_install pkg_preinst pkg_postinst
60 pkg_preinst pkg_postinst
61 63
62# Added by Daniel Ostrow <dostrow@gentoo.org> 64# Added by Daniel Ostrow <dostrow@gentoo.org>
63# This is an ugly hack to get around an issue with a 32-bit userland on ppc64. 65# This is an ugly hack to get around an issue with a 32-bit userland on ppc64.
64# I will remove it when I come up with something more reasonable. 66# I will remove it when I come up with something more reasonable.
65[[ ${PROFILE_ARCH} == 'ppc64' ]] && CHOST='powerpc64-unknown-linux-gnu' 67[[ ${PROFILE_ARCH} == "ppc64" ]] && CHOST="powerpc64-${CHOST#*-}"
66 68
67export CTARGET=${CTARGET:-${CHOST}} 69export CTARGET=${CTARGET:-${CHOST}}
68if [[ ${CTARGET} == ${CHOST} && ${CATEGORY/cross-} != ${CATEGORY} ]]; then 70if [[ ${CTARGET} == ${CHOST} && ${CATEGORY/cross-} != ${CATEGORY} ]]; then
69 export CTARGET=${CATEGORY/cross-} 71 export CTARGET=${CATEGORY/cross-}
70fi 72fi
71 73
72HOMEPAGE="http://www.kernel.org/ http://www.gentoo.org/" 74HOMEPAGE="http://www.kernel.org/ http://www.gentoo.org/ ${HOMEPAGE}"
73LICENSE="GPL-2" 75LICENSE="GPL-2"
76
77# No need to run scanelf/strip on kernel sources/headers (bug #134453).
78RESTRICT="binchecks strip"
74 79
75# set LINUX_HOSTCFLAGS if not already set 80# set LINUX_HOSTCFLAGS if not already set
76[[ -z ${LINUX_HOSTCFLAGS} ]] && \ 81[[ -z ${LINUX_HOSTCFLAGS} ]] && \
77 LINUX_HOSTCFLAGS="-Wall -Wstrict-prototypes -Os -fomit-frame-pointer -I${S}/include" 82 LINUX_HOSTCFLAGS="-Wall -Wstrict-prototypes -Os -fomit-frame-pointer -I${S}/include"
83
84# debugging functions
85#==============================================================
86# this function exists only to help debug kernel-2.eclass
87# if you are adding new functionality in, put a call to it
88# at the start of src_unpack, or during SRC_URI/dep generation.
89debug-print-kernel2-variables() {
90 debug-print "PVR: ${PVR}"
91 debug-print "CKV: ${CKV}"
92 debug-print "OKV: ${OKV}"
93 debug-print "KV: ${KV}"
94 debug-print "KV_FULL: ${KV_FULL}"
95 debug-print "RELEASETYPE: ${RELEASETYPE}"
96 debug-print "RELEASE: ${RELEASE}"
97 debug-print "UNIPATCH_LIST_DEFAULT: ${UNIPATCH_LIST_DEFAULT} "
98 debug-print "UNIPATCH_LIST_GENPATCHES: ${UNIPATCH_LIST_GENPATCHES} "
99 debug-print "UNIPATCH_LIST: ${UNIPATCH_LIST}"
100 debug-print "S: ${S}"
101 debug-print "KERNEL_URI: ${KERNEL_URI}"
102}
78 103
79#Eclass functions only from here onwards ... 104#Eclass functions only from here onwards ...
80#============================================================== 105#==============================================================
81handle_genpatches() { 106handle_genpatches() {
82 local tarball 107 local tarball
139 # Now we know that RELEASE is the -rc/-git 164 # Now we know that RELEASE is the -rc/-git
140 # and RELEASETYPE is the same but with its numerics stripped 165 # and RELEASETYPE is the same but with its numerics stripped
141 # we can work on better sorting EXTRAVERSION. 166 # we can work on better sorting EXTRAVERSION.
142 # first of all, we add the release 167 # first of all, we add the release
143 EXTRAVERSION="${RELEASE}" 168 EXTRAVERSION="${RELEASE}"
169 debug-print "0 EXTRAVERSION:${EXTRAVERSION}"
144 [[ -n ${KV_EXTRA} ]] && EXTRAVERSION=".${KV_EXTRA}${EXTRAVERSION}" 170 [[ -n ${KV_EXTRA} ]] && EXTRAVERSION=".${KV_EXTRA}${EXTRAVERSION}"
145 171
172 debug-print "1 EXTRAVERSION:${EXTRAVERSION}"
173 if [[ -n "${K_NOUSEPR}" ]]; then
174 # Don't add anything based on PR to EXTRAVERSION
175 debug-print "1.0 EXTRAVERSION:${EXTRAVERSION}"
146 if [[ -n ${K_PREPATCHED} ]]; then 176 elif [[ -n ${K_PREPATCHED} ]]; then
177 debug-print "1.1 EXTRAVERSION:${EXTRAVERSION}"
147 EXTRAVERSION="${EXTRAVERSION}-${PN/-*}${PR/r}" 178 EXTRAVERSION="${EXTRAVERSION}-${PN/-*}${PR/r}"
148 elif [[ "${ETYPE}" = "sources" ]]; then 179 elif [[ "${ETYPE}" = "sources" ]]; then
180 debug-print "1.2 EXTRAVERSION:${EXTRAVERSION}"
149 # For some sources we want to use the PV in the extra version 181 # For some sources we want to use the PV in the extra version
150 # This is because upstream releases with a completely different 182 # This is because upstream releases with a completely different
151 # versioning scheme. 183 # versioning scheme.
152 case ${PN/-*} in 184 case ${PN/-*} in
153 wolk) K_USEPV=1;; 185 wolk) K_USEPV=1;;
154 vserver) K_USEPV=1;; 186 vserver) K_USEPV=1;;
155 esac 187 esac
156 188
157 [[ -z ${K_NOUSENAME} ]] && EXTRAVERSION="${EXTRAVERSION}-${PN/-*}" 189 [[ -z "${K_NOUSENAME}" ]] && EXTRAVERSION="${EXTRAVERSION}-${PN/-*}"
158 [[ -n ${K_USEPV} ]] && EXTRAVERSION="${EXTRAVERSION}-${PV//_/-}" 190 [[ -n "${K_USEPV}" ]] && EXTRAVERSION="${EXTRAVERSION}-${PV//_/-}"
159 [[ -n ${PR//r0} ]] && EXTRAVERSION="${EXTRAVERSION}-${PR}" 191 [[ -n "${PR//r0}" ]] && EXTRAVERSION="${EXTRAVERSION}-${PR}"
160 fi 192 fi
193 debug-print "2 EXTRAVERSION:${EXTRAVERSION}"
161 194
162 # The only messing around which should actually effect this is for KV_EXTRA 195 # The only messing around which should actually effect this is for KV_EXTRA
163 # since this has to limit OKV to MAJ.MIN.PAT and strip EXTRA off else 196 # since this has to limit OKV to MAJ.MIN.PAT and strip EXTRA off else
164 # KV_FULL evaluates to MAJ.MIN.PAT.EXT.EXT after EXTRAVERSION 197 # KV_FULL evaluates to MAJ.MIN.PAT.EXT.EXT after EXTRAVERSION
165 if [[ -n ${KV_EXTRA} ]]; then 198 if [[ -n ${KV_EXTRA} ]]; then
201 KERNEL_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/snapshots/patch-${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${RELEASE}.bz2 234 KERNEL_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/snapshots/patch-${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${RELEASE}.bz2
202 mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/testing/patch-${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${RELEASE/-git*}.bz2 235 mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/testing/patch-${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${RELEASE/-git*}.bz2
203 mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/linux-${OKV}.tar.bz2" 236 mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/linux-${OKV}.tar.bz2"
204 UNIPATCH_LIST_DEFAULT="${DISTDIR}/patch-${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${RELEASE/-git*}.bz2 ${DISTDIR}/patch-${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${RELEASE}.bz2" 237 UNIPATCH_LIST_DEFAULT="${DISTDIR}/patch-${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${RELEASE/-git*}.bz2 ${DISTDIR}/patch-${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${RELEASE}.bz2"
205 fi 238 fi
239
240 debug-print-kernel2-variables
206 241
207 handle_genpatches 242 handle_genpatches
208} 243}
209 244
210kernel_is() { 245kernel_is() {
248} 283}
249 284
250# Capture the sources type and set DEPENDs 285# Capture the sources type and set DEPENDs
251if [[ ${ETYPE} == sources ]]; then 286if [[ ${ETYPE} == sources ]]; then
252 DEPEND="!build? ( sys-apps/sed 287 DEPEND="!build? ( sys-apps/sed
253 >=sys-devel/binutils-2.11.90.0.31 ) 288 >=sys-devel/binutils-2.11.90.0.31 )"
254 doc? ( app-text/docbook-sgml-utils
255 app-text/xmlto )"
256 RDEPEND="!build? ( >=sys-libs/ncurses-5.2 289 RDEPEND="!build? ( >=sys-libs/ncurses-5.2
257 sys-devel/make ) 290 sys-devel/make )
258 virtual/dev-manager" 291 virtual/dev-manager"
259 292
260 PROVIDE="virtual/linux-sources" 293 PROVIDE="virtual/linux-sources"
261 kernel_is gt 2 4 && PROVIDE="${PROVIDE} virtual/alsa" 294 kernel_is gt 2 4 && PROVIDE="${PROVIDE} virtual/alsa"
262 295
263 SLOT="${PVR}" 296 SLOT="${PVR}"
264 DESCRIPTION="Sources for the ${KV_MAJOR}.${KV_MINOR} linux kernel" 297 DESCRIPTION="Sources for the ${KV_MAJOR}.${KV_MINOR} linux kernel"
265 IUSE="symlink build doc" 298 IUSE="symlink build"
266elif [[ ${ETYPE} == headers ]]; then 299elif [[ ${ETYPE} == headers ]]; then
267 DESCRIPTION="Linux system headers" 300 DESCRIPTION="Linux system headers"
268 IUSE="" 301
302 # Since we should NOT honour KBUILD_OUTPUT in headers
303 # lets unset it here.
304 unset KBUILD_OUTPUT
269 305
270 if [[ ${CTARGET} = ${CHOST} ]]; then 306 if [[ ${CTARGET} = ${CHOST} ]]; then
271 DEPEND="!virtual/os-headers" 307 DEPEND="!virtual/os-headers"
272 PROVIDE="virtual/os-headers" 308 PROVIDE="virtual/os-headers"
273 SLOT="0" 309 SLOT="0"
282# Cross-compile support functions 318# Cross-compile support functions
283#============================================================== 319#==============================================================
284kernel_header_destdir() { 320kernel_header_destdir() {
285 [[ ${CTARGET} == ${CHOST} ]] \ 321 [[ ${CTARGET} == ${CHOST} ]] \
286 && echo /usr/include \ 322 && echo /usr/include \
287 || echo /usr/${CTARGET}/include 323 || echo /usr/${CTARGET}/usr/include
288} 324}
289 325
290cross_pre_c_headers() { 326cross_pre_c_headers() {
291 [[ -z ${_E_CROSS_HEADERS_ONLY} ]] && return 1 327 use crosscompile_opts_headers-only && [[ ${CHOST} != ${CTARGET} ]]
292 [[ ${CHOST} == ${CTARGET} ]] && return 1
293 return 0
294} 328}
295 329
296env_setup_xmakeopts() { 330env_setup_xmakeopts() {
297 # Kernel ARCH != portage ARCH 331 # Kernel ARCH != portage ARCH
298 export KARCH=$(tc-arch-kernel) 332 export KARCH=$(tc-arch-kernel)
309} 343}
310 344
311# Unpack functions 345# Unpack functions
312#============================================================== 346#==============================================================
313unpack_2_4() { 347unpack_2_4() {
314 env_setup_xmakeopts
315
316 cd "${S}"
317 # this file is required for other things to build properly, 348 # this file is required for other things to build properly,
318 # so we autogenerate it 349 # so we autogenerate it
319 make -s mrproper ${xmakeopts} || die "make mrproper failed" 350 make -s mrproper ${xmakeopts} || die "make mrproper failed"
320 make -s symlinks ${xmakeopts} || die "make symlinks failed" 351 make -s symlinks ${xmakeopts} || die "make symlinks failed"
321 make -s include/linux/version.h ${xmakeopts} || die "make include/linux/version.h failed" 352 make -s include/linux/version.h ${xmakeopts} || die "make include/linux/version.h failed"
322 echo ">>> version.h compiled successfully." 353 echo ">>> version.h compiled successfully."
323} 354}
324 355
325unpack_2_6() { 356unpack_2_6() {
326 env_setup_xmakeopts
327
328 cd "${S}"
329 # this file is required for other things to build properly, so we 357 # this file is required for other things to build properly, so we
330 # autogenerate it ... touch .config to keep version.h build from 358 # autogenerate it ... generate a .config to keep version.h build from
331 # spitting out an annoying warning 359 # spitting out an annoying warning
332 make -s mrproper ${xmakeopts} || die "make mrproper failed" 360 make -s mrproper ${xmakeopts} 2>/dev/null \
361 || die "make mrproper failed"
362
363 # quick fix for bug #132152 which triggers when it cannot include linux
364 # headers (ie, we have not installed it yet)
365 if ! make -s defconfig ${xmakeopts} &>/dev/null 2>&1 ; then
333 touch .config 366 touch .config
334 make -s include/linux/version.h ${xmakeopts} || die "make include/linux/version.h failed" 367 eerror "make defconfig failed."
335 rm -f .config 368 eerror "assuming you dont have any headers installed yet and continuing"
369 epause 5
370 fi
371
372 make -s include/linux/version.h ${xmakeopts} 2>/dev/null \
373 || die "make include/linux/version.h failed"
374 rm -f .config >/dev/null
336} 375}
337 376
338universal_unpack() { 377universal_unpack() {
339 cd ${WORKDIR} 378 cd ${WORKDIR}
340 unpack linux-${OKV}.tar.bz2 379 unpack linux-${OKV}.tar.bz2
380 if [[ -d "linux" ]]; then
381 mv linux linux-${KV_FULL} \
382 || die "Unable to move source tree to ${KV_FULL}."
341 if [[ "${OKV}" != "${KV_FULL}" ]]; then 383 elif [[ "${OKV}" != "${KV_FULL}" ]]; then
342 mv linux-${OKV} linux-${KV_FULL} \ 384 mv linux-${OKV} linux-${KV_FULL} \
343 || die "Unable to move source tree to ${KV_FULL}." 385 || die "Unable to move source tree to ${KV_FULL}."
344 fi 386 fi
345 cd "${S}" 387 cd "${S}"
346 388
347 # remove all backup files 389 # remove all backup files
348 find . -iname "*~" -exec rm {} \; 2> /dev/null 390 find . -iname "*~" -exec rm {} \; 2> /dev/null
349 391
350 # fix a problem on ppc where TOUT writes to /usr/src/linux breaking sandbox 392 # fix a problem on ppc where TOUT writes to /usr/src/linux breaking sandbox
351 use ppc && \ 393 sed -i \
352 sed -ie 's|TOUT := .tmp_gas_check|TOUT := $(T).tmp_gas_check|' \ 394 -e 's|TOUT := .tmp_gas_check|TOUT := $(T).tmp_gas_check|' \
353 "${S}"/arch/ppc/Makefile 395 "${S}"/arch/ppc/Makefile
354} 396}
355 397
356unpack_set_extraversion() { 398unpack_set_extraversion() {
357 cd "${S}" 399 cd "${S}"
358 sed -i -e "s:^\(EXTRAVERSION =\).*:\1 ${EXTRAVERSION}:" Makefile 400 sed -i -e "s:^\(EXTRAVERSION =\).*:\1 ${EXTRAVERSION}:" Makefile
359 cd ${OLDPWD} 401 cd "${OLDPWD}"
360} 402}
361 403
362# Should be done after patches have been applied 404# Should be done after patches have been applied
363# Otherwise patches that modify the same area of Makefile will fail 405# Otherwise patches that modify the same area of Makefile will fail
364unpack_fix_install_path() { 406unpack_fix_install_path() {
365 cd "${S}" 407 cd "${S}"
366 sed -i -e 's:#export\tINSTALL_PATH:export\tINSTALL_PATH:' Makefile 408 sed -i -e 's:#export\tINSTALL_PATH:export\tINSTALL_PATH:' Makefile
367} 409}
368 410
369unpack_fix_docbook() {
370 if [[ -d ${S}/Documentation/DocBook ]]; then
371 cd "${S}"/Documentation/DocBook
372 sed -ie "s:db2:docbook2:g" Makefile
373 cd ${OLDPWD}
374 fi
375}
376
377# Compile Functions 411# Compile Functions
378#============================================================== 412#==============================================================
379compile_headers() { 413compile_headers() {
380 env_setup_xmakeopts 414 env_setup_xmakeopts
381
382 # Since KBUILD_OUTPUT shouldnt be used when compiling headers, lets unset it
383 # if it exists.
384 [[ -n ${KBUILD_OUTPUT} ]] && unset KBUILD_OUTPUT
385 415
386 # if we couldnt obtain HOSTCFLAGS from the Makefile, 416 # if we couldnt obtain HOSTCFLAGS from the Makefile,
387 # then set it to something sane 417 # then set it to something sane
388 local HOSTCFLAGS=$(getfilevar HOSTCFLAGS "${S}"/Makefile) 418 local HOSTCFLAGS=$(getfilevar HOSTCFLAGS "${S}"/Makefile)
389 HOSTCFLAGS=${HOSTCFLAGS:--Wall -Wstrict-prototypes -O2 -fomit-frame-pointer} 419 HOSTCFLAGS=${HOSTCFLAGS:--Wall -Wstrict-prototypes -O2 -fomit-frame-pointer}
391 if kernel_is 2 4; then 421 if kernel_is 2 4; then
392 yes "" | make oldconfig ${xmakeopts} 422 yes "" | make oldconfig ${xmakeopts}
393 echo ">>> make oldconfig complete" 423 echo ">>> make oldconfig complete"
394 make dep ${xmakeopts} 424 make dep ${xmakeopts}
395 elif kernel_is 2 6; then 425 elif kernel_is 2 6; then
426 # 2.6.18 introduces headers_install which means we dont need any
427 # of this crap anymore :D
428 kernel_is ge 2 6 18 && return 0
429
396 # autoconf.h isnt generated unless it already exists. plus, we have 430 # autoconf.h isnt generated unless it already exists. plus, we have
397 # no guarantee that any headers are installed on the system... 431 # no guarantee that any headers are installed on the system...
398 [[ -f ${ROOT}/usr/include/linux/autoconf.h ]] \ 432 [[ -f ${ROOT}/usr/include/linux/autoconf.h ]] \
399 || touch include/linux/autoconf.h 433 || touch include/linux/autoconf.h
400 434
401 # if K_DEFCONFIG isn't set, force to "defconfig" 435 # if K_DEFCONFIG isn't set, force to "defconfig"
402 # needed by mips 436 # needed by mips
403 if [[ -z ${K_DEFCONFIG} ]]; then 437 if [[ -z ${K_DEFCONFIG} ]]; then
438 if [[ $(KV_to_int ${KV}) -ge $(KV_to_int 2.6.16) ]]; then
439 case ${CTARGET} in
440 powerpc64*) K_DEFCONFIG="ppc64_defconfig";;
441 powerpc*) K_DEFCONFIG="pmac32_defconfig";;
442 *) K_DEFCONFIG="defconfig";;
443 esac
444 else
404 K_DEFCONFIG="defconfig" 445 K_DEFCONFIG="defconfig"
446 fi
405 fi 447 fi
406 448
407 # if there arent any installed headers, then there also isnt an asm 449 # if there arent any installed headers, then there also isnt an asm
408 # symlink in /usr/include/, and make defconfig will fail, so we have 450 # symlink in /usr/include/, and make defconfig will fail, so we have
409 # to force an include path with $S. 451 # to force an include path with $S.
410 HOSTCFLAGS="${HOSTCFLAGS} -I${S}/include/" 452 HOSTCFLAGS="${HOSTCFLAGS} -I${S}/include/"
411 ln -sf asm-${KARCH} "${S}"/include/asm 453 ln -sf asm-${KARCH} "${S}"/include/asm
412 cross_pre_c_headers && return 0 454 cross_pre_c_headers && return 0
413 455
414 make ${K_DEFCONFIG} HOSTCFLAGS="${HOSTCFLAGS}" ${xmakeopts} || die "defconfig failed" 456 make ${K_DEFCONFIG} HOSTCFLAGS="${HOSTCFLAGS}" ${xmakeopts} || die "defconfig failed (${K_DEFCONFIG})"
457 if compile_headers_tweak_config ; then
458 yes "" | make oldconfig HOSTCFLAGS="${HOSTCFLAGS}" ${xmakeopts} || die "2nd oldconfig failed"
459 fi
415 make prepare HOSTCFLAGS="${HOSTCFLAGS}" ${xmakeopts} || die "prepare failed" 460 make prepare HOSTCFLAGS="${HOSTCFLAGS}" ${xmakeopts} || die "prepare failed"
416 make prepare-all HOSTCFLAGS="${HOSTCFLAGS}" ${xmakeopts} || die "prepare failed" 461 make prepare-all HOSTCFLAGS="${HOSTCFLAGS}" ${xmakeopts} || die "prepare failed"
417 fi 462 fi
418} 463}
419 464
420compile_manpages() { 465compile_headers_tweak_config() {
421 einfo "Making manpages ..." 466 # some targets can be very very picky, so let's finesse the
422 env -u ARCH make mandocs 467 # .config based upon any info we may have
468 case ${CTARGET} in
469 sh*)
470 sed -i '/CONFIG_CPU_SH/d' .config
471 echo "CONFIG_CPU_SH${CTARGET:2:1}=y" >> .config
472 return 0;;
473 esac
474
475 # no changes, so lets do nothing
476 return 1
423} 477}
424 478
425# install functions 479# install functions
426#============================================================== 480#==============================================================
427install_universal() { 481install_universal() {
428 #fix silly permissions in tarball 482 #fix silly permissions in tarball
429 cd ${WORKDIR} 483 cd ${WORKDIR}
430 chown -R root:root * 484 chown -R root:0 *
431 chmod -R a+r-w+X,u+w * 485 chmod -R a+r-w+X,u+w *
432 cd ${OLDPWD} 486 cd ${OLDPWD}
433} 487}
434 488
435install_headers() { 489install_headers() {
436 local ddir=$(kernel_header_destdir) 490 local ddir=$(kernel_header_destdir)
437 491
492 # 2.6.18 introduces headers_install which means we dont need any
493 # of this crap anymore :D
494 if kernel_is ge 2 6 18 ; then
495 env_setup_xmakeopts
496 emake headers_install INSTALL_HDR_PATH="${D}"/${ddir}/.. ${xmakeopts} || die
497
498 # let other packages install some of these headers
499 rm -rf "${D}"/${ddir}/sound #alsa-headers
500 rm -rf "${D}"/${ddir}/scsi #glibc/uclibc/etc...
501 return 0
502 fi
503
504 # Do not use "linux/*" as that can cause problems with very long
505 # $S values where the cmdline to cp is too long
438 cd "${S}" 506 cd "${S}"
439 dodir ${ddir}/linux 507 dodir ${ddir}/linux
440 cp -ax "${S}"/include/linux/* ${D}/${ddir}/linux 508 cp -pPR "${S}"/include/linux "${D}"/${ddir}/ || die
441 rm -rf ${D}/${ddir}/linux/modules 509 rm -rf "${D}"/${ddir}/linux/modules
442 510
443 # Handle multilib headers and crap 511 # Handle multilib headers and crap
444 local multi_dirs="" multi_defs="" 512 local multi_dirs="" multi_defs=""
445 case $(tc-arch-kernel) in 513 case $(tc-arch-kernel) in
446 sparc64) 514 sparc64)
459 multi_dirs="s390 s390x" 527 multi_dirs="s390 s390x"
460 multi_defs="!__s390x__ __s390x__" 528 multi_defs="!__s390x__ __s390x__"
461 ;; 529 ;;
462 arm) 530 arm)
463 dodir ${ddir}/asm 531 dodir ${ddir}/asm
464 cp -ax "${S}"/include/asm/* "${D}"/${ddir}/asm 532 cp -pPR "${S}"/include/asm/* "${D}"/${ddir}/asm
465 [[ ! -e ${D}/${ddir}/asm/arch ]] && ln -sf arch-ebsa285 "${D}"/${ddir}/asm/arch 533 [[ ! -e ${D}/${ddir}/asm/arch ]] && ln -sf arch-ebsa285 "${D}"/${ddir}/asm/arch
466 [[ ! -e ${D}/${ddir}/asm/proc ]] && ln -sf proc-armv "${D}"/${ddir}/asm/proc 534 [[ ! -e ${D}/${ddir}/asm/proc ]] && ln -sf proc-armv "${D}"/${ddir}/asm/proc
467 ;; 535 ;;
468 powerpc) 536 powerpc)
469 dodir ${ddir}/asm 537 dodir ${ddir}/asm
470 cp -ax "${S}"/include/asm/* ${D}/${ddir}/asm 538 cp -pPR "${S}"/include/asm/* ${D}/${ddir}/asm
471 if [[ -e "${S}"/include/asm-ppc ]] ; then 539 if [[ -e "${S}"/include/asm-ppc ]] ; then
472 dodir ${ddir}/asm-ppc 540 dodir ${ddir}/asm-ppc
473 cp -ax "${S}"/include/asm-ppc/* ${D}/${ddir}/asm-ppc 541 cp -pPR "${S}"/include/asm-ppc/* ${D}/${ddir}/asm-ppc
474 fi 542 fi
475 ;; 543 ;;
476 *) 544 *)
477 dodir ${ddir}/asm 545 dodir ${ddir}/asm
478 cp -ax "${S}"/include/asm/* ${D}/${ddir}/asm 546 cp -pPR "${S}"/include/asm/* ${D}/${ddir}/asm
479 ;; 547 ;;
480 esac 548 esac
481 if [[ -n ${multi_dirs} ]] ; then 549 if [[ -n ${multi_dirs} ]] ; then
482 local d ml_inc="" 550 local d ml_inc=""
483 for d in ${multi_dirs} ; do 551 for d in ${multi_dirs} ; do
484 dodir ${ddir}/asm-${d} 552 dodir ${ddir}/asm-${d}
485 cp -ax "${S}"/include/asm-${d}/* ${D}/${ddir}/asm-${d}/ || die "cp asm-${d} failed" 553 cp -pPR "${S}"/include/asm-${d}/* ${D}/${ddir}/asm-${d}/ || die "cp asm-${d} failed"
486 554
487 ml_inc="${ml_inc} ${multi_defs%% *}:${ddir}/asm-${d}" 555 ml_inc="${ml_inc} ${multi_defs%% *}:${ddir}/asm-${d}"
488 multi_defs=${multi_defs#* } 556 multi_defs=${multi_defs#* }
489 done 557 done
490 create_ml_includes ${ddir}/asm ${ml_inc} 558 create_ml_includes ${ddir}/asm ${ml_inc}
491 fi 559 fi
492 560
493 if kernel_is 2 6; then 561 if kernel_is 2 6; then
494 dodir ${ddir}/asm-generic 562 dodir ${ddir}/asm-generic
495 cp -ax "${S}"/include/asm-generic/* ${D}/${ddir}/asm-generic 563 cp -pPR "${S}"/include/asm-generic/* ${D}/${ddir}/asm-generic
496 fi 564 fi
497 565
498 # clean up 566 # clean up
499 find "${D}" -name '*.orig' -exec rm -f {} \; 567 find "${D}" -name '*.orig' -exec rm -f {} \;
500 568
501 cd ${OLDPWD} 569 cd ${OLDPWD}
502} 570}
503 571
504install_sources() { 572install_sources() {
505 local doc docs file 573 local file
506 574
507 cd "${S}" 575 cd "${S}"
508 dodir /usr/src 576 dodir /usr/src
509 echo ">>> Copying sources ..." 577 echo ">>> Copying sources ..."
510 578
524 [[ -f ${FILESDIR}/../ChangeLog ]] && \ 592 [[ -f ${FILESDIR}/../ChangeLog ]] && \
525 echo "Please check the ebuild ChangeLog for more details." \ 593 echo "Please check the ebuild ChangeLog for more details." \
526 > "${S}"/patches.txt 594 > "${S}"/patches.txt
527 fi 595 fi
528 596
529 if use doc ; then
530 install_manpages
531
532 for doc in ${UNIPATCH_DOCS}; do [[ -f ${doc} ]] && docs="${docs} ${doc}"; done
533 if [[ -f ${S}/patches.txt ]]; then docs="${docs} ${S}/patches.txt"; fi
534 [[ -n ${docs} ]] && dodoc ${docs}
535 fi
536
537 mv ${WORKDIR}/linux* ${D}/usr/src 597 mv ${WORKDIR}/linux* ${D}/usr/src
538}
539
540install_manpages() {
541 kernel_is lt 2 5 && return
542
543 local myfiles="Documentation/DocBook/Makefile"
544 kernel_is lt 2 6 12 && myfiles="scripts/makeman ${myfiles}"
545
546 sed -ie "s#/usr/local/man#${D}/usr/share/man#g" ${myfiles}
547 ebegin "Installing manpages"
548 env -u ARCH make installmandocs
549 eend $?
550 sed -ie "s#${D}/usr/share/man#/usr/local/man#g" ${myfiles}
551} 598}
552 599
553# pkg_preinst functions 600# pkg_preinst functions
554#============================================================== 601#==============================================================
555preinst_headers() { 602preinst_headers() {
565 612
566 # if we have USE=symlink, then force K_SYMLINK=1 613 # if we have USE=symlink, then force K_SYMLINK=1
567 use symlink && K_SYMLINK=1 614 use symlink && K_SYMLINK=1
568 615
569 # if we are to forcably symlink, delete it if it already exists first. 616 # if we are to forcably symlink, delete it if it already exists first.
570 if [[ -n ${K_SYMLINK} ]]; then 617 if [[ ${K_SYMLINK} > 0 ]]; then
571 [[ -h ${ROOT}usr/src/linux ]] && rm ${ROOT}usr/src/linux 618 [[ -h ${ROOT}usr/src/linux ]] && rm ${ROOT}usr/src/linux
572 MAKELINK=1 619 MAKELINK=1
573 fi 620 fi
574 621
575 # if the link doesnt exist, lets create it 622 # if the link doesnt exist, lets create it
582 fi 629 fi
583 630
584 # Don't forget to make directory for sysfs 631 # Don't forget to make directory for sysfs
585 [[ ! -d ${ROOT}sys ]] && kernel_is 2 6 && mkdir ${ROOT}sys 632 [[ ! -d ${ROOT}sys ]] && kernel_is 2 6 && mkdir ${ROOT}sys
586 633
587 echo
588 einfo "After installing a new kernel of any version, it is important"
589 einfo "that you have the appropriate /etc/modules.autoload.d/kernel-X.Y"
590 einfo "created (X.Y is the first 2 parts of your new kernel version)"
591 echo
592 einfo "For example, this kernel will require:"
593 einfo "/etc/modules.autoload.d/kernel-${KV_MAJOR}.${KV_MINOR}"
594 echo 634 echo
595 einfo "If you are upgrading from a previous kernel, you may be interested" 635 einfo "If you are upgrading from a previous kernel, you may be interested"
596 einfo "in the following documents:" 636 einfo "in the following documents:"
597 einfo " - General upgrade guide: http://www.gentoo.org/doc/en/kernel-upgrade.xml" 637 einfo " - General upgrade guide: http://www.gentoo.org/doc/en/kernel-upgrade.xml"
598 kernel_is_2_6 && einfo " - 2.4 to 2.6 migration guide: http://www.gentoo.org/doc/en/migration-to-2.6.xml" 638 kernel_is_2_6 && einfo " - 2.4 to 2.6 migration guide: http://www.gentoo.org/doc/en/migration-to-2.6.xml"
611 651
612 # if K_EXTRAEWARN is set then lets display it now 652 # if K_EXTRAEWARN is set then lets display it now
613 if [[ -n ${K_EXTRAEWARN} ]]; then 653 if [[ -n ${K_EXTRAEWARN} ]]; then
614 echo ${K_EXTRAEWARN} | fmt | 654 echo ${K_EXTRAEWARN} | fmt |
615 while read -s ELINE; do ewarn "${ELINE}"; done 655 while read -s ELINE; do ewarn "${ELINE}"; done
656 fi
657
658 # optionally display security unsupported message
659 if [[ -n ${K_SECURITY_UNSUPPORTED} ]]; then
660 echo
661 ewarn "${PN} is UNSUPPORTED by Gentoo Security."
662 ewarn "This means that it is likely to be vulnerable to recent security issues."
663 ewarn "For specific information on why this kernel is unsupported, please read:"
664 ewarn "http://www.gentoo.org/proj/en/security/kernel.xml"
616 fi 665 fi
617} 666}
618 667
619postinst_headers() { 668postinst_headers() {
620 einfo "Kernel headers are usually only used when recompiling glibc, as such, following the installation" 669 einfo "Kernel headers are usually only used when recompiling glibc, as such, following the installation"
773 if [ -z "${PATCH_DEPTH}" ]; then PATCH_DEPTH=0; fi 822 if [ -z "${PATCH_DEPTH}" ]; then PATCH_DEPTH=0; fi
774 823
775 ebegin "Applying ${i/*\//} (-p${PATCH_DEPTH}+)" 824 ebegin "Applying ${i/*\//} (-p${PATCH_DEPTH}+)"
776 while [ ${PATCH_DEPTH} -lt 5 ]; do 825 while [ ${PATCH_DEPTH} -lt 5 ]; do
777 echo "Attempting Dry-run:" >> ${STDERR_T} 826 echo "Attempting Dry-run:" >> ${STDERR_T}
778 echo "cmd: patch -p${PATCH_DEPTH} --dry-run -f < ${i}" >> ${STDERR_T} 827 echo "cmd: patch -p${PATCH_DEPTH} --no-backup-if-mismatch --dry-run -f < ${i}" >> ${STDERR_T}
779 echo "=======================================================" >> ${STDERR_T} 828 echo "=======================================================" >> ${STDERR_T}
780 if [ $(patch -p${PATCH_DEPTH} --dry-run -f < ${i} >> ${STDERR_T}) $? -eq 0 ]; then 829 if [ $(patch -p${PATCH_DEPTH} --no-backup-if-mismatch --dry-run -f < ${i} >> ${STDERR_T}) $? -eq 0 ]; then
781 echo "Attempting patch:" > ${STDERR_T} 830 echo "Attempting patch:" > ${STDERR_T}
782 echo "cmd: patch -p${PATCH_DEPTH} -f < ${i}" >> ${STDERR_T} 831 echo "cmd: patch -p${PATCH_DEPTH} --no-backup-if-mismatch -f < ${i}" >> ${STDERR_T}
783 echo "=======================================================" >> ${STDERR_T} 832 echo "=======================================================" >> ${STDERR_T}
784 if [ $(patch -p${PATCH_DEPTH} -f < ${i} >> ${STDERR_T}) "$?" -eq 0 ]; then 833 if [ $(patch -p${PATCH_DEPTH} --no-backup-if-mismatch -f < ${i} >> ${STDERR_T}) "$?" -eq 0 ]; then
785 eend 0 834 eend 0
786 rm ${STDERR_T} 835 rm ${STDERR_T}
787 break 836 break
788 else 837 else
789 eend 1 838 eend 1
937 return 0 986 return 0
938} 987}
939 988
940headers___fix() { 989headers___fix() {
941 # Voodoo to partially fix broken upstream headers. 990 # Voodoo to partially fix broken upstream headers.
942 # Issues with this function should go to plasmaroo. 991 # Issues with this function should go to toolchain.
943 sed -i \ 992 sed -i \
944 -e "s/\([ "$'\t'"]\)\(u\|s\)\(8\|16\|32\|64\)\([ "$'\t'"]\)/\1__\2\3\4/g;" \ 993 -e '/^\#define.*_TYPES_H/{:loop n; bloop}' \
945 -e 's/ \(u\|s\)\(8\|16\|32\|64\)$/ __\1\2/g' \ 994 -e 's:\<\([us]\(8\|16\|32\|64\)\)\>:__\1:g' \
946 -e 's/\([(, ]\)\(u\|s\)64\([, )]\)/\1__\264\3/g' \
947 -e "s/^\(u\|s\)\(8\|16\|32\|64\)\([ "$'\t'"]\)/__\1\2\3/g;" \
948 -e "s/ inline / __inline__ /g" \ 995 -e "s/ inline / __inline__ /g" \
949 "$@" 996 "$@"
950} 997}
951 998
952# common functions 999# common functions
953#============================================================== 1000#==============================================================
954kernel-2_src_unpack() { 1001kernel-2_src_unpack() {
955 universal_unpack 1002 universal_unpack
1003 debug-print "Doing unipatch"
956 1004
957 [[ -n ${UNIPATCH_LIST} || -n ${UNIPATCH_LIST_DEFAULT} || -n ${UNIPATCH_LIST_GENPATCHES} ]] && \ 1005 [[ -n ${UNIPATCH_LIST} || -n ${UNIPATCH_LIST_DEFAULT} || -n ${UNIPATCH_LIST_GENPATCHES} ]] && \
958 unipatch "${UNIPATCH_LIST_DEFAULT} ${UNIPATCH_LIST_GENPATCHES} ${UNIPATCH_LIST}" 1006 unipatch "${UNIPATCH_LIST_DEFAULT} ${UNIPATCH_LIST_GENPATCHES} ${UNIPATCH_LIST}"
1007
1008 debug-print "Doing premake"
959 1009
960 # allow ebuilds to massage the source tree after patching but before 1010 # allow ebuilds to massage the source tree after patching but before
961 # we run misc `make` functions below 1011 # we run misc `make` functions below
962 [[ $(type -t kernel-2_hook_premake) == "function" ]] && kernel-2_hook_premake 1012 [[ $(type -t kernel-2_hook_premake) == "function" ]] && kernel-2_hook_premake
963 1013
1014 debug-print "Doing unpack_set_extraversion"
1015
964 [[ -z ${K_NOSETEXTRAVERSION} ]] && unpack_set_extraversion 1016 [[ -z ${K_NOSETEXTRAVERSION} ]] && unpack_set_extraversion
965 unpack_fix_docbook
966 unpack_fix_install_path 1017 unpack_fix_install_path
967 1018
1019 # Setup xmakeopts and cd into sourcetree.
1020 env_setup_xmakeopts
1021 cd "${S}"
1022
1023 # We dont need a version.h for anything other than headers
1024 # at least, I should hope we dont. If this causes problems
1025 # take out the if/fi block and inform me please.
1026 # unpack_2_6 should now be 2.6.17 safe anyways
1027 if [[ ${ETYPE} == headers ]]; then
968 kernel_is 2 4 && unpack_2_4 1028 kernel_is 2 4 && unpack_2_4
969 kernel_is 2 6 && unpack_2_6 1029 kernel_is 2 6 && unpack_2_6
1030 fi
970} 1031}
971 1032
972kernel-2_src_compile() { 1033kernel-2_src_compile() {
973 cd "${S}" 1034 cd "${S}"
974 [[ ${ETYPE} == headers ]] && compile_headers 1035 [[ ${ETYPE} == headers ]] && compile_headers
975 [[ ${ETYPE} == sources ]] && \
976 use doc && compile_manpages
977} 1036}
978 1037
979kernel-2_pkg_preinst() { 1038kernel-2_pkg_preinst() {
980 [[ ${ETYPE} == headers ]] && preinst_headers 1039 [[ ${ETYPE} == headers ]] && preinst_headers
981} 1040}
990 [[ ${ETYPE} == headers ]] && postinst_headers 1049 [[ ${ETYPE} == headers ]] && postinst_headers
991 [[ ${ETYPE} == sources ]] && postinst_sources 1050 [[ ${ETYPE} == sources ]] && postinst_sources
992} 1051}
993 1052
994kernel-2_pkg_setup() { 1053kernel-2_pkg_setup() {
1054 if kernel_is 2 4; then
1055 if [ "$( gcc-major-version )" -eq "4" ] ; then
1056 echo
1057 ewarn "Be warned !! >=sys-devel/gcc-4.0.0 isn't supported with linux-2.4!"
1058 ewarn "Either switch to another gcc-version (via gcc-config) or use a"
1059 ewarn "newer kernel that supports gcc-4."
1060 echo
1061 ewarn "Also be aware that bugreports about gcc-4 not working"
1062 ewarn "with linux-2.4 based ebuilds will be closed as INVALID!"
1063 echo
1064 epause 10
1065 fi
1066 fi
1067
1068 ABI="${KERNEL_ABI}"
995 [[ ${ETYPE} == headers ]] && setup_headers 1069 [[ ${ETYPE} == headers ]] && setup_headers
996 [[ ${ETYPE} == sources ]] && echo ">>> Preparing to unpack ..." 1070 [[ ${ETYPE} == sources ]] && echo ">>> Preparing to unpack ..."
997} 1071}

Legend:
Removed from v.1.159  
changed lines
  Added in v.1.200

  ViewVC Help
Powered by ViewVC 1.1.20