/[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.148 Revision 1.159
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.148 2005/10/07 08:25:04 johnm Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/kernel-2.eclass,v 1.159 2006/02/17 22:18:20 swegener 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>
131 131
132 RELEASE=${CKV/${OKV}} 132 RELEASE=${CKV/${OKV}}
133 RELEASE=${RELEASE/_beta} 133 RELEASE=${RELEASE/_beta}
134 RELEASE=${RELEASE/_rc/-rc} 134 RELEASE=${RELEASE/_rc/-rc}
135 RELEASE=${RELEASE/_pre/-pre} 135 RELEASE=${RELEASE/_pre/-pre}
136 kernel_is ge 2 6 && RELEASE=${RELEASE/-pre/-bk} 136 kernel_is ge 2 6 && RELEASE=${RELEASE/-pre/-git}
137 RELEASETYPE=${RELEASE//[0-9]} 137 RELEASETYPE=${RELEASE//[0-9]}
138 138
139 # Now we know that RELEASE is the -rc/-bk 139 # Now we know that RELEASE is the -rc/-git
140 # and RELEASETYPE is the same but with its numerics stripped 140 # and RELEASETYPE is the same but with its numerics stripped
141 # we can work on better sorting EXTRAVERSION. 141 # we can work on better sorting EXTRAVERSION.
142 # first of all, we add the release 142 # first of all, we add the release
143 EXTRAVERSION="${RELEASE}" 143 EXTRAVERSION="${RELEASE}"
144 [[ -n ${KV_EXTRA} ]] && EXTRAVERSION=".${KV_EXTRA}${EXTRAVERSION}" 144 [[ -n ${KV_EXTRA} ]] && EXTRAVERSION=".${KV_EXTRA}${EXTRAVERSION}"
175 175
176 # we will set this for backwards compatibility. 176 # we will set this for backwards compatibility.
177 S=${WORKDIR}/linux-${KV_FULL} 177 S=${WORKDIR}/linux-${KV_FULL}
178 KV=${KV_FULL} 178 KV=${KV_FULL}
179 179
180 # -rc-bk pulls can be achieved by specifying CKV 180 # -rc-git pulls can be achieved by specifying CKV
181 # for example: 181 # for example:
182 # CKV="2.6.11_rc3_pre2" 182 # CKV="2.6.11_rc3_pre2"
183 # will pull: 183 # will pull:
184 # linux-2.6.10.tar.bz2 & patch-2.6.11-rc3.bz2 & patch-2.6.11-rc3-bk2.bz2 184 # linux-2.6.10.tar.bz2 & patch-2.6.11-rc3.bz2 & patch-2.6.11-rc3-git2.bz2
185 185
186 if [[ ${RELEASETYPE} == -rc ]] || [[ ${RELEASETYPE} == -pre ]]; then 186 if [[ ${RELEASETYPE} == -rc ]] || [[ ${RELEASETYPE} == -pre ]]; then
187 OKV="${KV_MAJOR}.${KV_MINOR}.$((${KV_PATCH} - 1))" 187 OKV="${KV_MAJOR}.${KV_MINOR}.$((${KV_PATCH} - 1))"
188 KERNEL_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/testing/patch-${CKV//_/-}.bz2 188 KERNEL_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/testing/patch-${CKV//_/-}.bz2
189 mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/linux-${OKV}.tar.bz2" 189 mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/linux-${OKV}.tar.bz2"
190 UNIPATCH_LIST_DEFAULT="${DISTDIR}/patch-${CKV//_/-}.bz2" 190 UNIPATCH_LIST_DEFAULT="${DISTDIR}/patch-${CKV//_/-}.bz2"
191 fi 191 fi
192 192
193 if [[ ${RELEASETYPE} == -bk ]]; then 193 if [[ ${RELEASETYPE} == -git ]]; then
194 KERNEL_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/snapshots/patch-${OKV}${RELEASE}.bz2 194 KERNEL_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/snapshots/patch-${OKV}${RELEASE}.bz2
195 mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/linux-${OKV}.tar.bz2" 195 mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/linux-${OKV}.tar.bz2"
196 UNIPATCH_LIST_DEFAULT="${DISTDIR}/patch-${OKV}${RELEASE}.bz2" 196 UNIPATCH_LIST_DEFAULT="${DISTDIR}/patch-${OKV}${RELEASE}.bz2"
197 fi 197 fi
198 198
199 if [[ ${RELEASETYPE} == -rc-bk ]]; then 199 if [[ ${RELEASETYPE} == -rc-git ]]; then
200 OKV="${KV_MAJOR}.${KV_MINOR}.$((${KV_PATCH} - 1))" 200 OKV="${KV_MAJOR}.${KV_MINOR}.$((${KV_PATCH} - 1))"
201 KERNEL_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/snapshots/patch-${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${RELEASE}.bz2 201 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/-bk*}.bz2 202 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" 203 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/-bk*}.bz2 ${DISTDIR}/patch-${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${RELEASE}.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"
205 fi 205 fi
206 206
207 handle_genpatches 207 handle_genpatches
208} 208}
209 209
245 245
246kernel_is_2_6() { 246kernel_is_2_6() {
247 kernel_is 2 6 || kernel_is 2 5 247 kernel_is 2 6 || kernel_is 2 5
248} 248}
249 249
250kernel_header_destdir() {
251 [[ ${CTARGET} == ${CHOST} ]] \
252 && echo /usr/include \
253 || echo /usr/${CTARGET}/include
254}
255
256# Capture the sources type and set DEPENDs 250# Capture the sources type and set DEPENDs
257if [[ ${ETYPE} == sources ]]; then 251if [[ ${ETYPE} == sources ]]; then
258 DEPEND="!build? ( sys-apps/sed 252 DEPEND="!build? ( sys-apps/sed
259 >=sys-devel/binutils-2.11.90.0.31 ) 253 >=sys-devel/binutils-2.11.90.0.31 )
260 doc? ( app-text/docbook-sgml-utils 254 doc? ( app-text/docbook-sgml-utils
283else 277else
284 eerror "Unknown ETYPE=\"${ETYPE}\", must be \"sources\" or \"headers\"" 278 eerror "Unknown ETYPE=\"${ETYPE}\", must be \"sources\" or \"headers\""
285 die "Unknown ETYPE=\"${ETYPE}\", must be \"sources\" or \"headers\"" 279 die "Unknown ETYPE=\"${ETYPE}\", must be \"sources\" or \"headers\""
286fi 280fi
287 281
288# Unpack functions 282# Cross-compile support functions
289#============================================================== 283#==============================================================
290unpack_2_4() { 284kernel_header_destdir() {
285 [[ ${CTARGET} == ${CHOST} ]] \
286 && echo /usr/include \
287 || echo /usr/${CTARGET}/include
288}
289
290cross_pre_c_headers() {
291 [[ -z ${_E_CROSS_HEADERS_ONLY} ]] && return 1
292 [[ ${CHOST} == ${CTARGET} ]] && return 1
293 return 0
294}
295
296env_setup_xmakeopts() {
291 # Kernel ARCH != portage ARCH 297 # Kernel ARCH != portage ARCH
292 local KARCH=$(tc-arch-kernel) 298 export KARCH=$(tc-arch-kernel)
293 299
294 # When cross-compiling, we need to set the ARCH/CROSS_COMPILE 300 # When cross-compiling, we need to set the ARCH/CROSS_COMPILE
295 # variables properly or bad things happen ! 301 # variables properly or bad things happen !
296 local xmakeopts="ARCH=${KARCH}" 302 xmakeopts="ARCH=${KARCH}"
297 if [[ ${CTARGET} != ${CHOST} ]]; then 303 if [[ ${CTARGET} != ${CHOST} ]] && ! cross_pre_c_headers ; then
298 xmakeopts="${xmakeopts} CROSS_COMPILE=${CTARGET}-" 304 xmakeopts="${xmakeopts} CROSS_COMPILE=${CTARGET}-"
299 elif type -p ${CHOST}-ar; then 305 elif type -p ${CHOST}-ar > /dev/null ; then
300 xmakeopts="${xmakeopts} CROSS_COMPILE=${CHOST}-" 306 xmakeopts="${xmakeopts} CROSS_COMPILE=${CHOST}-"
301 fi 307 fi
308 export xmakeopts
309}
310
311# Unpack functions
312#==============================================================
313unpack_2_4() {
314 env_setup_xmakeopts
302 315
303 cd "${S}" 316 cd "${S}"
304 # this file is required for other things to build properly, 317 # this file is required for other things to build properly,
305 # so we autogenerate it 318 # so we autogenerate it
306 make -s mrproper ${xmakeopts} || die "make mrproper failed" 319 make -s mrproper ${xmakeopts} || die "make mrproper failed"
307 make -s symlinks ${xmakeopts} || die "make symlinks failed" 320 make -s symlinks ${xmakeopts} || die "make symlinks failed"
308 make -s include/linux/version.h ${xmakeopts} || die "make include/linux/version.h failed" 321 make -s include/linux/version.h ${xmakeopts} || die "make include/linux/version.h failed"
309 echo ">>> version.h compiled successfully." 322 echo ">>> version.h compiled successfully."
310} 323}
311 324
325unpack_2_6() {
326 env_setup_xmakeopts
327
328 cd "${S}"
329 # this file is required for other things to build properly, so we
330 # autogenerate it ... touch .config to keep version.h build from
331 # spitting out an annoying warning
332 make -s mrproper ${xmakeopts} || die "make mrproper failed"
333 touch .config
334 make -s include/linux/version.h ${xmakeopts} || die "make include/linux/version.h failed"
335 rm -f .config
336}
337
312universal_unpack() { 338universal_unpack() {
313 cd ${WORKDIR} 339 cd ${WORKDIR}
314 unpack linux-${OKV}.tar.bz2 340 unpack linux-${OKV}.tar.bz2
315 if [[ "${OKV}" != "${KV_FULL}" ]]; then 341 if [[ "${OKV}" != "${KV_FULL}" ]]; then
316 mv linux-${OKV} linux-${KV_FULL} \ 342 mv linux-${OKV} linux-${KV_FULL} \
349} 375}
350 376
351# Compile Functions 377# Compile Functions
352#============================================================== 378#==============================================================
353compile_headers() { 379compile_headers() {
380 env_setup_xmakeopts
381
354 # Since KBUILD_OUTPUT shouldnt be used when compiling headers, lets unset it 382 # Since KBUILD_OUTPUT shouldnt be used when compiling headers, lets unset it
355 # if it exists. 383 # if it exists.
356 [[ -n ${KBUILD_OUTPUT} ]] && unset KBUILD_OUTPUT 384 [[ -n ${KBUILD_OUTPUT} ]] && unset KBUILD_OUTPUT
357 385
358 # if we couldnt obtain HOSTCFLAGS from the Makefile, 386 # if we couldnt obtain HOSTCFLAGS from the Makefile,
359 # then set it to something sane 387 # then set it to something sane
360 local HOSTCFLAGS=$(getfilevar HOSTCFLAGS "${S}"/Makefile) 388 local HOSTCFLAGS=$(getfilevar HOSTCFLAGS "${S}"/Makefile)
361 HOSTCFLAGS=${HOSTCFLAGS:--Wall -Wstrict-prototypes -O2 -fomit-frame-pointer} 389 HOSTCFLAGS=${HOSTCFLAGS:--Wall -Wstrict-prototypes -O2 -fomit-frame-pointer}
362 390
363 # Kernel ARCH != portage ARCH
364 local KARCH=$(tc-arch-kernel)
365
366 # When cross-compiling, we need to set the ARCH/CROSS_COMPILE
367 # variables properly or bad things happen !
368 local xmakeopts="ARCH=${KARCH}"
369 if [[ ${CTARGET} != ${CHOST} ]]; then
370 xmakeopts="${xmakeopts} CROSS_COMPILE=${CTARGET}-"
371 elif type -p ${CHOST}-ar; then
372 xmakeopts="${xmakeopts} CROSS_COMPILE=${CHOST}-"
373 fi
374
375 if kernel_is 2 4; then 391 if kernel_is 2 4; then
376 yes "" | make oldconfig ${xmakeopts} 392 yes "" | make oldconfig ${xmakeopts}
377 echo ">>> make oldconfig complete" 393 echo ">>> make oldconfig complete"
378 use sparc && make dep ${xmakeopts} 394 make dep ${xmakeopts}
379 elif kernel_is 2 6; then 395 elif kernel_is 2 6; then
380 # autoconf.h isnt generated unless it already exists. plus, we have 396 # autoconf.h isnt generated unless it already exists. plus, we have
381 # no guarantee that any headers are installed on the system... 397 # no guarantee that any headers are installed on the system...
382 [[ -f ${ROOT}/usr/include/linux/autoconf.h ]] \ 398 [[ -f ${ROOT}/usr/include/linux/autoconf.h ]] \
383 || touch include/linux/autoconf.h 399 || touch include/linux/autoconf.h
391 # if there arent any installed headers, then there also isnt an asm 407 # if there arent any installed headers, then there also isnt an asm
392 # symlink in /usr/include/, and make defconfig will fail, so we have 408 # symlink in /usr/include/, and make defconfig will fail, so we have
393 # to force an include path with $S. 409 # to force an include path with $S.
394 HOSTCFLAGS="${HOSTCFLAGS} -I${S}/include/" 410 HOSTCFLAGS="${HOSTCFLAGS} -I${S}/include/"
395 ln -sf asm-${KARCH} "${S}"/include/asm 411 ln -sf asm-${KARCH} "${S}"/include/asm
412 cross_pre_c_headers && return 0
413
396 make ${K_DEFCONFIG} HOSTCFLAGS="${HOSTCFLAGS}" ${xmakeopts} || die "defconfig failed" 414 make ${K_DEFCONFIG} HOSTCFLAGS="${HOSTCFLAGS}" ${xmakeopts} || die "defconfig failed"
397 make prepare HOSTCFLAGS="${HOSTCFLAGS}" ${xmakeopts} || die "prepare failed" 415 make prepare HOSTCFLAGS="${HOSTCFLAGS}" ${xmakeopts} || die "prepare failed"
398 make prepare-all HOSTCFLAGS="${HOSTCFLAGS}" ${xmakeopts} || die "prepare failed" 416 make prepare-all HOSTCFLAGS="${HOSTCFLAGS}" ${xmakeopts} || die "prepare failed"
399 fi 417 fi
400} 418}
445 dodir ${ddir}/asm 463 dodir ${ddir}/asm
446 cp -ax "${S}"/include/asm/* "${D}"/${ddir}/asm 464 cp -ax "${S}"/include/asm/* "${D}"/${ddir}/asm
447 [[ ! -e ${D}/${ddir}/asm/arch ]] && ln -sf arch-ebsa285 "${D}"/${ddir}/asm/arch 465 [[ ! -e ${D}/${ddir}/asm/arch ]] && ln -sf arch-ebsa285 "${D}"/${ddir}/asm/arch
448 [[ ! -e ${D}/${ddir}/asm/proc ]] && ln -sf proc-armv "${D}"/${ddir}/asm/proc 466 [[ ! -e ${D}/${ddir}/asm/proc ]] && ln -sf proc-armv "${D}"/${ddir}/asm/proc
449 ;; 467 ;;
468 powerpc)
469 dodir ${ddir}/asm
470 cp -ax "${S}"/include/asm/* ${D}/${ddir}/asm
471 if [[ -e "${S}"/include/asm-ppc ]] ; then
472 dodir ${ddir}/asm-ppc
473 cp -ax "${S}"/include/asm-ppc/* ${D}/${ddir}/asm-ppc
474 fi
475 ;;
450 *) 476 *)
451 dodir ${ddir}/asm 477 dodir ${ddir}/asm
452 cp -ax "${S}"/include/asm/* ${D}/${ddir}/asm 478 cp -ax "${S}"/include/asm/* ${D}/${ddir}/asm
453 ;; 479 ;;
454 esac 480 esac
511 mv ${WORKDIR}/linux* ${D}/usr/src 537 mv ${WORKDIR}/linux* ${D}/usr/src
512} 538}
513 539
514install_manpages() { 540install_manpages() {
515 kernel_is lt 2 5 && return 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
516 sed -ie "s#/usr/local/man#${D}/usr/share/man#g" \ 546 sed -ie "s#/usr/local/man#${D}/usr/share/man#g" ${myfiles}
517 scripts/makeman Documentation/DocBook/Makefile
518 ebegin "Installing manpages" 547 ebegin "Installing manpages"
519 env -u ARCH make installmandocs 548 env -u ARCH make installmandocs
520 eend $? 549 eend $?
521 sed -ie "s#${D}/usr/share/man#/usr/local/man#g" \ 550 sed -ie "s#${D}/usr/share/man#/usr/local/man#g" ${myfiles}
522 scripts/makeman Documentation/DocBook/Makefile
523} 551}
524 552
525# pkg_preinst functions 553# pkg_preinst functions
526#============================================================== 554#==============================================================
527preinst_headers() { 555preinst_headers() {
915 sed -i \ 943 sed -i \
916 -e "s/\([ "$'\t'"]\)\(u\|s\)\(8\|16\|32\|64\)\([ "$'\t'"]\)/\1__\2\3\4/g;" \ 944 -e "s/\([ "$'\t'"]\)\(u\|s\)\(8\|16\|32\|64\)\([ "$'\t'"]\)/\1__\2\3\4/g;" \
917 -e 's/ \(u\|s\)\(8\|16\|32\|64\)$/ __\1\2/g' \ 945 -e 's/ \(u\|s\)\(8\|16\|32\|64\)$/ __\1\2/g' \
918 -e 's/\([(, ]\)\(u\|s\)64\([, )]\)/\1__\264\3/g' \ 946 -e 's/\([(, ]\)\(u\|s\)64\([, )]\)/\1__\264\3/g' \
919 -e "s/^\(u\|s\)\(8\|16\|32\|64\)\([ "$'\t'"]\)/__\1\2\3/g;" \ 947 -e "s/^\(u\|s\)\(8\|16\|32\|64\)\([ "$'\t'"]\)/__\1\2\3/g;" \
948 -e "s/ inline / __inline__ /g" \
920 "$@" 949 "$@"
921} 950}
922 951
923# common functions 952# common functions
924#============================================================== 953#==============================================================
925kernel-2_src_unpack() { 954kernel-2_src_unpack() {
926 universal_unpack 955 universal_unpack
927 956
928 [[ -n ${UNIPATCH_LIST} || -n ${UNIPATCH_LIST_DEFAULT} || -n ${UNIPATCH_LIST_GENPATCHES} ]] && \ 957 [[ -n ${UNIPATCH_LIST} || -n ${UNIPATCH_LIST_DEFAULT} || -n ${UNIPATCH_LIST_GENPATCHES} ]] && \
929 unipatch "${UNIPATCH_LIST_DEFAULT} ${UNIPATCH_LIST_GENPATCHES} ${UNIPATCH_LIST}" 958 unipatch "${UNIPATCH_LIST_DEFAULT} ${UNIPATCH_LIST_GENPATCHES} ${UNIPATCH_LIST}"
959
960 # allow ebuilds to massage the source tree after patching but before
961 # we run misc `make` functions below
962 [[ $(type -t kernel-2_hook_premake) == "function" ]] && kernel-2_hook_premake
930 963
931 [[ -z ${K_NOSETEXTRAVERSION} ]] && unpack_set_extraversion 964 [[ -z ${K_NOSETEXTRAVERSION} ]] && unpack_set_extraversion
932 unpack_fix_docbook 965 unpack_fix_docbook
933 unpack_fix_install_path 966 unpack_fix_install_path
934 967
935 kernel_is 2 4 && unpack_2_4 968 kernel_is 2 4 && unpack_2_4
969 kernel_is 2 6 && unpack_2_6
936} 970}
937 971
938kernel-2_src_compile() { 972kernel-2_src_compile() {
939 cd "${S}" 973 cd "${S}"
940 [[ ${ETYPE} == headers ]] && compile_headers 974 [[ ${ETYPE} == headers ]] && compile_headers

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

  ViewVC Help
Powered by ViewVC 1.1.20