/[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.197
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.197 2006/10/26 06:55:31 vapier 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
53# UNIPATCH_DOCS - space delimemeted list of docs to be installed to 55# UNIPATCH_DOCS - space delimemeted list of docs to be installed to
54# the doc dir 56# the doc dir
55# UNIPATCH_STRICTORDER - if this is set places patches into directories of 57# UNIPATCH_STRICTORDER - if this is set places patches into directories of
56# order, so they are applied in the order passed 58# order, so they are applied in the order passed
57 59
58inherit toolchain-funcs versionator multilib 60inherit eutils toolchain-funcs versionator multilib
59EXPORT_FUNCTIONS pkg_setup src_unpack src_compile src_install \ 61EXPORT_FUNCTIONS pkg_setup src_unpack src_compile src_install pkg_preinst pkg_postinst
60 pkg_preinst pkg_postinst
61 62
62# Added by Daniel Ostrow <dostrow@gentoo.org> 63# 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. 64# 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. 65# I will remove it when I come up with something more reasonable.
65[[ ${PROFILE_ARCH} == 'ppc64' ]] && CHOST='powerpc64-unknown-linux-gnu' 66[[ ${PROFILE_ARCH} == "ppc64" ]] && CHOST="powerpc64-${CHOST#*-}"
66 67
67export CTARGET=${CTARGET:-${CHOST}} 68export CTARGET=${CTARGET:-${CHOST}}
68if [[ ${CTARGET} == ${CHOST} && ${CATEGORY/cross-} != ${CATEGORY} ]]; then 69if [[ ${CTARGET} == ${CHOST} && ${CATEGORY/cross-} != ${CATEGORY} ]]; then
69 export CTARGET=${CATEGORY/cross-} 70 export CTARGET=${CATEGORY/cross-}
70fi 71fi
71 72
72HOMEPAGE="http://www.kernel.org/ http://www.gentoo.org/" 73HOMEPAGE="http://www.kernel.org/ http://www.gentoo.org/ ${HOMEPAGE}"
73LICENSE="GPL-2" 74LICENSE="GPL-2"
75
76# No need to run scanelf/strip on kernel sources/headers (bug #134453).
77RESTRICT="binchecks strip"
74 78
75# set LINUX_HOSTCFLAGS if not already set 79# set LINUX_HOSTCFLAGS if not already set
76[[ -z ${LINUX_HOSTCFLAGS} ]] && \ 80[[ -z ${LINUX_HOSTCFLAGS} ]] && \
77 LINUX_HOSTCFLAGS="-Wall -Wstrict-prototypes -Os -fomit-frame-pointer -I${S}/include" 81 LINUX_HOSTCFLAGS="-Wall -Wstrict-prototypes -Os -fomit-frame-pointer -I${S}/include"
82
83# debugging functions
84#==============================================================
85# this function exists only to help debug kernel-2.eclass
86# if you are adding new functionality in, put a call to it
87# at the start of src_unpack, or during SRC_URI/dep generation.
88debug-print-kernel2-variables() {
89 debug-print "PVR: ${PVR}"
90 debug-print "CKV: ${CKV}"
91 debug-print "OKV: ${OKV}"
92 debug-print "KV: ${KV}"
93 debug-print "KV_FULL: ${KV_FULL}"
94 debug-print "RELEASETYPE: ${RELEASETYPE}"
95 debug-print "RELEASE: ${RELEASE}"
96 debug-print "UNIPATCH_LIST_DEFAULT: ${UNIPATCH_LIST_DEFAULT} "
97 debug-print "UNIPATCH_LIST_GENPATCHES: ${UNIPATCH_LIST_GENPATCHES} "
98 debug-print "UNIPATCH_LIST: ${UNIPATCH_LIST}"
99 debug-print "S: ${S}"
100 debug-print "KERNEL_URI: ${KERNEL_URI}"
101}
78 102
79#Eclass functions only from here onwards ... 103#Eclass functions only from here onwards ...
80#============================================================== 104#==============================================================
81handle_genpatches() { 105handle_genpatches() {
82 local tarball 106 local tarball
139 # Now we know that RELEASE is the -rc/-git 163 # Now we know that RELEASE is the -rc/-git
140 # and RELEASETYPE is the same but with its numerics stripped 164 # and RELEASETYPE is the same but with its numerics stripped
141 # we can work on better sorting EXTRAVERSION. 165 # we can work on better sorting EXTRAVERSION.
142 # first of all, we add the release 166 # first of all, we add the release
143 EXTRAVERSION="${RELEASE}" 167 EXTRAVERSION="${RELEASE}"
168 debug-print "0 EXTRAVERSION:${EXTRAVERSION}"
144 [[ -n ${KV_EXTRA} ]] && EXTRAVERSION=".${KV_EXTRA}${EXTRAVERSION}" 169 [[ -n ${KV_EXTRA} ]] && EXTRAVERSION=".${KV_EXTRA}${EXTRAVERSION}"
145 170
171 debug-print "1 EXTRAVERSION:${EXTRAVERSION}"
172 if [[ -n "${K_NOUSEPR}" ]]; then
173 # Don't add anything based on PR to EXTRAVERSION
174 debug-print "1.0 EXTRAVERSION:${EXTRAVERSION}"
146 if [[ -n ${K_PREPATCHED} ]]; then 175 elif [[ -n ${K_PREPATCHED} ]]; then
176 debug-print "1.1 EXTRAVERSION:${EXTRAVERSION}"
147 EXTRAVERSION="${EXTRAVERSION}-${PN/-*}${PR/r}" 177 EXTRAVERSION="${EXTRAVERSION}-${PN/-*}${PR/r}"
148 elif [[ "${ETYPE}" = "sources" ]]; then 178 elif [[ "${ETYPE}" = "sources" ]]; then
179 debug-print "1.2 EXTRAVERSION:${EXTRAVERSION}"
149 # For some sources we want to use the PV in the extra version 180 # For some sources we want to use the PV in the extra version
150 # This is because upstream releases with a completely different 181 # This is because upstream releases with a completely different
151 # versioning scheme. 182 # versioning scheme.
152 case ${PN/-*} in 183 case ${PN/-*} in
153 wolk) K_USEPV=1;; 184 wolk) K_USEPV=1;;
154 vserver) K_USEPV=1;; 185 vserver) K_USEPV=1;;
155 esac 186 esac
156 187
157 [[ -z ${K_NOUSENAME} ]] && EXTRAVERSION="${EXTRAVERSION}-${PN/-*}" 188 [[ -z "${K_NOUSENAME}" ]] && EXTRAVERSION="${EXTRAVERSION}-${PN/-*}"
158 [[ -n ${K_USEPV} ]] && EXTRAVERSION="${EXTRAVERSION}-${PV//_/-}" 189 [[ -n "${K_USEPV}" ]] && EXTRAVERSION="${EXTRAVERSION}-${PV//_/-}"
159 [[ -n ${PR//r0} ]] && EXTRAVERSION="${EXTRAVERSION}-${PR}" 190 [[ -n "${PR//r0}" ]] && EXTRAVERSION="${EXTRAVERSION}-${PR}"
160 fi 191 fi
192 debug-print "2 EXTRAVERSION:${EXTRAVERSION}"
161 193
162 # The only messing around which should actually effect this is for KV_EXTRA 194 # 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 195 # 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 196 # KV_FULL evaluates to MAJ.MIN.PAT.EXT.EXT after EXTRAVERSION
165 if [[ -n ${KV_EXTRA} ]]; then 197 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 233 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 234 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" 235 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" 236 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 237 fi
238
239 debug-print-kernel2-variables
206 240
207 handle_genpatches 241 handle_genpatches
208} 242}
209 243
210kernel_is() { 244kernel_is() {
248} 282}
249 283
250# Capture the sources type and set DEPENDs 284# Capture the sources type and set DEPENDs
251if [[ ${ETYPE} == sources ]]; then 285if [[ ${ETYPE} == sources ]]; then
252 DEPEND="!build? ( sys-apps/sed 286 DEPEND="!build? ( sys-apps/sed
253 >=sys-devel/binutils-2.11.90.0.31 ) 287 >=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 288 RDEPEND="!build? ( >=sys-libs/ncurses-5.2
257 sys-devel/make ) 289 sys-devel/make )
258 virtual/dev-manager" 290 virtual/dev-manager"
259 291
260 PROVIDE="virtual/linux-sources" 292 PROVIDE="virtual/linux-sources"
261 kernel_is gt 2 4 && PROVIDE="${PROVIDE} virtual/alsa" 293 kernel_is gt 2 4 && PROVIDE="${PROVIDE} virtual/alsa"
262 294
263 SLOT="${PVR}" 295 SLOT="${PVR}"
264 DESCRIPTION="Sources for the ${KV_MAJOR}.${KV_MINOR} linux kernel" 296 DESCRIPTION="Sources for the ${KV_MAJOR}.${KV_MINOR} linux kernel"
265 IUSE="symlink build doc" 297 IUSE="symlink build"
266elif [[ ${ETYPE} == headers ]]; then 298elif [[ ${ETYPE} == headers ]]; then
267 DESCRIPTION="Linux system headers" 299 DESCRIPTION="Linux system headers"
268 IUSE="" 300
301 # Since we should NOT honour KBUILD_OUTPUT in headers
302 # lets unset it here.
303 unset KBUILD_OUTPUT
269 304
270 if [[ ${CTARGET} = ${CHOST} ]]; then 305 if [[ ${CTARGET} = ${CHOST} ]]; then
271 DEPEND="!virtual/os-headers" 306 DEPEND="!virtual/os-headers"
272 PROVIDE="virtual/os-headers" 307 PROVIDE="virtual/os-headers"
273 SLOT="0" 308 SLOT="0"
282# Cross-compile support functions 317# Cross-compile support functions
283#============================================================== 318#==============================================================
284kernel_header_destdir() { 319kernel_header_destdir() {
285 [[ ${CTARGET} == ${CHOST} ]] \ 320 [[ ${CTARGET} == ${CHOST} ]] \
286 && echo /usr/include \ 321 && echo /usr/include \
287 || echo /usr/${CTARGET}/include 322 || echo /usr/${CTARGET}/usr/include
288} 323}
289 324
290cross_pre_c_headers() { 325cross_pre_c_headers() {
291 [[ -z ${_E_CROSS_HEADERS_ONLY} ]] && return 1 326 use crosscompile_opts_headers-only && [[ ${CHOST} != ${CTARGET} ]]
292 [[ ${CHOST} == ${CTARGET} ]] && return 1
293 return 0
294} 327}
295 328
296env_setup_xmakeopts() { 329env_setup_xmakeopts() {
297 # Kernel ARCH != portage ARCH 330 # Kernel ARCH != portage ARCH
298 export KARCH=$(tc-arch-kernel) 331 export KARCH=$(tc-arch-kernel)
309} 342}
310 343
311# Unpack functions 344# Unpack functions
312#============================================================== 345#==============================================================
313unpack_2_4() { 346unpack_2_4() {
314 env_setup_xmakeopts
315
316 cd "${S}"
317 # this file is required for other things to build properly, 347 # this file is required for other things to build properly,
318 # so we autogenerate it 348 # so we autogenerate it
319 make -s mrproper ${xmakeopts} || die "make mrproper failed" 349 make -s mrproper ${xmakeopts} || die "make mrproper failed"
320 make -s symlinks ${xmakeopts} || die "make symlinks failed" 350 make -s symlinks ${xmakeopts} || die "make symlinks failed"
321 make -s include/linux/version.h ${xmakeopts} || die "make include/linux/version.h failed" 351 make -s include/linux/version.h ${xmakeopts} || die "make include/linux/version.h failed"
322 echo ">>> version.h compiled successfully." 352 echo ">>> version.h compiled successfully."
323} 353}
324 354
325unpack_2_6() { 355unpack_2_6() {
326 env_setup_xmakeopts
327
328 cd "${S}"
329 # this file is required for other things to build properly, so we 356 # this file is required for other things to build properly, so we
330 # autogenerate it ... touch .config to keep version.h build from 357 # autogenerate it ... generate a .config to keep version.h build from
331 # spitting out an annoying warning 358 # spitting out an annoying warning
332 make -s mrproper ${xmakeopts} || die "make mrproper failed" 359 make -s mrproper ${xmakeopts} 2>/dev/null \
360 || die "make mrproper failed"
361
362 # quick fix for bug #132152 which triggers when it cannot include linux
363 # headers (ie, we have not installed it yet)
364 if ! make -s defconfig ${xmakeopts} &>/dev/null 2>&1 ; then
333 touch .config 365 touch .config
334 make -s include/linux/version.h ${xmakeopts} || die "make include/linux/version.h failed" 366 eerror "make defconfig failed."
335 rm -f .config 367 eerror "assuming you dont have any headers installed yet and continuing"
368 epause 5
369 fi
370
371 make -s include/linux/version.h ${xmakeopts} 2>/dev/null \
372 || die "make include/linux/version.h failed"
373 rm -f .config >/dev/null
336} 374}
337 375
338universal_unpack() { 376universal_unpack() {
339 cd ${WORKDIR} 377 cd ${WORKDIR}
340 unpack linux-${OKV}.tar.bz2 378 unpack linux-${OKV}.tar.bz2
379 if [[ -d "linux" ]]; then
380 mv linux linux-${KV_FULL} \
381 || die "Unable to move source tree to ${KV_FULL}."
341 if [[ "${OKV}" != "${KV_FULL}" ]]; then 382 elif [[ "${OKV}" != "${KV_FULL}" ]]; then
342 mv linux-${OKV} linux-${KV_FULL} \ 383 mv linux-${OKV} linux-${KV_FULL} \
343 || die "Unable to move source tree to ${KV_FULL}." 384 || die "Unable to move source tree to ${KV_FULL}."
344 fi 385 fi
345 cd "${S}" 386 cd "${S}"
346 387
347 # remove all backup files 388 # remove all backup files
348 find . -iname "*~" -exec rm {} \; 2> /dev/null 389 find . -iname "*~" -exec rm {} \; 2> /dev/null
349 390
350 # fix a problem on ppc where TOUT writes to /usr/src/linux breaking sandbox 391 # fix a problem on ppc where TOUT writes to /usr/src/linux breaking sandbox
351 use ppc && \ 392 sed -i \
352 sed -ie 's|TOUT := .tmp_gas_check|TOUT := $(T).tmp_gas_check|' \ 393 -e 's|TOUT := .tmp_gas_check|TOUT := $(T).tmp_gas_check|' \
353 "${S}"/arch/ppc/Makefile 394 "${S}"/arch/ppc/Makefile
354} 395}
355 396
356unpack_set_extraversion() { 397unpack_set_extraversion() {
357 cd "${S}" 398 cd "${S}"
358 sed -i -e "s:^\(EXTRAVERSION =\).*:\1 ${EXTRAVERSION}:" Makefile 399 sed -i -e "s:^\(EXTRAVERSION =\).*:\1 ${EXTRAVERSION}:" Makefile
359 cd ${OLDPWD} 400 cd "${OLDPWD}"
360} 401}
361 402
362# Should be done after patches have been applied 403# Should be done after patches have been applied
363# Otherwise patches that modify the same area of Makefile will fail 404# Otherwise patches that modify the same area of Makefile will fail
364unpack_fix_install_path() { 405unpack_fix_install_path() {
365 cd "${S}" 406 cd "${S}"
366 sed -i -e 's:#export\tINSTALL_PATH:export\tINSTALL_PATH:' Makefile 407 sed -i -e 's:#export\tINSTALL_PATH:export\tINSTALL_PATH:' Makefile
367} 408}
368 409
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 410# Compile Functions
378#============================================================== 411#==============================================================
379compile_headers() { 412compile_headers() {
380 env_setup_xmakeopts 413 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 414
386 # if we couldnt obtain HOSTCFLAGS from the Makefile, 415 # if we couldnt obtain HOSTCFLAGS from the Makefile,
387 # then set it to something sane 416 # then set it to something sane
388 local HOSTCFLAGS=$(getfilevar HOSTCFLAGS "${S}"/Makefile) 417 local HOSTCFLAGS=$(getfilevar HOSTCFLAGS "${S}"/Makefile)
389 HOSTCFLAGS=${HOSTCFLAGS:--Wall -Wstrict-prototypes -O2 -fomit-frame-pointer} 418 HOSTCFLAGS=${HOSTCFLAGS:--Wall -Wstrict-prototypes -O2 -fomit-frame-pointer}
391 if kernel_is 2 4; then 420 if kernel_is 2 4; then
392 yes "" | make oldconfig ${xmakeopts} 421 yes "" | make oldconfig ${xmakeopts}
393 echo ">>> make oldconfig complete" 422 echo ">>> make oldconfig complete"
394 make dep ${xmakeopts} 423 make dep ${xmakeopts}
395 elif kernel_is 2 6; then 424 elif kernel_is 2 6; then
425 # 2.6.18 introduces headers_install which means we dont need any
426 # of this crap anymore :D
427 kernel_is ge 2 6 18 && return 0
428
396 # autoconf.h isnt generated unless it already exists. plus, we have 429 # autoconf.h isnt generated unless it already exists. plus, we have
397 # no guarantee that any headers are installed on the system... 430 # no guarantee that any headers are installed on the system...
398 [[ -f ${ROOT}/usr/include/linux/autoconf.h ]] \ 431 [[ -f ${ROOT}/usr/include/linux/autoconf.h ]] \
399 || touch include/linux/autoconf.h 432 || touch include/linux/autoconf.h
400 433
401 # if K_DEFCONFIG isn't set, force to "defconfig" 434 # if K_DEFCONFIG isn't set, force to "defconfig"
402 # needed by mips 435 # needed by mips
403 if [[ -z ${K_DEFCONFIG} ]]; then 436 if [[ -z ${K_DEFCONFIG} ]]; then
437 if [[ $(KV_to_int ${KV}) -ge $(KV_to_int 2.6.16) ]]; then
438 case ${CTARGET} in
439 powerpc64*) K_DEFCONFIG="ppc64_defconfig";;
440 powerpc*) K_DEFCONFIG="pmac32_defconfig";;
441 *) K_DEFCONFIG="defconfig";;
442 esac
443 else
404 K_DEFCONFIG="defconfig" 444 K_DEFCONFIG="defconfig"
445 fi
405 fi 446 fi
406 447
407 # if there arent any installed headers, then there also isnt an asm 448 # 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 449 # symlink in /usr/include/, and make defconfig will fail, so we have
409 # to force an include path with $S. 450 # to force an include path with $S.
410 HOSTCFLAGS="${HOSTCFLAGS} -I${S}/include/" 451 HOSTCFLAGS="${HOSTCFLAGS} -I${S}/include/"
411 ln -sf asm-${KARCH} "${S}"/include/asm 452 ln -sf asm-${KARCH} "${S}"/include/asm
412 cross_pre_c_headers && return 0 453 cross_pre_c_headers && return 0
413 454
414 make ${K_DEFCONFIG} HOSTCFLAGS="${HOSTCFLAGS}" ${xmakeopts} || die "defconfig failed" 455 make ${K_DEFCONFIG} HOSTCFLAGS="${HOSTCFLAGS}" ${xmakeopts} || die "defconfig failed (${K_DEFCONFIG})"
456 if compile_headers_tweak_config ; then
457 yes "" | make oldconfig HOSTCFLAGS="${HOSTCFLAGS}" ${xmakeopts} || die "2nd oldconfig failed"
458 fi
415 make prepare HOSTCFLAGS="${HOSTCFLAGS}" ${xmakeopts} || die "prepare failed" 459 make prepare HOSTCFLAGS="${HOSTCFLAGS}" ${xmakeopts} || die "prepare failed"
416 make prepare-all HOSTCFLAGS="${HOSTCFLAGS}" ${xmakeopts} || die "prepare failed" 460 make prepare-all HOSTCFLAGS="${HOSTCFLAGS}" ${xmakeopts} || die "prepare failed"
417 fi 461 fi
418} 462}
419 463
420compile_manpages() { 464compile_headers_tweak_config() {
421 einfo "Making manpages ..." 465 # some targets can be very very picky, so let's finesse the
422 env -u ARCH make mandocs 466 # .config based upon any info we may have
467 case ${CTARGET} in
468 sh*)
469 sed -i '/CONFIG_CPU_SH/d' .config
470 echo "CONFIG_CPU_SH${CTARGET:2:1}=y" >> .config
471 return 0;;
472 esac
473
474 # no changes, so lets do nothing
475 return 1
423} 476}
424 477
425# install functions 478# install functions
426#============================================================== 479#==============================================================
427install_universal() { 480install_universal() {
428 #fix silly permissions in tarball 481 #fix silly permissions in tarball
429 cd ${WORKDIR} 482 cd ${WORKDIR}
430 chown -R root:root * 483 chown -R root:0 *
431 chmod -R a+r-w+X,u+w * 484 chmod -R a+r-w+X,u+w *
432 cd ${OLDPWD} 485 cd ${OLDPWD}
433} 486}
434 487
435install_headers() { 488install_headers() {
436 local ddir=$(kernel_header_destdir) 489 local ddir=$(kernel_header_destdir)
437 490
491 # 2.6.18 introduces headers_install which means we dont need any
492 # of this crap anymore :D
493 if kernel_is ge 2 6 18 ; then
494 env_setup_xmakeopts
495 emake headers_install INSTALL_HDR_PATH="${D}"/${ddir}/.. ${xmakeopts} || die
496
497 # let other packages install some of these headers
498 rm -rf "${D}"/${ddir}/sound #alsa-headers
499 rm -rf "${D}"/${ddir}/scsi #glibc/uclibc/etc...
500 return 0
501 fi
502
438 cd "${S}" 503 cd "${S}"
439 dodir ${ddir}/linux 504 dodir ${ddir}/linux
440 cp -ax "${S}"/include/linux/* ${D}/${ddir}/linux 505 cp -pPR "${S}"/include/linux/* ${D}/${ddir}/linux
441 rm -rf ${D}/${ddir}/linux/modules 506 rm -rf ${D}/${ddir}/linux/modules
442 507
443 # Handle multilib headers and crap 508 # Handle multilib headers and crap
444 local multi_dirs="" multi_defs="" 509 local multi_dirs="" multi_defs=""
445 case $(tc-arch-kernel) in 510 case $(tc-arch-kernel) in
459 multi_dirs="s390 s390x" 524 multi_dirs="s390 s390x"
460 multi_defs="!__s390x__ __s390x__" 525 multi_defs="!__s390x__ __s390x__"
461 ;; 526 ;;
462 arm) 527 arm)
463 dodir ${ddir}/asm 528 dodir ${ddir}/asm
464 cp -ax "${S}"/include/asm/* "${D}"/${ddir}/asm 529 cp -pPR "${S}"/include/asm/* "${D}"/${ddir}/asm
465 [[ ! -e ${D}/${ddir}/asm/arch ]] && ln -sf arch-ebsa285 "${D}"/${ddir}/asm/arch 530 [[ ! -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 531 [[ ! -e ${D}/${ddir}/asm/proc ]] && ln -sf proc-armv "${D}"/${ddir}/asm/proc
467 ;; 532 ;;
468 powerpc) 533 powerpc)
469 dodir ${ddir}/asm 534 dodir ${ddir}/asm
470 cp -ax "${S}"/include/asm/* ${D}/${ddir}/asm 535 cp -pPR "${S}"/include/asm/* ${D}/${ddir}/asm
471 if [[ -e "${S}"/include/asm-ppc ]] ; then 536 if [[ -e "${S}"/include/asm-ppc ]] ; then
472 dodir ${ddir}/asm-ppc 537 dodir ${ddir}/asm-ppc
473 cp -ax "${S}"/include/asm-ppc/* ${D}/${ddir}/asm-ppc 538 cp -pPR "${S}"/include/asm-ppc/* ${D}/${ddir}/asm-ppc
474 fi 539 fi
475 ;; 540 ;;
476 *) 541 *)
477 dodir ${ddir}/asm 542 dodir ${ddir}/asm
478 cp -ax "${S}"/include/asm/* ${D}/${ddir}/asm 543 cp -pPR "${S}"/include/asm/* ${D}/${ddir}/asm
479 ;; 544 ;;
480 esac 545 esac
481 if [[ -n ${multi_dirs} ]] ; then 546 if [[ -n ${multi_dirs} ]] ; then
482 local d ml_inc="" 547 local d ml_inc=""
483 for d in ${multi_dirs} ; do 548 for d in ${multi_dirs} ; do
484 dodir ${ddir}/asm-${d} 549 dodir ${ddir}/asm-${d}
485 cp -ax "${S}"/include/asm-${d}/* ${D}/${ddir}/asm-${d}/ || die "cp asm-${d} failed" 550 cp -pPR "${S}"/include/asm-${d}/* ${D}/${ddir}/asm-${d}/ || die "cp asm-${d} failed"
486 551
487 ml_inc="${ml_inc} ${multi_defs%% *}:${ddir}/asm-${d}" 552 ml_inc="${ml_inc} ${multi_defs%% *}:${ddir}/asm-${d}"
488 multi_defs=${multi_defs#* } 553 multi_defs=${multi_defs#* }
489 done 554 done
490 create_ml_includes ${ddir}/asm ${ml_inc} 555 create_ml_includes ${ddir}/asm ${ml_inc}
491 fi 556 fi
492 557
493 if kernel_is 2 6; then 558 if kernel_is 2 6; then
494 dodir ${ddir}/asm-generic 559 dodir ${ddir}/asm-generic
495 cp -ax "${S}"/include/asm-generic/* ${D}/${ddir}/asm-generic 560 cp -pPR "${S}"/include/asm-generic/* ${D}/${ddir}/asm-generic
496 fi 561 fi
497 562
498 # clean up 563 # clean up
499 find "${D}" -name '*.orig' -exec rm -f {} \; 564 find "${D}" -name '*.orig' -exec rm -f {} \;
500 565
501 cd ${OLDPWD} 566 cd ${OLDPWD}
502} 567}
503 568
504install_sources() { 569install_sources() {
505 local doc docs file 570 local file
506 571
507 cd "${S}" 572 cd "${S}"
508 dodir /usr/src 573 dodir /usr/src
509 echo ">>> Copying sources ..." 574 echo ">>> Copying sources ..."
510 575
524 [[ -f ${FILESDIR}/../ChangeLog ]] && \ 589 [[ -f ${FILESDIR}/../ChangeLog ]] && \
525 echo "Please check the ebuild ChangeLog for more details." \ 590 echo "Please check the ebuild ChangeLog for more details." \
526 > "${S}"/patches.txt 591 > "${S}"/patches.txt
527 fi 592 fi
528 593
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 594 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} 595}
552 596
553# pkg_preinst functions 597# pkg_preinst functions
554#============================================================== 598#==============================================================
555preinst_headers() { 599preinst_headers() {
565 609
566 # if we have USE=symlink, then force K_SYMLINK=1 610 # if we have USE=symlink, then force K_SYMLINK=1
567 use symlink && K_SYMLINK=1 611 use symlink && K_SYMLINK=1
568 612
569 # if we are to forcably symlink, delete it if it already exists first. 613 # if we are to forcably symlink, delete it if it already exists first.
570 if [[ -n ${K_SYMLINK} ]]; then 614 if [[ ${K_SYMLINK} > 0 ]]; then
571 [[ -h ${ROOT}usr/src/linux ]] && rm ${ROOT}usr/src/linux 615 [[ -h ${ROOT}usr/src/linux ]] && rm ${ROOT}usr/src/linux
572 MAKELINK=1 616 MAKELINK=1
573 fi 617 fi
574 618
575 # if the link doesnt exist, lets create it 619 # if the link doesnt exist, lets create it
937 return 0 981 return 0
938} 982}
939 983
940headers___fix() { 984headers___fix() {
941 # Voodoo to partially fix broken upstream headers. 985 # Voodoo to partially fix broken upstream headers.
942 # Issues with this function should go to plasmaroo. 986 # Issues with this function should go to toolchain.
943 sed -i \ 987 sed -i \
944 -e "s/\([ "$'\t'"]\)\(u\|s\)\(8\|16\|32\|64\)\([ "$'\t'"]\)/\1__\2\3\4/g;" \ 988 -e '/^\#define.*_TYPES_H/{:loop n; bloop}' \
945 -e 's/ \(u\|s\)\(8\|16\|32\|64\)$/ __\1\2/g' \ 989 -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" \ 990 -e "s/ inline / __inline__ /g" \
949 "$@" 991 "$@"
950} 992}
951 993
952# common functions 994# common functions
953#============================================================== 995#==============================================================
954kernel-2_src_unpack() { 996kernel-2_src_unpack() {
955 universal_unpack 997 universal_unpack
998 debug-print "Doing unipatch"
956 999
957 [[ -n ${UNIPATCH_LIST} || -n ${UNIPATCH_LIST_DEFAULT} || -n ${UNIPATCH_LIST_GENPATCHES} ]] && \ 1000 [[ -n ${UNIPATCH_LIST} || -n ${UNIPATCH_LIST_DEFAULT} || -n ${UNIPATCH_LIST_GENPATCHES} ]] && \
958 unipatch "${UNIPATCH_LIST_DEFAULT} ${UNIPATCH_LIST_GENPATCHES} ${UNIPATCH_LIST}" 1001 unipatch "${UNIPATCH_LIST_DEFAULT} ${UNIPATCH_LIST_GENPATCHES} ${UNIPATCH_LIST}"
1002
1003 debug-print "Doing premake"
959 1004
960 # allow ebuilds to massage the source tree after patching but before 1005 # allow ebuilds to massage the source tree after patching but before
961 # we run misc `make` functions below 1006 # we run misc `make` functions below
962 [[ $(type -t kernel-2_hook_premake) == "function" ]] && kernel-2_hook_premake 1007 [[ $(type -t kernel-2_hook_premake) == "function" ]] && kernel-2_hook_premake
963 1008
1009 debug-print "Doing unpack_set_extraversion"
1010
964 [[ -z ${K_NOSETEXTRAVERSION} ]] && unpack_set_extraversion 1011 [[ -z ${K_NOSETEXTRAVERSION} ]] && unpack_set_extraversion
965 unpack_fix_docbook
966 unpack_fix_install_path 1012 unpack_fix_install_path
967 1013
1014 # Setup xmakeopts and cd into sourcetree.
1015 env_setup_xmakeopts
1016 cd "${S}"
1017
1018 # We dont need a version.h for anything other than headers
1019 # at least, I should hope we dont. If this causes problems
1020 # take out the if/fi block and inform me please.
1021 # unpack_2_6 should now be 2.6.17 safe anyways
1022 if [[ ${ETYPE} == headers ]]; then
968 kernel_is 2 4 && unpack_2_4 1023 kernel_is 2 4 && unpack_2_4
969 kernel_is 2 6 && unpack_2_6 1024 kernel_is 2 6 && unpack_2_6
1025 fi
970} 1026}
971 1027
972kernel-2_src_compile() { 1028kernel-2_src_compile() {
973 cd "${S}" 1029 cd "${S}"
974 [[ ${ETYPE} == headers ]] && compile_headers 1030 [[ ${ETYPE} == headers ]] && compile_headers
975 [[ ${ETYPE} == sources ]] && \
976 use doc && compile_manpages
977} 1031}
978 1032
979kernel-2_pkg_preinst() { 1033kernel-2_pkg_preinst() {
980 [[ ${ETYPE} == headers ]] && preinst_headers 1034 [[ ${ETYPE} == headers ]] && preinst_headers
981} 1035}
990 [[ ${ETYPE} == headers ]] && postinst_headers 1044 [[ ${ETYPE} == headers ]] && postinst_headers
991 [[ ${ETYPE} == sources ]] && postinst_sources 1045 [[ ${ETYPE} == sources ]] && postinst_sources
992} 1046}
993 1047
994kernel-2_pkg_setup() { 1048kernel-2_pkg_setup() {
1049 if kernel_is 2 4; then
1050 if [ "$( gcc-major-version )" -eq "4" ] ; then
1051 echo
1052 ewarn "Be warned !! >=sys-devel/gcc-4.0.0 isn't supported with linux-2.4!"
1053 ewarn "Either switch to another gcc-version (via gcc-config) or use a"
1054 ewarn "newer kernel that supports gcc-4."
1055 echo
1056 ewarn "Also be aware that bugreports about gcc-4 not working"
1057 ewarn "with linux-2.4 based ebuilds will be closed as INVALID!"
1058 echo
1059 epause 10
1060 fi
1061 fi
1062
1063 ABI="${KERNEL_ABI}"
995 [[ ${ETYPE} == headers ]] && setup_headers 1064 [[ ${ETYPE} == headers ]] && setup_headers
996 [[ ${ETYPE} == sources ]] && echo ">>> Preparing to unpack ..." 1065 [[ ${ETYPE} == sources ]] && echo ">>> Preparing to unpack ..."
997} 1066}

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

  ViewVC Help
Powered by ViewVC 1.1.20