summaryrefslogtreecommitdiff
path: root/meta/classes/kernel.bbclass
diff options
context:
space:
mode:
authorDarren Hart <dvhart@linux.intel.com>2011-03-08 17:09:10 -0800
committerRichard Purdie <richard.purdie@linuxfoundation.org>2011-03-21 17:28:06 +0000
commita9d41062e24a6b99661b3a5256f369b557433607 (patch)
tree304d9be7e1cb8c12e3c8e6335ce43382774570e5 /meta/classes/kernel.bbclass
parent97b71119d716eab86b8afcbac204f38a00b88cf3 (diff)
downloadopenembedded-core-a9d41062e24a6b99661b3a5256f369b557433607.tar.gz
openembedded-core-a9d41062e24a6b99661b3a5256f369b557433607.tar.bz2
openembedded-core-a9d41062e24a6b99661b3a5256f369b557433607.zip
kernel/bbclass: rework kernel and module classes to allow for building out-of-tree modules
The existing infrastructure uses an external build tree which references the kernel source in the work dir. If run with rm work, building external modules will fail. This patch places a configured source tree in sysroots. Striking a balance between minimal size and minimal maintenance is difficult. A fully configured tree is about 500MB after a clean. This version leans on the side of caution and removes only the obviously unecessary parts of the source tree to conserve space, resulting in about 170MB. The arch directories would be some additional pruning we could do. Given examples from the devel package from distributions, I suspect this size could be reduced to 75MB or so, but at the cost of a much more complex recipe which is likely to require a great deal more maintenance to keep current with kernel releases. Care is also taken to clean the hostprogs in scripts, and the modules are responsible for building them as needed. Although it is unclear to me if this is really necessary, especially considering that modules put these bits back as soon as they compile. If we are not generating an sstate package, I suspect we can ignore these. Please try this with your modules and let me know how it does. I tried to take non linux-yocto kernel recipes into account, but I have only tested with linux-yocto and the hello-mod recipe so far. Signed-off-by: Darren Hart <dvhart@linux.intel.com> Acked-by: Koen Kooi <koen@dominion.thruhere.net> Acked-by: Gary Thomas <gary@mlbassoc.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes/kernel.bbclass')
-rw-r--r--meta/classes/kernel.bbclass97
1 files changed, 35 insertions, 62 deletions
diff --git a/meta/classes/kernel.bbclass b/meta/classes/kernel.bbclass
index a9a8f4fe9b..3eb6659a75 100644
--- a/meta/classes/kernel.bbclass
+++ b/meta/classes/kernel.bbclass
@@ -115,78 +115,51 @@ kernel_do_install() {
install -d ${D}/etc/modprobe.d
fi
-
+ #
+ # Support for external module building - create a minimal copy of the
+ # kernel source tree.
+ #
+ kerneldir=${STAGING_KERNEL_DIR}
+ install -d $kerneldir
#
- # Support for external module building - create a minimal copy of the kernel source tree
+ # Copy the entire source tree. In case an external build directory is
+ # used, copy the build directory over first, then copy over the source
+ # dir. This ensures the original Makefiles are used and not the
+ # redirecting Makefiles in the build directory.
#
- kerneldir=${D}/kernel/
-
- # Take care of arch specific headers
- # Kernel 2.6.27 moved headers from includes/asm-${ARCH} to arch/${ARCH}/include/asm
- if [ -e arch/${ARCH}/include/asm/ ] ; then
- install -d $kerneldir/arch/${ARCH}/
- cp -fR arch/${ARCH}/* $kerneldir/arch/${ARCH}/
-
- # Check for arch/x86 on i386
- elif [ -d arch/x86/include/asm/ ]; then
- if [ -e include/asm ] ; then
- install -d $kerneldir/include/asm/
- cp -fR arch/x86/include/asm/* $kerneldir/include/asm/
- fi
- install -d $kerneldir/arch/x86/include
- cp -fR arch/x86/* $kerneldir/arch/x86/
+ # work and sysroots can be on different partitions, so we can't rely on
+ # hardlinking, unfortunately.
+ #
+ cp -fR * $kerneldir
+ cp .config $kerneldir
+ if [ ! "${S}" == "${B}" ]; then
+ cp -fR ${S}/* $kerneldir
fi
+ echo "LINUX BUILD TREE COPIED TO SYSROOTS"
+ du -hs $kerneldir
- # Take care of the rest of the main directories we need
- for entry in drivers/crypto drivers/media include scripts; do
- if [ -d $entry ]; then
- mkdir -p $kerneldir/$entry
- cp -fR $entry/* $kerneldir/$entry/
- fi
- done
-
- install -m 0644 .config $kerneldir/config-${KERNEL_VERSION}
- ln -sf config-${KERNEL_VERSION} $kerneldir/.config
- ln -sf config-${KERNEL_VERSION} $kerneldir/kernel-config
- echo "${KERNEL_VERSION}" >$kerneldir/kernel-abiversion
- echo "${S}" >$kerneldir/kernel-source
- echo "${KERNEL_CCSUFFIX}" >$kerneldir/kernel-ccsuffix
- echo "${KERNEL_LDSUFFIX}" >$kerneldir/kernel-ldsuffix
- [ -e vmlinux ] && install -m 0644 vmlinux $kerneldir/
- install -m 0644 ${KERNEL_OUTPUT} $kerneldir/${KERNEL_IMAGETYPE}
- install -m 0644 System.map $kerneldir/System.map-${KERNEL_VERSION}
- [ -e Module.symvers ] && install -m 0644 Module.symvers $kerneldir/
-
- # Copy over the main Makefiles
- [ -e Rules.make ] && install -m 0644 Rules.make $kerneldir/
- [ -e Makefile ] && install -m 0644 Makefile $kerneldir/
- # Check if arch/${ARCH}/Makefile exists and install it
- if [ -e arch/${ARCH}/Makefile ]; then
- install -d $kerneldir/arch/${ARCH}
- install -m 0644 arch/${ARCH}/Makefile* $kerneldir/arch/${ARCH}
- # Otherwise check arch/x86/Makefile for i386 and x86_64 on kernels >= 2.6.24
- elif [ -e arch/x86/Makefile ]; then
- install -d $kerneldir/arch/x86
- install -m 0644 arch/x86/Makefile* $kerneldir/arch/x86
- fi
+ #
+ # Clean and remove files not needed for building modules.
+ # Some distributions go through a lot more trouble to strip out
+ # unecessary headers, for now, we just prune the obvious bits.
+ #
+ # We don't want to leave host-arch binaries in /sysroots, so
+ # we clean the scripts dir while leaving the generated config
+ # and include files.
+ #
+ oe_runmake -C $kerneldir CC="${KERNEL_CC}" LD="${KERNEL_LD}" clean
+ make -C $kerneldir _mrproper_scripts
+ find $kerneldir -path $kerneldir/scripts -prune -o -name "*.[csS]" -exec rm '{}' \;
+ find $kerneldir/Documentation -name "*.txt" -exec rm '{}' \;
# Remove the following binaries which cause strip errors
# during do_package for cross-compiled platforms
bin_files="arch/powerpc/boot/addnote arch/powerpc/boot/hack-coff \
- arch/powerpc/boot/mktree scripts/bin2c scripts/conmakehash \
- scripts/ihex2fw scripts/kallsyms scripts/pnmtologo scripts/basic/docproc \
- scripts/basic/fixdep scripts/basic/hash scripts/dtc/dtc \
- scripts/genksyms/genksyms scripts/kconfig/conf scripts/mod/mk_elfconfig \
- scripts/mod/modpost scripts/recordmcount"
- rm -rf $kerneldir/scripts/*.o
- rm -rf $kerneldir/scripts/basic/*.o
- rm -rf $kerneldir/scripts/kconfig/*.o
- rm -rf $kerneldir/scripts/mod/*.o
- rm -rf $kerneldir/scripts/dtc/*.o
+ arch/powerpc/boot/mktree"
for entry in $bin_files; do
- rm -f $kerneldir/$entry
- done
+ rm -f $kerneldir/$entry
+ done
}
sysroot_stage_all_append() {