/[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.152 Revision 1.153
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.152 2005/11/11 02:33:50 vapier Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/kernel-2.eclass,v 1.153 2005/11/18 03:58:21 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>
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 > /dev/null ; 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
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 390
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 make dep ${xmakeopts} 394 make dep ${xmakeopts}
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}
933 [[ -z ${K_NOSETEXTRAVERSION} ]] && unpack_set_extraversion 951 [[ -z ${K_NOSETEXTRAVERSION} ]] && unpack_set_extraversion
934 unpack_fix_docbook 952 unpack_fix_docbook
935 unpack_fix_install_path 953 unpack_fix_install_path
936 954
937 kernel_is 2 4 && unpack_2_4 955 kernel_is 2 4 && unpack_2_4
956 kernel_is 2 6 && unpack_2_6
938} 957}
939 958
940kernel-2_src_compile() { 959kernel-2_src_compile() {
941 cd "${S}" 960 cd "${S}"
942 [[ ${ETYPE} == headers ]] && compile_headers 961 [[ ${ETYPE} == headers ]] && compile_headers

Legend:
Removed from v.1.152  
changed lines
  Added in v.1.153

  ViewVC Help
Powered by ViewVC 1.1.20