Skip to contentSkip to conversation

build kernel in output dir

PATCH In review C Michael Sundius 2 participants 5 messages Mar 9, 2010

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 build kernel in output dir

We build our kernel in an output directory so that the objects don't muck up our source directory. We do this since during development, most engineers just set up a link to their SCM Project directory containing the source rather than having bitbake copy all the files in to the ${S} directory.

I made some mods to the kernel.bbclass to allow us to build in the out directory and included it here in the attached patch (along w/ our own recipe for building the kernel). These mods *should* allow other kernel recipes to build unchanged.

I'd love to get comments on this, understanding that:
1) there might be a better way someone else is already using
2) that I've screwed stuff up
3) something else.

I'd also love to see this get pushed upstream if others find it useful..

thanks for you comments.

Mike

openembedded/classes/kernel.bbclass renamed from oe.org/openembedded/classes/kernel.bbclass +39 -19
@@ -55,12 +55,18 @@
 KERNEL_LD = "${LD}${KERNEL_LDSUFFIX} ${HOST_LD_KERNEL_ARCH}"
 
 # Where built kernel lies in the kernel tree
-KERNEL_OUTPUT ?= "arch/${ARCH}/boot/${KERNEL_IMAGETYPE}"
+KERNEL_OUTDIR ?= "${S}"
+KERNEL_OUTPUT ?= "${KERNEL_OUTDIR}/arch/${ARCH}/boot/${KERNEL_IMAGETYPE}"
 KERNEL_IMAGEDEST = "boot"
 
+#If we are using an output dir for kernel objs, then add the switch
+EXTRA_KERNELMAKE += "${@base_conditional('KERNEL_OUTDIR', "${S}", '', '-C ${S} O=${KERNEL_OUTDIR}', d)}"
+SCENEFUNCS += "${@base_conditional('KERNEL_OUTDIR', "${S}", '', 'kernel_setscene_func', d)}"
 #
 # configuration
 #
+KERNEL_CONFIGFILE = "${KERNEL_OUTDIR}/.config"
+
 export CMDLINE_CONSOLE = "console=${@bb.data.getVar("KERNEL_CONSOLE",d,1) or "ttyS0"}"
 
 KERNEL_VERSION = "${@get_kernelversion('${S}')}"
@@ -78,16 +84,25 @@
 # For the kernel, we don't want the '-e MAKEFLAGS=' in EXTRA_OEMAKE.
 # We don't want to override kernel Makefile variables from the environment
 EXTRA_OEMAKE = ""
+# I use EXTRA_KERNELMAKE to make sure its not confused with EXTRA_OEMAKE
+EXTRA_KERNELMAKE ?= ""
+
+# should only be called when using KERNEL_OUTDIR
+kernel_setscene_func() {
+	install -d ${KERNEL_OUTDIR}
+	rm -f ${S}/.config
+}
 
 kernel_do_compile() {
+	cd ${KERNEL_OUTDIR}
 	unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS MACHINE
-	oe_runmake include/linux/version.h CC="${KERNEL_CC}" LD="${KERNEL_LD}"
+	oe_runmake ${EXTRA_KERNELMAKE} include/linux/version.h CC="${KERNEL_CC}" LD="${KERNEL_LD}"
 	if [ "${KERNEL_MAJOR_VERSION}" != "2.6" ]; then
 		oe_runmake dep CC="${KERNEL_CC}" LD="${KERNEL_LD}"
 	fi
-	oe_runmake ${KERNEL_IMAGETYPE} CC="${KERNEL_CC}" LD="${KERNEL_LD}"
-	if (grep -q -i -e '^CONFIG_MODULES=y$' .config); then
-		oe_runmake modules  CC="${KERNEL_CC}" LD="${KERNEL_LD}"
+	oe_runmake ${EXTRA_KERNELMAKE} ${KERNEL_IMAGETYPE} CC="${KERNEL_CC}" LD="${KERNEL_LD}"
+	if (grep -q -i -e '^CONFIG_MODULES=y$' ${KERNEL_CONFIGFILE}); then
+		oe_runmake ${EXTRA_KERNELMAKE} modules  CC="${KERNEL_CC}" LD="${KERNEL_LD}"
 	else
 		oenote "no modules to compile"
 	fi
@@ -95,9 +110,9 @@
 kernel_do_compile[depends] = "${INITRAMFS_TASK}"
 
 kernel_do_stage() {
-	if [ -e include/asm ] ; then
+	if [ -e ${KERNEL_OUTDIR}/include/asm ] ; then
 		# This link is generated only in kernel before 2.6.33-rc1, don't stage it for newer kernels
-		ASMDIR=`readlink include/asm`
+		ASMDIR=`readlink ${KERNEL_OUTDIR}/include/asm`
 
 		mkdir -p ${STAGING_KERNEL_DIR}/include/$ASMDIR
 		cp -fR include/$ASMDIR/* ${STAGING_KERNEL_DIR}/include/$ASMDIR/
@@ -112,14 +127,14 @@
 
 	# Check for arch/x86 on i386
 	elif [ -d arch/x86/include/asm/ ]; then
-		if [ -e include/asm ] ; then
+		if [ -e ${KERNEL_OUTDIR}/include/asm ] ; then
 			cp -fR arch/x86/include/asm/* ${STAGING_KERNEL_DIR}/include/asm-x86/
 		fi
 		install -d ${STAGING_KERNEL_DIR}/arch/x86/include
 		cp -fR arch/x86/* ${STAGING_KERNEL_DIR}/arch/x86/
 	fi
 
-	if [ -e include/asm ] ; then
+	if [ -e ${KERNEL_OUTDIR}/include/asm ] ; then
 		rm -f ${STAGING_KERNEL_DIR}/include/asm
 		ln -sf $ASMDIR ${STAGING_KERNEL_DIR}/include/asm
 	fi
@@ -140,9 +155,9 @@
 		cp -fR drivers/sound/*.h ${STAGING_KERNEL_DIR}/include/drivers/sound/
 	fi
 
-	install -m 0644 .config ${STAGING_KERNEL_DIR}/config-${KERNEL_VERSION}
-	ln -sf config-${KERNEL_VERSION} ${STAGING_KERNEL_DIR}/.config
-	ln -sf config-${KERNEL_VERSION} ${STAGING_KERNEL_DIR}/kernel-config
+	install -m 0644 ${KERNEL_OUTDIR}/.config ${STAGING_KERNEL_DIR}/config-${KERNEL_VERSION}
+	ln -sf ${KERNEL_OUTDIR}/config-${KERNEL_VERSION} ${STAGING_KERNEL_DIR}/.config
+	ln -sf ${KERNEL_OUTDIR}/config-${KERNEL_VERSION} ${STAGING_KERNEL_DIR}/kernel-config
 	echo "${KERNEL_VERSION}" >${STAGING_KERNEL_DIR}/kernel-abiversion
 	echo "${S}" >${STAGING_KERNEL_DIR}/kernel-source
 	echo "${KERNEL_CCSUFFIX}" >${STAGING_KERNEL_DIR}/kernel-ccsuffix
@@ -159,17 +174,18 @@
 		install -d ${STAGING_KERNEL_DIR}/arch/x86
 		install -m 0644 arch/x86/Makefile* ${STAGING_KERNEL_DIR}/arch/x86
 	fi
-	cp -fR include/config* ${STAGING_KERNEL_DIR}/include/	
+	cp -fR ${KERNEL_OUTDIR}/include/config* ${STAGING_KERNEL_DIR}/include/	
 	# Install kernel images and system.map to staging
-	[ -e vmlinux ] && install -m 0644 vmlinux ${STAGING_KERNEL_DIR}/	
+	[ -e ${KERNEL_OUTDIR}/vmlinux ] && install -m 0644 ${KERNEL_OUTDIR}/vmlinux ${STAGING_KERNEL_DIR}/	
 	install -m 0644 ${KERNEL_OUTPUT} ${STAGING_KERNEL_DIR}/${KERNEL_IMAGETYPE}
-	install -m 0644 System.map ${STAGING_KERNEL_DIR}/System.map-${KERNEL_VERSION}
-	[ -e Module.symvers ] && install -m 0644 Module.symvers ${STAGING_KERNEL_DIR}/
+	install -m 0644 ${KERNEL_OUTDIR}/System.map ${STAGING_KERNEL_DIR}/System.map-${KERNEL_VERSION}
+	[ -e Module.symvers ] && install -m 0644 ${KERNEL_OUTDIR}/Module.symvers ${STAGING_KERNEL_DIR}/
 
 	cp -fR scripts ${STAGING_KERNEL_DIR}/
 }
 
 kernel_do_install() {
+	cd ${KERNEL_OUTDIR}
 	unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS MACHINE
 	if (grep -q -i -e '^CONFIG_MODULES=y$' .config); then
 		oe_runmake DEPMOD=echo INSTALL_MOD_PATH="${D}" modules_install
@@ -199,7 +215,8 @@
 }
 
 kernel_do_configure() {
-	yes '' | oe_runmake oldconfig
+	cd ${KERNEL_OUTDIR}
+	yes '' | oe_runmake ${EXTRA_KERNELMAKE} oldconfig
 	if [ ! -z "${INITRAMFS_IMAGE}" ]; then
 		for img in cpio.gz cpio.lzo cpio.lzma; do
 		if [ -e "${DEPLOY_DIR_IMAGE}/${INITRAMFS_IMAGE}-${MACHINE}.$img" ]; then
@@ -210,13 +227,16 @@
 }
 
 do_menuconfig() {
+	cd ${KERNEL_OUTDIR}
+	export DISPLAY="${DISPLAY}"
 	export TERMWINDOWTITLE="${PN} Kernel Configuration"
-	export SHELLCMDS="make menuconfig"
+	export SHELLCMDS="make ${EXTRA_KERNELMAKE} menuconfig"
 	${TERMCMDRUN}
 	if [ $? -ne 0 ]; then
 		echo "Fatal: '${TERMCMD}' not found. Check TERMCMD variable."
 		exit 1
 	fi
+	yes '' | oe_runmake ${EXTRA_KERNELMAKE} oldconfig
 }
 do_menuconfig[nostamp] = "1"
 addtask menuconfig after do_configure
@@ -529,7 +549,7 @@
 do_deploy() {
 	install -d ${DEPLOY_DIR_IMAGE}
 	install -m 0644 ${KERNEL_OUTPUT} ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGE_BASE_NAME}.bin
-	package_stagefile_shell ${S}/${KERNEL_OUTPUT}
+	package_stagefile_shell ${KERNEL_OUTPUT}
 	package_stagefile_shell ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGE_BASE_NAME}.bin
 
 	if [ -d "${PKGD}/lib" ]; then
openembedded/recipes/linux/stb-linux_2.6.24.bb renamed from oe.org/openembedded/recipes/linux/stb-linux_2.6.24.bb +76 -0

76 lines not on this page · raw message

#1 lore raw
Quoted 11 lines · C Michael Sundius

We build our kernel in an output directory so that the objects don't muck up our source directory. We do this since during development, most engineers just set up a link to their SCM Project directory containing the source rather than having bitbake copy all the files in to the ${S} directory.

I made some mods to the kernel.bbclass to allow us to build in the out directory and included it here in the attached patch (along w/ our own recipe for building the kernel). These mods *should* allow other kernel recipes to build unchanged.

Quoted 6 lines

I'd love to get comments on this, understanding that:
1) there might be a better way someone else is already using
2) that I've screwed stuff up
3) something else.

I'd also love to see this get pushed upstream if others find it useful..

As a concept, yay! I'd make a few suggestions on implementation however:
- B is the normal shorthand for where we build. See gcc / gdb / etc for examples of where $B != $S
- We should change $B to be something like, from the above example, B="${WORKDIR}/build-${MACHINE}
- We should then always work like this, rather than conditionally (since a kernel build where O=... fails is a bug, this should be fine).

Signature · 2 lines
Tom Rini <[email protected]>
Mentor Graphics Corporation
#2 lore raw
Quoted 11 lines

As a concept, yay! I'd make a few suggestions on implementation however:
- B is the normal shorthand for where we build. See gcc / gdb / etc for examples of where $B != $S
- We should change $B to be something like, from the above example, B="${WORKDIR}/build-${MACHINE}
- We should then always work like this, rather than conditionally (since a kernel build where O=... fails is a bug, this should be fine).

Ok thats all good to know, I made a few more changes.

Also realizing that some of the staging that I had in my own recipe really belonged in the kernel.bbclass. Though, that staging task is starting to get pretty messy :[

on the bright side, making those changes I think simplifies things even more.

Thanks
Mike

openembedded/classes/kernel.bbclass +56 -20
@@ -55,12 +55,18 @@
 KERNEL_LD = "${LD}${KERNEL_LDSUFFIX} ${HOST_LD_KERNEL_ARCH}"
 
 # Where built kernel lies in the kernel tree
-KERNEL_OUTPUT ?= "arch/${ARCH}/boot/${KERNEL_IMAGETYPE}"
+B = "${WORKDIR}/build-${MACHINE}"
+KERNEL_OUTPUT ?= "${B}/arch/${ARCH}/boot/${KERNEL_IMAGETYPE}"
 KERNEL_IMAGEDEST = "boot"
 
+#If we are using an output dir for kernel objs, then add the switch
+EXTRA_KERNELMAKE += "-C ${S} O=${B}"
+SCENEFUNCS += "kernel_setscene_func"
 #
 # configuration
 #
+KERNEL_CONFIGFILE = "${B}/.config"
+
 export CMDLINE_CONSOLE = "console=${@bb.data.getVar("KERNEL_CONSOLE",d,1) or "ttyS0"}"
 
 KERNEL_VERSION = "${@get_kernelversion('${S}')}"
@@ -78,16 +84,27 @@
 # For the kernel, we don't want the '-e MAKEFLAGS=' in EXTRA_OEMAKE.
 # We don't want to override kernel Makefile variables from the environment
 EXTRA_OEMAKE = ""
+# I use EXTRA_KERNELMAKE to make sure its not confused with EXTRA_OEMAKE
+EXTRA_KERNELMAKE ?= ""
+
+# should only be called when using 
+kernel_setscene_func() {
+	if [ "${S}" != "${B}" ]; then
+		install -d ${B}
+		rm -f ${S}/.config
+	fi
+}
 
 kernel_do_compile() {
+	cd ${B}
 	unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS MACHINE
-	oe_runmake include/linux/version.h CC="${KERNEL_CC}" LD="${KERNEL_LD}"
+	oe_runmake ${EXTRA_KERNELMAKE} include/linux/version.h CC="${KERNEL_CC}" LD="${KERNEL_LD}"
 	if [ "${KERNEL_MAJOR_VERSION}" != "2.6" ]; then
 		oe_runmake dep CC="${KERNEL_CC}" LD="${KERNEL_LD}"
 	fi
-	oe_runmake ${KERNEL_IMAGETYPE} CC="${KERNEL_CC}" LD="${KERNEL_LD}"
-	if (grep -q -i -e '^CONFIG_MODULES=y$' .config); then
-		oe_runmake modules  CC="${KERNEL_CC}" LD="${KERNEL_LD}"
+	oe_runmake ${EXTRA_KERNELMAKE} ${KERNEL_IMAGETYPE} CC="${KERNEL_CC}" LD="${KERNEL_LD}"
+	if (grep -q -i -e '^CONFIG_MODULES=y$' ${KERNEL_CONFIGFILE}); then
+		oe_runmake ${EXTRA_KERNELMAKE} modules  CC="${KERNEL_CC}" LD="${KERNEL_LD}"
 	else
 		oenote "no modules to compile"
 	fi
@@ -95,9 +112,9 @@
 kernel_do_compile[depends] = "${INITRAMFS_TASK}"
 
 kernel_do_stage() {
-	if [ -e include/asm ] ; then
+	if [ -e ${B}/include/asm ] ; then
 		# This link is generated only in kernel before 2.6.33-rc1, don't stage it for newer kernels
-		ASMDIR=`readlink include/asm`
+		ASMDIR=`readlink ${B}/include/asm`
 
 		mkdir -p ${STAGING_KERNEL_DIR}/include/$ASMDIR
 		cp -fR include/$ASMDIR/* ${STAGING_KERNEL_DIR}/include/$ASMDIR/
@@ -112,14 +129,14 @@
 
 	# Check for arch/x86 on i386
 	elif [ -d arch/x86/include/asm/ ]; then
-		if [ -e include/asm ] ; then
+		if [ -e ${B}/include/asm ] ; then
 			cp -fR arch/x86/include/asm/* ${STAGING_KERNEL_DIR}/include/asm-x86/
 		fi
 		install -d ${STAGING_KERNEL_DIR}/arch/x86/include
 		cp -fR arch/x86/* ${STAGING_KERNEL_DIR}/arch/x86/
 	fi
 
-	if [ -e include/asm ] ; then
+	if [ -e ${B}/include/asm ] ; then
 		rm -f ${STAGING_KERNEL_DIR}/include/asm
 		ln -sf $ASMDIR ${STAGING_KERNEL_DIR}/include/asm
 	fi
@@ -140,9 +157,9 @@
 		cp -fR drivers/sound/*.h ${STAGING_KERNEL_DIR}/include/drivers/sound/
 	fi
 
-	install -m 0644 .config ${STAGING_KERNEL_DIR}/config-${KERNEL_VERSION}
-	ln -sf config-${KERNEL_VERSION} ${STAGING_KERNEL_DIR}/.config
-	ln -sf config-${KERNEL_VERSION} ${STAGING_KERNEL_DIR}/kernel-config
+	install -m 0644 ${B}/.config ${STAGING_KERNEL_DIR}/config-${KERNEL_VERSION}
+	ln -sf ${B}/config-${KERNEL_VERSION} ${STAGING_KERNEL_DIR}/.config
+	ln -sf ${B}/config-${KERNEL_VERSION} ${STAGING_KERNEL_DIR}/kernel-config
 	echo "${KERNEL_VERSION}" >${STAGING_KERNEL_DIR}/kernel-abiversion
 	echo "${S}" >${STAGING_KERNEL_DIR}/kernel-source
 	echo "${KERNEL_CCSUFFIX}" >${STAGING_KERNEL_DIR}/kernel-ccsuffix
@@ -159,17 +176,32 @@
 		install -d ${STAGING_KERNEL_DIR}/arch/x86
 		install -m 0644 arch/x86/Makefile* ${STAGING_KERNEL_DIR}/arch/x86
 	fi
-	cp -fR include/config* ${STAGING_KERNEL_DIR}/include/	
+	cp -fR ${B}/include/config* ${STAGING_KERNEL_DIR}/include/	
 	# Install kernel images and system.map to staging
-	[ -e vmlinux ] && install -m 0644 vmlinux ${STAGING_KERNEL_DIR}/	
+	[ -e ${B}/vmlinux ] && install -m 0644 ${B}/vmlinux ${STAGING_KERNEL_DIR}/	
 	install -m 0644 ${KERNEL_OUTPUT} ${STAGING_KERNEL_DIR}/${KERNEL_IMAGETYPE}
-	install -m 0644 System.map ${STAGING_KERNEL_DIR}/System.map-${KERNEL_VERSION}
-	[ -e Module.symvers ] && install -m 0644 Module.symvers ${STAGING_KERNEL_DIR}/
+	install -m 0644 ${B}/System.map ${STAGING_KERNEL_DIR}/System.map-${KERNEL_VERSION}
+	[ -e Module.symvers ] && install -m 0644 ${B}/Module.symvers ${STAGING_KERNEL_DIR}/
+
+	cp -fR ${S}/scripts ${STAGING_KERNEL_DIR}/
+	cp -fR ${B}/scripts ${STAGING_KERNEL_DIR}/
+
+	if [ ! -e ${STAGING_KERNEL_DIR}/include/linux ]; then \
+		install -m 0755 -d ${STAGING_KERNEL_DIR}/include/linux; \
+	fi
+	install -m 0644 ${B}/include/linux/* \
+		${STAGING_KERNEL_DIR}/include/linux
+	if [ ! -e ${STAGING_KERNEL_DIR}/include/config ]; then \
+		install -m 0755 -d ${STAGING_KERNEL_DIR}/include/config; \
+	fi
+	install -m 0644 ${B}/include/config/auto.conf \
+		${STAGING_KERNEL_DIR}/include/config
 
-	cp -fR scripts ${STAGING_KERNEL_DIR}/
+	install -m 0644 ${B}/include/linux/version.h ${STAGING_KERNEL_DIR}/include/linux
 }
 
 kernel_do_install() {
+	cd ${B}
 	unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS MACHINE
 	if (grep -q -i -e '^CONFIG_MODULES=y$' .config); then
 		oe_runmake DEPMOD=echo INSTALL_MOD_PATH="${D}" modules_install
@@ -199,7 +231,8 @@
 }
 
 kernel_do_configure() {
-	yes '' | oe_runmake oldconfig
+	cd ${B}
+	yes '' | oe_runmake ${EXTRA_KERNELMAKE} oldconfig
 	if [ ! -z "${INITRAMFS_IMAGE}" ]; then
 		for img in cpio.gz cpio.lzo cpio.lzma; do
 		if [ -e "${DEPLOY_DIR_IMAGE}/${INITRAMFS_IMAGE}-${MACHINE}.$img" ]; then
@@ -210,13 +243,16 @@
 }
 
 do_menuconfig() {
+	cd ${B}
+	export DISPLAY="${DISPLAY}"
 	export TERMWINDOWTITLE="${PN} Kernel Configuration"
-	export SHELLCMDS="make menuconfig"
+	export SHELLCMDS="make ${EXTRA_KERNELMAKE} menuconfig"
 	${TERMCMDRUN}
 	if [ $? -ne 0 ]; then
 		echo "Fatal: '${TERMCMD}' not found. Check TERMCMD variable."
 		exit 1
 	fi
+	yes '' | oe_runmake ${EXTRA_KERNELMAKE} oldconfig
 }
 do_menuconfig[nostamp] = "1"
 addtask menuconfig after do_configure
@@ -529,7 +565,7 @@
 do_deploy() {
 	install -d ${DEPLOY_DIR_IMAGE}
 	install -m 0644 ${KERNEL_OUTPUT} ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGE_BASE_NAME}.bin
-	package_stagefile_shell ${S}/${KERNEL_OUTPUT}
+	package_stagefile_shell ${KERNEL_OUTPUT}
 	package_stagefile_shell ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGE_BASE_NAME}.bin
 
 	if [ -d "${PKGD}/lib" ]; then
openembedded/recipes/linux/stb-linux_2.6.24.bb +56 -0

56 lines not on this page · raw message

Acked-by
#3 lore raw
Quoted 10 lines · C Michael Sundius
Quoted 10 lines

As a concept, yay! I'd make a few suggestions on implementation however:
- B is the normal shorthand for where we build. See gcc / gdb / etc for examples of where $B != $S
- We should change $B to be something like, from the above example, B="${WORKDIR}/build-${MACHINE}
- We should then always work like this, rather than conditionally (since a kernel build where O=... fails is a bug, this should be fine).

Quoted 8 lines
Quoted 1 line

Ok thats all good to know, I made a few more changes.

Also realizing that some of the staging that I had in my own recipe really belonged in the kernel.bbclass. Though, that staging task is starting to get pretty messy :[

on the bright side, making those changes I think simplifies things even more.

On the kernel.bbclass side of things:

The stb-linux recipe should be its own patch, should have said that before, sorry.

Signature · 2 lines
Tom Rini <[email protected]>
Mentor Graphics Corporation
#4 lore raw
Quoted 24 lines · Tom Rini
Quoted 4 lines · C Michael Sundius
Quoted 4 lines

As a concept, yay! I'd make a few suggestions on implementation however:
- B is the normal shorthand for where we build. See gcc / gdb / etc

for

Quoted 4 lines
Quoted 4 lines

examples of where $B != $S
- We should change $B to be something like, from the above example, B="${WORKDIR}/build-${MACHINE}
- We should then always work like this, rather than conditionally

(since

Quoted 5 lines
Quoted 3 lines

a kernel build where O=... fails is a bug, this should be fine).

Ok thats all good to know, I made a few more changes.

Also realizing that some of the staging that I had in my own recipe

really

Quoted 1 line

belonged in the kernel.bbclass. Though, that staging task is starting to

get

Quoted 4 lines

pretty messy :[

on the bright side, making those changes I think simplifies things even more.

Quoted 6 lines

On the kernel.bbclass side of things:

oops.. small detail.. staging got done from the wrong directory when I used

${B}...

fixed in this patch. Also took out the stb-linux_2.6.24.bb

openembedded/classes/kernel.bbclass +57 -20
@@ -55,12 +55,18 @@
 KERNEL_LD = "${LD}${KERNEL_LDSUFFIX} ${HOST_LD_KERNEL_ARCH}"
 
 # Where built kernel lies in the kernel tree
-KERNEL_OUTPUT ?= "arch/${ARCH}/boot/${KERNEL_IMAGETYPE}"
+B = "${WORKDIR}/build-${MACHINE}"
+KERNEL_OUTPUT ?= "${B}/arch/${ARCH}/boot/${KERNEL_IMAGETYPE}"
 KERNEL_IMAGEDEST = "boot"
 
+#If we are using an output dir for kernel objs, then add the switch
+EXTRA_KERNELMAKE += "-C ${S} O=${B}"
+SCENEFUNCS += "kernel_setscene_func"
 #
 # configuration
 #
+KERNEL_CONFIGFILE = "${B}/.config"
+
 export CMDLINE_CONSOLE = "console=${@bb.data.getVar("KERNEL_CONSOLE",d,1) or "ttyS0"}"
 
 KERNEL_VERSION = "${@get_kernelversion('${S}')}"
@@ -78,16 +84,27 @@
 # For the kernel, we don't want the '-e MAKEFLAGS=' in EXTRA_OEMAKE.
 # We don't want to override kernel Makefile variables from the environment
 EXTRA_OEMAKE = ""
+# I use EXTRA_KERNELMAKE to make sure its not confused with EXTRA_OEMAKE
+EXTRA_KERNELMAKE ?= ""
+
+# should only be called when using 
+kernel_setscene_func() {
+	if [ "${S}" != "${B}" ]; then
+		install -d ${B}
+		rm -f ${S}/.config
+	fi
+}
 
 kernel_do_compile() {
+	cd ${B}
 	unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS MACHINE
-	oe_runmake include/linux/version.h CC="${KERNEL_CC}" LD="${KERNEL_LD}"
+	oe_runmake ${EXTRA_KERNELMAKE} include/linux/version.h CC="${KERNEL_CC}" LD="${KERNEL_LD}"
 	if [ "${KERNEL_MAJOR_VERSION}" != "2.6" ]; then
 		oe_runmake dep CC="${KERNEL_CC}" LD="${KERNEL_LD}"
 	fi
-	oe_runmake ${KERNEL_IMAGETYPE} CC="${KERNEL_CC}" LD="${KERNEL_LD}"
-	if (grep -q -i -e '^CONFIG_MODULES=y$' .config); then
-		oe_runmake modules  CC="${KERNEL_CC}" LD="${KERNEL_LD}"
+	oe_runmake ${EXTRA_KERNELMAKE} ${KERNEL_IMAGETYPE} CC="${KERNEL_CC}" LD="${KERNEL_LD}"
+	if (grep -q -i -e '^CONFIG_MODULES=y$' ${KERNEL_CONFIGFILE}); then
+		oe_runmake ${EXTRA_KERNELMAKE} modules  CC="${KERNEL_CC}" LD="${KERNEL_LD}"
 	else
 		oenote "no modules to compile"
 	fi
@@ -95,9 +112,9 @@
 kernel_do_compile[depends] = "${INITRAMFS_TASK}"
 
 kernel_do_stage() {
-	if [ -e include/asm ] ; then
+	if [ -e ${B}/include/asm ] ; then
 		# This link is generated only in kernel before 2.6.33-rc1, don't stage it for newer kernels
-		ASMDIR=`readlink include/asm`
+		ASMDIR=`readlink ${B}/include/asm`
 
 		mkdir -p ${STAGING_KERNEL_DIR}/include/$ASMDIR
 		cp -fR include/$ASMDIR/* ${STAGING_KERNEL_DIR}/include/$ASMDIR/
@@ -112,14 +129,14 @@
 
 	# Check for arch/x86 on i386
 	elif [ -d arch/x86/include/asm/ ]; then
-		if [ -e include/asm ] ; then
+		if [ -e ${B}/include/asm ] ; then
 			cp -fR arch/x86/include/asm/* ${STAGING_KERNEL_DIR}/include/asm-x86/
 		fi
 		install -d ${STAGING_KERNEL_DIR}/arch/x86/include
 		cp -fR arch/x86/* ${STAGING_KERNEL_DIR}/arch/x86/
 	fi
 
-	if [ -e include/asm ] ; then
+	if [ -e ${B}/include/asm ] ; then
 		rm -f ${STAGING_KERNEL_DIR}/include/asm
 		ln -sf $ASMDIR ${STAGING_KERNEL_DIR}/include/asm
 	fi
@@ -140,9 +157,9 @@
 		cp -fR drivers/sound/*.h ${STAGING_KERNEL_DIR}/include/drivers/sound/
 	fi
 
-	install -m 0644 .config ${STAGING_KERNEL_DIR}/config-${KERNEL_VERSION}
-	ln -sf config-${KERNEL_VERSION} ${STAGING_KERNEL_DIR}/.config
-	ln -sf config-${KERNEL_VERSION} ${STAGING_KERNEL_DIR}/kernel-config
+	install -m 0644 ${B}/.config ${STAGING_KERNEL_DIR}/config-${KERNEL_VERSION}
+	ln -sf ${B}/config-${KERNEL_VERSION} ${STAGING_KERNEL_DIR}/.config
+	ln -sf ${B}/config-${KERNEL_VERSION} ${STAGING_KERNEL_DIR}/kernel-config
 	echo "${KERNEL_VERSION}" >${STAGING_KERNEL_DIR}/kernel-abiversion
 	echo "${S}" >${STAGING_KERNEL_DIR}/kernel-source
 	echo "${KERNEL_CCSUFFIX}" >${STAGING_KERNEL_DIR}/kernel-ccsuffix
@@ -159,17 +176,33 @@
 		install -d ${STAGING_KERNEL_DIR}/arch/x86
 		install -m 0644 arch/x86/Makefile* ${STAGING_KERNEL_DIR}/arch/x86
 	fi
-	cp -fR include/config* ${STAGING_KERNEL_DIR}/include/	
+	cp -fR ${B}/include/config* ${STAGING_KERNEL_DIR}/include/	
 	# Install kernel images and system.map to staging
-	[ -e vmlinux ] && install -m 0644 vmlinux ${STAGING_KERNEL_DIR}/	
+	[ -e ${B}/vmlinux ] && install -m 0644 ${B}/vmlinux ${STAGING_KERNEL_DIR}/	
 	install -m 0644 ${KERNEL_OUTPUT} ${STAGING_KERNEL_DIR}/${KERNEL_IMAGETYPE}
-	install -m 0644 System.map ${STAGING_KERNEL_DIR}/System.map-${KERNEL_VERSION}
-	[ -e Module.symvers ] && install -m 0644 Module.symvers ${STAGING_KERNEL_DIR}/
+	install -m 0644 ${B}/System.map ${STAGING_KERNEL_DIR}/System.map-${KERNEL_VERSION}
+	[ -e Module.symvers ] && install -m 0644 ${B}/Module.symvers ${STAGING_KERNEL_DIR}/
+
+	cp -fR ${S}/scripts ${STAGING_KERNEL_DIR}/
+	cp -fR ${B}/scripts ${STAGING_KERNEL_DIR}/
+
+	if [ ! -e ${STAGING_KERNEL_DIR}/include/linux ]; then \
+		install -m 0755 -d ${STAGING_KERNEL_DIR}/include/linux; \
+	fi
+	install -m 0644 ${B}/include/linux/* \
+		${STAGING_KERNEL_DIR}/include/linux
+	if [ ! -e ${STAGING_KERNEL_DIR}/include/config ]; then \
+		install -m 0755 -d ${STAGING_KERNEL_DIR}/include/config; \
+	fi
+	install -m 0644 ${B}/include/config/auto.conf \
+		${STAGING_KERNEL_DIR}/include/config
 
-	cp -fR scripts ${STAGING_KERNEL_DIR}/
+	install -m 0644 ${B}/include/linux/version.h ${STAGING_KERNEL_DIR}/include/linux
 }
+do_stage[dirs] = "${S}"
 
 kernel_do_install() {
+	cd ${B}
 	unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS MACHINE
 	if (grep -q -i -e '^CONFIG_MODULES=y$' .config); then
 		oe_runmake DEPMOD=echo INSTALL_MOD_PATH="${D}" modules_install
@@ -199,7 +232,8 @@
 }
 
 kernel_do_configure() {
-	yes '' | oe_runmake oldconfig
+	cd ${B}
+	yes '' | oe_runmake ${EXTRA_KERNELMAKE} oldconfig
 	if [ ! -z "${INITRAMFS_IMAGE}" ]; then
 		for img in cpio.gz cpio.lzo cpio.lzma; do
 		if [ -e "${DEPLOY_DIR_IMAGE}/${INITRAMFS_IMAGE}-${MACHINE}.$img" ]; then
@@ -210,13 +244,16 @@
 }
 
 do_menuconfig() {
+	cd ${B}
+	export DISPLAY="${DISPLAY}"
 	export TERMWINDOWTITLE="${PN} Kernel Configuration"
-	export SHELLCMDS="make menuconfig"
+	export SHELLCMDS="make ${EXTRA_KERNELMAKE} menuconfig"
 	${TERMCMDRUN}
 	if [ $? -ne 0 ]; then
 		echo "Fatal: '${TERMCMD}' not found. Check TERMCMD variable."
 		exit 1
 	fi
+	yes '' | oe_runmake ${EXTRA_KERNELMAKE} oldconfig
 }
 do_menuconfig[nostamp] = "1"
 addtask menuconfig after do_configure
@@ -529,7 +566,7 @@
 do_deploy() {
 	install -d ${DEPLOY_DIR_IMAGE}
 	install -m 0644 ${KERNEL_OUTPUT} ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGE_BASE_NAME}.bin
-	package_stagefile_shell ${S}/${KERNEL_OUTPUT}
+	package_stagefile_shell ${KERNEL_OUTPUT}
 	package_stagefile_shell ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGE_BASE_NAME}.bin
 
 	if [ -d "${PKGD}/lib" ]; then