/[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.74 Revision 1.75
1# Copyright 1999-2004 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.74 2005/01/11 21:20:59 johnm Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/kernel-2.eclass,v 1.75 2005/01/12 01:58:27 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>
9# Copyright 2004 Gentoo Linux
10# 9#
11# Please direct your bugs to the current eclass maintainer :) 10# Please direct your bugs to the current eclass maintainer :)
12 11
13# added functionality: 12# added functionality:
14# unipatch - a flexible, singular method to extract, add and remove patches. 13# unipatch - a flexible, singular method to extract, add and remove patches.
41# UNIPATCH_DOCS - space delimemeted list of docs to be installed to 40# UNIPATCH_DOCS - space delimemeted list of docs to be installed to
42# the doc dir 41# the doc dir
43# UNIPATCH_STRICTORDER - if this is set places patches into directories of 42# UNIPATCH_STRICTORDER - if this is set places patches into directories of
44# order, so they are applied in the order passed 43# order, so they are applied in the order passed
45 44
45inherit toolchain-funcs
46
46ECLASS="kernel-2" 47ECLASS="kernel-2"
47INHERITED="$INHERITED $ECLASS" 48INHERITED="$INHERITED $ECLASS"
48EXPORT_FUNCTIONS pkg_setup src_unpack src_compile src_install pkg_preinst pkg_postinst 49EXPORT_FUNCTIONS pkg_setup src_unpack src_compile src_install pkg_preinst pkg_postinst
49 50
50export CTARGET="${CTARGET:-${CHOST}}" 51export CTARGET=${CTARGET:-${CHOST}}
52if [[ ${CTARGET} == ${CHOST} ]] ; then
53 if [[ ${CATEGORY/cross-} != ${CATEGORY} ]] ; then
54 export CTARGET=${CATEGORY/cross-}
55 fi
56fi
51 57
52HOMEPAGE="http://www.kernel.org/ http://www.gentoo.org/" 58HOMEPAGE="http://www.kernel.org/ http://www.gentoo.org/"
53LICENSE="GPL-2" 59LICENSE="GPL-2"
54 60
55# set LINUX_HOSTCFLAGS if not already set 61# set LINUX_HOSTCFLAGS if not already set
130 [ ${KV_MAJOR} -eq 2 -a ${KV_MINOR} -eq 5 -o ${KV_MINOR} -eq 6 ] && \ 136 [ ${KV_MAJOR} -eq 2 -a ${KV_MINOR} -eq 5 -o ${KV_MINOR} -eq 6 ] && \
131 return 0 || return 1 137 return 0 || return 1
132} 138}
133 139
134kernel_header_destdir() { 140kernel_header_destdir() {
135 [ "${CTARGET}" = "${CHOST}" ] \ 141 [[ ${CTARGET} == ${CHOST} ]] \
136 && echo /usr/include \ 142 && echo /usr/include \
137 || echo /usr/${CTARGET}/include 143 || echo /usr/${CTARGET}/include
138} 144}
139 145
140# Capture the sources type and set DEPENDs 146# Capture the sources type and set DEPENDs
223} 229}
224 230
225# Compile Functions 231# Compile Functions
226#============================================================== 232#==============================================================
227compile_headers() { 233compile_headers() {
228 local extra_makeopts= 234 # if we couldnt obtain HOSTCFLAGS from the Makefile,
235 # then set it to something sane
229 local HOSTCFLAGS=$(getfilevar HOSTCFLAGS ${S}/Makefile) 236 local HOSTCFLAGS=$(getfilevar HOSTCFLAGS ${S}/Makefile)
230 237 HOSTCFLAGS=${HOSTCFLAGS:--Wall -Wstrict-prototypes -O2 -fomit-frame-pointer}
231 set_arch_to_kernel; 238
232 239 # Kernel ARCH != portage ARCH
240 local KARCH=$(tc-arch-kernel ${CTARGET})
241
242 # When cross-compiling, we need to set the ARCH/CROSS_COMPILE
243 # variables properly or bad things happen !
244 local xmakeopts="ARCH=${KARCH}"
245 if [[ ${CTARGET} != ${CHOST} ]] ; then
246 xmakeopts="${xmakeopts} CROSS_COMPILE=${CTARGET}-"
247 elif type -p ${CHOST}-ar ; then
248 xmakeopts="${xmakeopts} CROSS_COMPILE=${CHOST}-"
249 fi
250
233 if kernel_is 2 4 251 if kernel_is 2 4
234 then 252 then
235 yes "" | make oldconfig 253 yes "" | make oldconfig ${xmakeopts}
236 echo ">>> make oldconfig complete" 254 echo ">>> make oldconfig complete"
237 use sparc && make dep 255 use sparc && make dep ${xmakeopts}
256
238 elif kernel_is 2 6 257 elif kernel_is 2 6
239 then 258 then
240 # autoconf.h isnt generated unless it already exists. plus, we have 259 # autoconf.h isnt generated unless it already exists. plus, we have
241 # no guarantee that any headers are installed on the system... 260 # no guarantee that any headers are installed on the system...
242 [ -f "${ROOT}"/usr/include/linux/autoconf.h ] \ 261 [[ -f ${ROOT}/usr/include/linux/autoconf.h ]] \
243 || touch include/linux/autoconf.h 262 || touch include/linux/autoconf.h
244 263
245 # When cross-compiling, we need to set the CROSS_COMPILE var properly
246 if [[ ${CTARGET} != ${CHOST} ]] ; then
247 extra_makeopts="CROSS_COMPILE=${CTARGET}-"
248 elif type -p ${CHOST}-ar ; then
249 extra_makeopts="CROSS_COMPILE=${CHOST}-"
250 fi
251
252 # if we couldnt obtain HOSTCFLAGS from the Makefile,
253 #then set it to something sane
254 [ -z "${HOSTCFLAGS}" ] && \
255 HOSTCFLAGS="-Wall -Wstrict-prototypes -O2 -fomit-frame-pointer -I${S}/include/"
256
257 # if there arent any installed headers, then there also isnt an asm 264 # if there arent any installed headers, then there also isnt an asm
258 # symlink in /usr/include/, and make defconfig will fail, so we have 265 # symlink in /usr/include/, and make defconfig will fail, so we have
259 # to force an include path with $S. 266 # to force an include path with $S.
260 ln -sf ${S}/include/asm-${ARCH} ${S}/include/asm 267 HOSTCFLAGS="${HOSTCFLAGS} -I${S}/include/"
268 ln -sf asm-${KARCH} "${S}"/include/asm
261 make defconfig HOSTCFLAGS="${HOSTCFLAGS}" ${extra_makeopts} || die "defconfig failed" 269 make defconfig HOSTCFLAGS="${HOSTCFLAGS}" ${xmakeopts} || die "defconfig failed"
262 make prepare HOSTCFLAGS="${HOSTCFLAGS}" ${extra_makeopts} || die "prepare failed" 270 make prepare HOSTCFLAGS="${HOSTCFLAGS}" ${xmakeopts} || die "prepare failed"
263 fi 271 fi
264
265 set_arch_to_portage;
266} 272}
267 273
268compile_manpages() { 274compile_manpages() {
269 local MY_ARCH
270
271 einfo "Making manpages ..." 275 einfo "Making manpages ..."
272 MY_ARCH=${ARCH} 276 env -u ARCH make mandocs
273 unset ARCH
274 make mandocs
275 ARCH=${MY_ARCH}
276} 277}
277 278
278# install functions 279# install functions
279#============================================================== 280#==============================================================
280install_universal() { 281install_universal() {
306 307
307 if kernel_is 2 6 308 if kernel_is 2 6
308 then 309 then
309 dodir ${ddir}/asm-generic 310 dodir ${ddir}/asm-generic
310 cp -ax ${S}/include/asm-generic/* ${D}/${ddir}/asm-generic 311 cp -ax ${S}/include/asm-generic/* ${D}/${ddir}/asm-generic
311
312
313 fi 312 fi
314} 313}
315 314
316install_sources() { 315install_sources() {
317 local doc 316 local doc
639 rm -Rf ${x} 638 rm -Rf ${x}
640 done 639 done
641 unset LC_ALL 640 unset LC_ALL
642} 641}
643 642
644# custom functions
645#==============================================================
646# Pulled from eutils as it might be more useful only being here since
647# very few ebuilds which dont use this eclass will ever ever use these functions
648set_arch_to_kernel() {
649 export PORTAGE_ARCH="${ARCH}"
650 case ${ARCH} in
651 x86) export ARCH="i386";;
652 amd64) export ARCH="x86_64";;
653 hppa) export ARCH="parisc";;
654 mips) export ARCH="mips";;
655 *) export ARCH="${ARCH}";;
656 esac
657}
658
659# set's ARCH back to what portage expects
660set_arch_to_portage() {
661 export ARCH="${PORTAGE_ARCH}"
662}
663
664# getfilevar accepts 2 vars as follows: 643# getfilevar accepts 2 vars as follows:
665# getfilevar <VARIABLE> <CONFIGFILE> 644# getfilevar <VARIABLE> <CONFIGFILE>
666# pulled from linux-info 645# pulled from linux-info
667 646
668getfilevar() { 647getfilevar() {

Legend:
Removed from v.1.74  
changed lines
  Added in v.1.75

  ViewVC Help
Powered by ViewVC 1.1.20