2013-12-12 16:07:04 +00:00
inherit linux-kernel-base kernel-module-split
2005-08-31 10:45:47 +00:00
PROVIDES += "virtual/kernel"
2014-10-02 20:33:23 +00:00
DEPENDS += "virtual/${TARGET_PREFIX}binutils virtual/${TARGET_PREFIX}gcc kmod-native depmodwrapper-cross bc-native"
2008-04-08 15:31:57 +00:00
2014-12-19 17:46:27 +00:00
S = "${STAGING_KERNEL_DIR}"
B = "${WORKDIR}/build"
KBUILD_OUTPUT = "${B}"
OE_TERMINAL_EXPORTS += "KBUILD_OUTPUT"
2014-12-18 11:41:58 +00:00
2008-04-08 15:31:57 +00:00
# we include gcc above, we dont need virtual/libc
INHIBIT_DEFAULT_DEPS = "1"
2005-08-31 10:45:47 +00:00
2008-03-25 15:48:26 +00:00
KERNEL_IMAGETYPE ?= "zImage"
2011-07-11 22:33:11 +00:00
INITRAMFS_IMAGE ?= ""
INITRAMFS_TASK ?= ""
2013-08-22 23:04:27 +00:00
INITRAMFS_IMAGE_BUNDLE ?= ""
2008-03-25 15:48:26 +00:00
python __anonymous () {
2015-05-14 12:31:06 +00:00
import re
2014-08-22 08:43:19 +00:00
kerneltype = d.getVar('KERNEL_IMAGETYPE', True)
2011-07-11 22:33:11 +00:00
2015-05-14 12:31:06 +00:00
d.setVar("KERNEL_IMAGETYPE_FOR_MAKE", re.sub(r'\.gz$', '', kerneltype))
Convert to use direct access to the data store (instead of bb.data.*Var*())
This is the result of running the following over the metadata:
sed \
-e 's:bb.data.\(setVar([^,()]*,[^,()]*\), *\([^ )]*\) *):\2.\1):g' \
-e 's:bb.data.\(setVarFlag([^,()]*,[^,()]*,[^,()]*\), *\([^) ]*\) *):\2.\1):g' \
-e 's:bb.data.\(getVar([^,()]*\), *\([^(), ]*\) *,\([^)]*\)):\2.\1,\3):g' \
-e 's:bb.data.\(getVarFlag([^,()]*,[^,()]*\), *\([^(), ]*\) *,\([^)]*\)):\2.\1,\3):g' \
-e 's:bb.data.\(getVarFlag([^,()]*,[^,()]*\), *\([^() ]*\) *):\2.\1):g' \
-e 's:bb.data.\(getVar([^,()]*\), *\([^) ]*\) *):\2.\1):g' \
-i `grep -ril bb.data *`
(From OE-Core rev: b22831fd63164c4db9c0b72934d7d734a6585251)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2011-11-09 15:00:01 +00:00
image = d.getVar('INITRAMFS_IMAGE', True)
2011-07-11 22:33:11 +00:00
if image:
2013-08-22 23:04:27 +00:00
d.appendVarFlag('do_bundle_initramfs', 'depends', ' ${INITRAMFS_IMAGE}:do_rootfs')
# NOTE: setting INITRAMFS_TASK is for backward compatibility
# The preferred method is to set INITRAMFS_IMAGE, because
# this INITRAMFS_TASK has circular dependency problems
# if the initramfs requires kernel modules
image_task = d.getVar('INITRAMFS_TASK', True)
if image_task:
d.appendVarFlag('do_configure', 'depends', ' ${INITRAMFS_TASK}')
2008-03-25 15:48:26 +00:00
}
2015-05-14 12:31:09 +00:00
# Here we pull in all various kernel image types which we support.
#
# In case you're wondering why kernel.bbclass inherits the other image
# types instead of the other way around, the reason for that is to
# maintain compatibility with various currently existing meta-layers.
# By pulling in the various kernel image types here, we retain the
# original behavior of kernel.bbclass, so no meta-layers should get
# broken.
#
# KERNEL_CLASSES by default pulls in kernel-uimage.bbclass, since this
# used to be the default behavior when only uImage was supported. This
# variable can be appended by users who implement support for new kernel
# image types.
KERNEL_CLASSES ?= " kernel-uimage "
inherit ${KERNEL_CLASSES}
2014-12-19 17:46:27 +00:00
# Old style kernels may set ${S} = ${WORKDIR}/git for example
# We need to move these over to STAGING_KERNEL_DIR. We can't just
# create the symlink in advance as the git fetcher can't cope with
# the symlink.
2015-01-15 11:54:19 +00:00
do_unpack[cleandirs] += " ${S} ${STAGING_KERNEL_DIR} ${B} ${STAGING_KERNEL_BUILDDIR}"
do_clean[cleandirs] += " ${S} ${STAGING_KERNEL_DIR} ${B} ${STAGING_KERNEL_BUILDDIR}"
2014-12-19 17:46:27 +00:00
base_do_unpack_append () {
s = d.getVar("S", True)
kernel.bbclass: fix do_unpack function when S ends with slash
* slash at the end causes os.symlink(kernsrc, s) to use s as
directory name and fails with:
ERROR: Error executing a python function in /OE/build/owpb/webos-ports/meta-smartphone/meta-samsung/recipes-kernel/linux/linux-samsung-tuna_git.bb:
The stack trace of python calls that resulted in this exception/failure was:
File: 'base_do_unpack', lineno: 26, function: <module>
0022: subprocess.call(d.expand("mv /OE/build/owpb/webos-ports/tmp-glibc/work/maguro-webos-linux-gnueabi/linux-samsung-tuna/3_3.0.72+gitrAUTOINC+f8ed73f94a-r12/git/ /OE/build/owpb/webos-ports/tmp-glibc/sysroots/maguro/usr/src/kernel"), shell=True)
0023: os.symlink(kernsrc, s)
0024:
0025:
*** 0026:base_do_unpack(d)
0027:
File: 'base_do_unpack', lineno: 23, function: base_do_unpack
0019: bb.utils.mkdirhier(kernsrc)
0020: bb.utils.remove(kernsrc, recurse=True)
0021: import subprocess
0022: subprocess.call(d.expand("mv /OE/build/owpb/webos-ports/tmp-glibc/work/maguro-webos-linux-gnueabi/linux-samsung-tuna/3_3.0.72+gitrAUTOINC+f8ed73f94a-r12/git/ /OE/build/owpb/webos-ports/tmp-glibc/sysroots/maguro/usr/src/kernel"), shell=True)
*** 0023: os.symlink(kernsrc, s)
0024:
0025:
0026:base_do_unpack(d)
0027:
Exception: OSError: [Errno 2] No such file or directory
ERROR: Function failed: base_do_unpack
ERROR: Logfile of failure stored in: /OE/build/owpb/webos-ports/tmp-glibc/work/maguro-webos-linux-gnueabi/linux-samsung-tuna/3_3.0.72+gitrAUTOINC+f8ed73f94a-r12/temp/log.do_unpack.17042
ERROR: Task 0 (/OE/build/owpb/webos-ports/meta-smartphone/meta-samsung/recipes-kernel/linux/linux-samsung-tuna_git.bb, do_unpack) failed with exit code '1'
(From OE-Core rev: dba30c2395792b553b69ce0b44cc75ff2dbdb317)
Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2015-01-07 14:06:49 +00:00
if s[-1] == '/':
# drop trailing slash, so that os.symlink(kernsrc, s) doesn't use s as directory name and fail
s=s[:-1]
2014-12-19 17:46:27 +00:00
kernsrc = d.getVar("STAGING_KERNEL_DIR", True)
if s != kernsrc:
bb.utils.mkdirhier(kernsrc)
bb.utils.remove(kernsrc, recurse=True)
import subprocess
subprocess.call(d.expand("mv ${S} ${STAGING_KERNEL_DIR}"), shell=True)
os.symlink(kernsrc, s)
}
2010-08-05 13:25:20 +00:00
inherit kernel-arch deploy
2005-08-31 10:45:47 +00:00
2012-10-12 10:46:38 +00:00
PACKAGES_DYNAMIC += "^kernel-module-.*"
PACKAGES_DYNAMIC += "^kernel-image-.*"
PACKAGES_DYNAMIC += "^kernel-firmware-.*"
2006-02-10 11:38:23 +00:00
2005-08-31 10:45:47 +00:00
export OS = "${TARGET_OS}"
export CROSS_COMPILE = "${TARGET_PREFIX}"
2012-03-23 12:56:28 +00:00
KERNEL_PRIORITY ?= "${@int(d.getVar('PV',1).split('-')[0].split('+')[0].split('.')[0]) * 10000 + \
int(d.getVar('PV',1).split('-')[0].split('+')[0].split('.')[1]) * 100 + \
int(d.getVar('PV',1).split('-')[0].split('+')[0].split('.')[-1])}"
2005-08-31 10:45:47 +00:00
2007-01-08 21:05:18 +00:00
KERNEL_RELEASE ?= "${KERNEL_VERSION}"
2005-12-12 14:41:23 +00:00
2008-06-05 10:49:22 +00:00
# Where built kernel lies in the kernel tree
2009-12-14 15:55:03 +00:00
KERNEL_OUTPUT ?= "arch/${ARCH}/boot/${KERNEL_IMAGETYPE}"
2005-08-31 10:45:47 +00:00
KERNEL_IMAGEDEST = "boot"
#
# configuration
#
Convert to use direct access to the data store (instead of bb.data.*Var*())
This is the result of running the following over the metadata:
sed \
-e 's:bb.data.\(setVar([^,()]*,[^,()]*\), *\([^ )]*\) *):\2.\1):g' \
-e 's:bb.data.\(setVarFlag([^,()]*,[^,()]*,[^,()]*\), *\([^) ]*\) *):\2.\1):g' \
-e 's:bb.data.\(getVar([^,()]*\), *\([^(), ]*\) *,\([^)]*\)):\2.\1,\3):g' \
-e 's:bb.data.\(getVarFlag([^,()]*,[^,()]*\), *\([^(), ]*\) *,\([^)]*\)):\2.\1,\3):g' \
-e 's:bb.data.\(getVarFlag([^,()]*,[^,()]*\), *\([^() ]*\) *):\2.\1):g' \
-e 's:bb.data.\(getVar([^,()]*\), *\([^) ]*\) *):\2.\1):g' \
-i `grep -ril bb.data *`
(From OE-Core rev: b22831fd63164c4db9c0b72934d7d734a6585251)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2011-11-09 15:00:01 +00:00
export CMDLINE_CONSOLE = "console=${@d.getVar("KERNEL_CONSOLE",1) or "ttyS0"}"
2005-08-31 10:45:47 +00:00
2014-10-21 21:05:30 +00:00
KERNEL_VERSION = "${@get_kernelversion_headers('${B}')}"
2005-08-31 10:45:47 +00:00
KERNEL_LOCALVERSION ?= ""
# kernels are generally machine specific
PACKAGE_ARCH = "${MACHINE_ARCH}"
2008-02-06 15:27:26 +00:00
# U-Boot support
UBOOT_ENTRYPOINT ?= "20008000"
2008-06-05 10:49:22 +00:00
UBOOT_LOADADDRESS ?= "${UBOOT_ENTRYPOINT}"
2008-02-06 15:27:26 +00:00
2013-08-05 17:08:25 +00:00
# Some Linux kernel configurations need additional parameters on the command line
2012-05-03 13:48:48 +00:00
KERNEL_EXTRA_ARGS ?= ""
2009-12-14 15:55:03 +00:00
# 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 = ""
2010-06-24 19:00:48 +00:00
KERNEL_ALT_IMAGETYPE ??= ""
2012-06-23 00:44:10 +00:00
# Define where the kernel headers are installed on the target as well as where
# they are staged.
KERNEL_SRC_PATH = "/usr/src/kernel"
2013-08-22 23:04:27 +00:00
copy_initramfs() {
echo "Copying initramfs into ./usr ..."
2013-09-27 21:32:00 +00:00
# In case the directory is not created yet from the first pass compile:
mkdir -p ${B}/usr
2013-08-22 23:04:27 +00:00
# Find and use the first initramfs image archive type we find
rm -f ${B}/usr/${INITRAMFS_IMAGE}-${MACHINE}.cpio
2014-01-14 11:00:48 +00:00
for img in cpio.gz cpio.lz4 cpio.lzo cpio.lzma cpio.xz; do
2013-08-22 23:04:27 +00:00
if [ -e "${DEPLOY_DIR_IMAGE}/${INITRAMFS_IMAGE}-${MACHINE}.$img" ]; then
cp ${DEPLOY_DIR_IMAGE}/${INITRAMFS_IMAGE}-${MACHINE}.$img ${B}/usr/.
case $img in
*gz)
echo "gzip decompressing image"
gunzip -f ${B}/usr/${INITRAMFS_IMAGE}-${MACHINE}.$img
break
;;
2014-01-14 11:00:48 +00:00
*lz4)
echo "lz4 decompressing image"
lz4 -df ${B}/usr/${INITRAMFS_IMAGE}-${MACHINE}.$img
break
;;
2013-08-22 23:04:27 +00:00
*lzo)
echo "lzo decompressing image"
lzop -df ${B}/usr/${INITRAMFS_IMAGE}-${MACHINE}.$img
break
;;
*lzma)
echo "lzma decompressing image"
2013-11-15 13:31:01 +00:00
lzma -df ${B}/usr/${INITRAMFS_IMAGE}-${MACHINE}.$img
2013-08-22 23:04:27 +00:00
break
;;
*xz)
echo "xz decompressing image"
xz -df ${B}/usr/${INITRAMFS_IMAGE}-${MACHINE}.$img
break
;;
esac
fi
done
echo "Finished copy of initramfs into ./usr"
}
INITRAMFS_BASE_NAME = "${KERNEL_IMAGETYPE}-initramfs-${PV}-${PR}-${MACHINE}-${DATETIME}"
INITRAMFS_BASE_NAME[vardepsexclude] = "DATETIME"
do_bundle_initramfs () {
if [ ! -z "${INITRAMFS_IMAGE}" -a x"${INITRAMFS_IMAGE_BUNDLE}" = x1 ]; then
echo "Creating a kernel image with a bundled initramfs..."
copy_initramfs
if [ -e ${KERNEL_OUTPUT} ] ; then
mv -f ${KERNEL_OUTPUT} ${KERNEL_OUTPUT}.bak
fi
use_alternate_initrd=CONFIG_INITRAMFS_SOURCE=${B}/usr/${INITRAMFS_IMAGE}-${MACHINE}.cpio
kernel_do_compile
mv -f ${KERNEL_OUTPUT} ${KERNEL_OUTPUT}.initramfs
mv -f ${KERNEL_OUTPUT}.bak ${KERNEL_OUTPUT}
# Update install area
echo "There is kernel image bundled with initramfs: ${B}/${KERNEL_OUTPUT}.initramfs"
install -m 0644 ${B}/${KERNEL_OUTPUT}.initramfs ${D}/boot/${KERNEL_IMAGETYPE}-initramfs-${MACHINE}.bin
echo "${B}/${KERNEL_OUTPUT}.initramfs"
fi
}
2013-09-20 05:45:46 +00:00
python do_devshell_prepend () {
os.environ["LDFLAGS"] = ''
}
2013-11-22 14:23:02 +00:00
addtask bundle_initramfs after do_install before do_deploy
2013-08-22 23:04:27 +00:00
2005-08-31 10:45:47 +00:00
kernel_do_compile() {
2006-11-20 08:56:52 +00:00
unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS MACHINE
2013-08-22 23:04:27 +00:00
# The $use_alternate_initrd is only set from
# do_bundle_initramfs() This variable is specifically for the
# case where we are making a second pass at the kernel
# compilation and we want to force the kernel build to use a
# different initramfs image. The way to do that in the kernel
# is to specify:
# make ...args... CONFIG_INITRAMFS_SOURCE=some_other_initramfs.cpio
2013-09-27 21:32:00 +00:00
if [ "$use_alternate_initrd" = "" ] && [ "${INITRAMFS_TASK}" != "" ] ; then
# The old style way of copying an prebuilt image and building it
# is turned on via INTIRAMFS_TASK != ""
copy_initramfs
use_alternate_initrd=CONFIG_INITRAMFS_SOURCE=${B}/usr/${INITRAMFS_IMAGE}-${MACHINE}.cpio
fi
2013-08-22 23:04:27 +00:00
oe_runmake ${KERNEL_IMAGETYPE_FOR_MAKE} ${KERNEL_ALT_IMAGETYPE} CC="${KERNEL_CC}" LD="${KERNEL_LD}" ${KERNEL_EXTRA_ARGS} $use_alternate_initrd
2011-08-25 12:59:28 +00:00
if test "${KERNEL_IMAGETYPE_FOR_MAKE}.gz" = "${KERNEL_IMAGETYPE}"; then
gzip -9c < "${KERNEL_IMAGETYPE_FOR_MAKE}" > "${KERNEL_OUTPUT}"
fi
2011-03-15 10:25:01 +00:00
}
do_compile_kernelmodules() {
unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS MACHINE
2005-08-31 10:45:47 +00:00
if (grep -q -i -e '^CONFIG_MODULES=y$' .config); then
2012-05-03 13:48:48 +00:00
oe_runmake ${PARALLEL_MAKE} modules CC="${KERNEL_CC}" LD="${KERNEL_LD}" ${KERNEL_EXTRA_ARGS}
2005-08-31 10:45:47 +00:00
else
2011-04-29 04:49:31 +00:00
bbnote "no modules to compile"
2005-08-31 10:45:47 +00:00
fi
}
2013-04-10 12:36:47 +00:00
addtask compile_kernelmodules after do_compile before do_strip
2005-08-31 10:45:47 +00:00
2009-11-19 13:22:48 +00:00
kernel_do_install() {
2010-05-24 10:14:56 +00:00
#
# First install the modules
#
2009-11-19 13:22:48 +00:00
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
2012-08-05 19:48:44 +00:00
rm "${D}/lib/modules/${KERNEL_VERSION}/build"
rm "${D}/lib/modules/${KERNEL_VERSION}/source"
2014-01-14 01:21:00 +00:00
# If the kernel/ directory is empty remove it to prevent QA issues
rmdir --ignore-fail-on-non-empty "${D}/lib/modules/${KERNEL_VERSION}/kernel"
2009-11-19 13:22:48 +00:00
else
2011-04-29 04:49:31 +00:00
bbnote "no modules to install"
2009-11-19 13:22:48 +00:00
fi
2010-05-24 10:14:56 +00:00
#
# Install various kernel output (zImage, map file, config, module support files)
2012-03-29 14:08:55 +00:00
#
2009-11-19 13:22:48 +00:00
install -d ${D}/${KERNEL_IMAGEDEST}
install -d ${D}/boot
install -m 0644 ${KERNEL_OUTPUT} ${D}/${KERNEL_IMAGEDEST}/${KERNEL_IMAGETYPE}-${KERNEL_VERSION}
install -m 0644 System.map ${D}/boot/System.map-${KERNEL_VERSION}
install -m 0644 .config ${D}/boot/config-${KERNEL_VERSION}
install -m 0644 vmlinux ${D}/boot/vmlinux-${KERNEL_VERSION}
2009-12-14 15:55:03 +00:00
[ -e Module.symvers ] && install -m 0644 Module.symvers ${D}/boot/Module.symvers-${KERNEL_VERSION}
2012-08-05 19:48:44 +00:00
install -d ${D}${sysconfdir}/modules-load.d
install -d ${D}${sysconfdir}/modprobe.d
kernel: move source and build output to work-shared
commit 3b3f7e785e279 [kernel: Rearrange for 1.8] began the process of
moving the kernel source and build artefacts out of sstate control and
into a shared location.
This changed triggered some workflow issues, as well as bugs related
to the kernel source containing build output, and hence being dirty and
breaking kernel rebuilds.
To solve these issues, and to make it clear that the kernel is not under
sstate control, we move the source and build outputs to:
work-shared/MACHINE/kernel-source
work-shared/MACHINE/kernel-build-artifacts
Where kernel-build-artifacts is the kernel build output and
kernel-source is kept "pristine". The build-artifacts contain everything
that is required to build external modules against the kernel source,
and includes the defconfig, the kernel-abiversion, System.map files and
output from "make scripts".
External module builds should either pass O= on the command line, or
set KBUILD_OUTPUT to point to the build-artifacts. module-base.bbclass
takes care of setting KBUILD_OUTPUT, so most existing external module
recipes are transparently adapted to the new source/build layout.
recipes that depend on the kernel source must have a depedency on the
do_shared_workdir task:
do_configure[depends] += "virtual/kernel:do_shared_workdir"
With this dependency added, the STAGING_KERNEL_DIR will be populated and
available to the rest of the build.
(From OE-Core rev: 6a1ff0e7eacef595738f2fed086986fd622ec32a)
Signed-off-by: Bruce Ashfield <bruce.ashfield@windriver.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2015-01-15 11:54:15 +00:00
}
do_install[prefuncs] += "package_get_auto_pr"
2009-11-19 13:22:48 +00:00
2015-05-06 20:28:39 +00:00
addtask shared_workdir after do_compile before do_compile_kernelmodules
2015-05-14 09:31:51 +00:00
addtask shared_workdir_setscene
do_shared_workdir_setscene () {
exit 1
}
kernel: move source and build output to work-shared
commit 3b3f7e785e279 [kernel: Rearrange for 1.8] began the process of
moving the kernel source and build artefacts out of sstate control and
into a shared location.
This changed triggered some workflow issues, as well as bugs related
to the kernel source containing build output, and hence being dirty and
breaking kernel rebuilds.
To solve these issues, and to make it clear that the kernel is not under
sstate control, we move the source and build outputs to:
work-shared/MACHINE/kernel-source
work-shared/MACHINE/kernel-build-artifacts
Where kernel-build-artifacts is the kernel build output and
kernel-source is kept "pristine". The build-artifacts contain everything
that is required to build external modules against the kernel source,
and includes the defconfig, the kernel-abiversion, System.map files and
output from "make scripts".
External module builds should either pass O= on the command line, or
set KBUILD_OUTPUT to point to the build-artifacts. module-base.bbclass
takes care of setting KBUILD_OUTPUT, so most existing external module
recipes are transparently adapted to the new source/build layout.
recipes that depend on the kernel source must have a depedency on the
do_shared_workdir task:
do_configure[depends] += "virtual/kernel:do_shared_workdir"
With this dependency added, the STAGING_KERNEL_DIR will be populated and
available to the rest of the build.
(From OE-Core rev: 6a1ff0e7eacef595738f2fed086986fd622ec32a)
Signed-off-by: Bruce Ashfield <bruce.ashfield@windriver.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2015-01-15 11:54:15 +00:00
2015-01-29 14:35:08 +00:00
emit_depmod_pkgdata() {
# Stash data for depmod
install -d ${PKGDESTWORK}/kernel-depmod/
echo "${KERNEL_VERSION}" > ${PKGDESTWORK}/kernel-depmod/kernel-abiversion
cp System.map ${PKGDESTWORK}/kernel-depmod/System.map-${KERNEL_VERSION}
}
PACKAGEFUNCS += "emit_depmod_pkgdata"
kernel: move source and build output to work-shared
commit 3b3f7e785e279 [kernel: Rearrange for 1.8] began the process of
moving the kernel source and build artefacts out of sstate control and
into a shared location.
This changed triggered some workflow issues, as well as bugs related
to the kernel source containing build output, and hence being dirty and
breaking kernel rebuilds.
To solve these issues, and to make it clear that the kernel is not under
sstate control, we move the source and build outputs to:
work-shared/MACHINE/kernel-source
work-shared/MACHINE/kernel-build-artifacts
Where kernel-build-artifacts is the kernel build output and
kernel-source is kept "pristine". The build-artifacts contain everything
that is required to build external modules against the kernel source,
and includes the defconfig, the kernel-abiversion, System.map files and
output from "make scripts".
External module builds should either pass O= on the command line, or
set KBUILD_OUTPUT to point to the build-artifacts. module-base.bbclass
takes care of setting KBUILD_OUTPUT, so most existing external module
recipes are transparently adapted to the new source/build layout.
recipes that depend on the kernel source must have a depedency on the
do_shared_workdir task:
do_configure[depends] += "virtual/kernel:do_shared_workdir"
With this dependency added, the STAGING_KERNEL_DIR will be populated and
available to the rest of the build.
(From OE-Core rev: 6a1ff0e7eacef595738f2fed086986fd622ec32a)
Signed-off-by: Bruce Ashfield <bruce.ashfield@windriver.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2015-01-15 11:54:15 +00:00
do_shared_workdir () {
cd ${B}
kerneldir=${STAGING_KERNEL_BUILDDIR}
2011-03-09 01:09:10 +00:00
install -d $kerneldir
2010-05-18 13:46:33 +00:00
2011-06-22 15:41:34 +00:00
#
# Store the kernel version in sysroots for module-base.bbclass
#
echo "${KERNEL_VERSION}" > $kerneldir/kernel-abiversion
kernel: move source and build output to work-shared
commit 3b3f7e785e279 [kernel: Rearrange for 1.8] began the process of
moving the kernel source and build artefacts out of sstate control and
into a shared location.
This changed triggered some workflow issues, as well as bugs related
to the kernel source containing build output, and hence being dirty and
breaking kernel rebuilds.
To solve these issues, and to make it clear that the kernel is not under
sstate control, we move the source and build outputs to:
work-shared/MACHINE/kernel-source
work-shared/MACHINE/kernel-build-artifacts
Where kernel-build-artifacts is the kernel build output and
kernel-source is kept "pristine". The build-artifacts contain everything
that is required to build external modules against the kernel source,
and includes the defconfig, the kernel-abiversion, System.map files and
output from "make scripts".
External module builds should either pass O= on the command line, or
set KBUILD_OUTPUT to point to the build-artifacts. module-base.bbclass
takes care of setting KBUILD_OUTPUT, so most existing external module
recipes are transparently adapted to the new source/build layout.
recipes that depend on the kernel source must have a depedency on the
do_shared_workdir task:
do_configure[depends] += "virtual/kernel:do_shared_workdir"
With this dependency added, the STAGING_KERNEL_DIR will be populated and
available to the rest of the build.
(From OE-Core rev: 6a1ff0e7eacef595738f2fed086986fd622ec32a)
Signed-off-by: Bruce Ashfield <bruce.ashfield@windriver.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2015-01-15 11:54:15 +00:00
2014-11-14 19:51:27 +00:00
# Copy files required for module builds
cp System.map $kerneldir/System.map-${KERNEL_VERSION}
cp Module.symvers $kerneldir/
cp .config $kerneldir/
mkdir -p $kerneldir/include/config
cp include/config/kernel.release $kerneldir/include/config/kernel.release
kernel: move source and build output to work-shared
commit 3b3f7e785e279 [kernel: Rearrange for 1.8] began the process of
moving the kernel source and build artefacts out of sstate control and
into a shared location.
This changed triggered some workflow issues, as well as bugs related
to the kernel source containing build output, and hence being dirty and
breaking kernel rebuilds.
To solve these issues, and to make it clear that the kernel is not under
sstate control, we move the source and build outputs to:
work-shared/MACHINE/kernel-source
work-shared/MACHINE/kernel-build-artifacts
Where kernel-build-artifacts is the kernel build output and
kernel-source is kept "pristine". The build-artifacts contain everything
that is required to build external modules against the kernel source,
and includes the defconfig, the kernel-abiversion, System.map files and
output from "make scripts".
External module builds should either pass O= on the command line, or
set KBUILD_OUTPUT to point to the build-artifacts. module-base.bbclass
takes care of setting KBUILD_OUTPUT, so most existing external module
recipes are transparently adapted to the new source/build layout.
recipes that depend on the kernel source must have a depedency on the
do_shared_workdir task:
do_configure[depends] += "virtual/kernel:do_shared_workdir"
With this dependency added, the STAGING_KERNEL_DIR will be populated and
available to the rest of the build.
(From OE-Core rev: 6a1ff0e7eacef595738f2fed086986fd622ec32a)
Signed-off-by: Bruce Ashfield <bruce.ashfield@windriver.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2015-01-15 11:54:15 +00:00
# We can also copy over all the generated files and avoid special cases
# like version.h, but we've opted to keep this small until file creep starts
# to happen
2015-01-15 11:54:14 +00:00
if [ -e include/linux/version.h ]; then
mkdir -p $kerneldir/include/linux
cp include/linux/version.h $kerneldir/include/linux/version.h
fi
2014-11-14 19:51:27 +00:00
# As of Linux kernel version 3.0.1, the clean target removes
# arch/powerpc/lib/crtsavres.o which is present in
# KBUILD_LDFLAGS_MODULE, making it required to build external modules.
if [ ${ARCH} = "powerpc" ]; then
mkdir -p $kerneldir/arch/powerpc/lib/
cp arch/powerpc/lib/crtsavres.o $kerneldir/arch/powerpc/lib/crtsavres.o
fi
mkdir -p $kerneldir/include/generated/
cp -fR include/generated/* $kerneldir/include/generated/
if [ -d arch/${ARCH}/include/generated ]; then
mkdir -p $kerneldir/arch/${ARCH}/include/generated/
cp -fR arch/${ARCH}/include/generated/* $kerneldir/arch/${ARCH}/include/generated/
fi
2005-08-31 10:45:47 +00:00
}
2015-01-29 14:35:08 +00:00
# We don't need to stage anything, not the modules/firmware since those would clash with linux-firmware
kernel: move source and build output to work-shared
commit 3b3f7e785e279 [kernel: Rearrange for 1.8] began the process of
moving the kernel source and build artefacts out of sstate control and
into a shared location.
This changed triggered some workflow issues, as well as bugs related
to the kernel source containing build output, and hence being dirty and
breaking kernel rebuilds.
To solve these issues, and to make it clear that the kernel is not under
sstate control, we move the source and build outputs to:
work-shared/MACHINE/kernel-source
work-shared/MACHINE/kernel-build-artifacts
Where kernel-build-artifacts is the kernel build output and
kernel-source is kept "pristine". The build-artifacts contain everything
that is required to build external modules against the kernel source,
and includes the defconfig, the kernel-abiversion, System.map files and
output from "make scripts".
External module builds should either pass O= on the command line, or
set KBUILD_OUTPUT to point to the build-artifacts. module-base.bbclass
takes care of setting KBUILD_OUTPUT, so most existing external module
recipes are transparently adapted to the new source/build layout.
recipes that depend on the kernel source must have a depedency on the
do_shared_workdir task:
do_configure[depends] += "virtual/kernel:do_shared_workdir"
With this dependency added, the STAGING_KERNEL_DIR will be populated and
available to the rest of the build.
(From OE-Core rev: 6a1ff0e7eacef595738f2fed086986fd622ec32a)
Signed-off-by: Bruce Ashfield <bruce.ashfield@windriver.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2015-01-15 11:54:15 +00:00
sysroot_stage_all () {
2015-01-29 14:35:08 +00:00
:
2005-08-31 10:45:47 +00:00
}
2014-12-19 17:46:27 +00:00
KERNEL_CONFIG_COMMAND ?= "oe_runmake_call -C ${S} O=${B} oldnoconfig || yes '' | oe_runmake -C ${S} O=${B} oldconfig"
2014-02-07 16:30:32 +00:00
2005-08-31 10:45:47 +00:00
kernel_do_configure() {
2012-03-23 12:56:29 +00:00
# fixes extra + in /lib/modules/2.6.37+
# $ scripts/setlocalversion . => +
# $ make kernelversion => 2.6.37
# $ make kernelrelease => 2.6.37+
2012-03-26 17:29:48 +00:00
touch ${B}/.scmversion ${S}/.scmversion
2012-03-23 12:56:29 +00:00
2014-12-19 17:46:27 +00:00
if [ "${S}" != "${B}" ] && [ -f "${S}/.config" ] && [ ! -f "${B}/.config" ]; then
mv "${S}/.config" "${B}/.config"
fi
2011-02-08 22:31:23 +00:00
# Copy defconfig to .config if .config does not exist. This allows
# recipes to manage the .config themselves in do_configure_prepend().
2011-07-20 20:22:31 +00:00
if [ -f "${WORKDIR}/defconfig" ] && [ ! -f "${B}/.config" ]; then
cp "${WORKDIR}/defconfig" "${B}/.config"
2011-02-08 22:31:23 +00:00
fi
2014-02-07 16:30:32 +00:00
eval ${KERNEL_CONFIG_COMMAND}
2005-08-31 10:45:47 +00:00
}
2011-08-02 12:30:18 +00:00
do_savedefconfig() {
oe_runmake savedefconfig
}
do_savedefconfig[nostamp] = "1"
addtask savedefconfig after do_configure
2005-08-31 10:45:47 +00:00
inherit cml1
2009-11-19 13:22:48 +00:00
EXPORT_FUNCTIONS do_compile do_install do_configure
2005-08-31 10:45:47 +00:00
2007-08-29 19:29:56 +00:00
# kernel-base becomes kernel-${KERNEL_VERSION}
# kernel-image becomes kernel-image-${KERNEL_VERISON}
2012-10-16 22:34:28 +00:00
PACKAGES = "kernel kernel-base kernel-vmlinux kernel-image kernel-dev kernel-modules"
2013-05-07 13:30:03 +00:00
FILES_${PN} = ""
2013-02-28 18:09:05 +00:00
FILES_kernel-base = "/lib/modules/${KERNEL_VERSION}/modules.order /lib/modules/${KERNEL_VERSION}/modules.builtin"
2005-08-31 10:45:47 +00:00
FILES_kernel-image = "/boot/${KERNEL_IMAGETYPE}*"
2014-09-30 21:40:05 +00:00
FILES_kernel-dev = "/boot/System.map* /boot/Module.symvers* /boot/config* ${KERNEL_SRC_PATH} /lib/modules/${KERNEL_VERSION}/build"
2007-09-11 12:47:17 +00:00
FILES_kernel-vmlinux = "/boot/vmlinux*"
2012-10-16 22:34:28 +00:00
FILES_kernel-modules = ""
2007-08-29 19:29:56 +00:00
RDEPENDS_kernel = "kernel-base"
# Allow machines to override this dependency if kernel image files are
# not wanted in images as standard
RDEPENDS_kernel-base ?= "kernel-image"
2011-05-20 16:29:47 +00:00
PKG_kernel-image = "kernel-image-${@legitimize_package_name('${KERNEL_VERSION}')}"
PKG_kernel-base = "kernel-${@legitimize_package_name('${KERNEL_VERSION}')}"
2012-07-06 15:52:41 +00:00
RPROVIDES_kernel-base += "kernel-${KERNEL_VERSION}"
2005-08-31 10:45:47 +00:00
ALLOW_EMPTY_kernel = "1"
2007-08-29 19:29:56 +00:00
ALLOW_EMPTY_kernel-base = "1"
2005-08-31 10:45:47 +00:00
ALLOW_EMPTY_kernel-image = "1"
2012-10-16 22:34:28 +00:00
ALLOW_EMPTY_kernel-modules = "1"
DESCRIPTION_kernel-modules = "Kernel modules meta package"
2005-08-31 10:45:47 +00:00
2014-03-21 18:02:38 +00:00
pkg_postinst_kernel-base () {
2013-08-09 17:58:42 +00:00
if [ ! -e "$D/lib/modules/${KERNEL_VERSION}" ]; then
mkdir -p $D/lib/modules/${KERNEL_VERSION}
fi
if [ -n "$D" ]; then
depmodwrapper -a -b $D ${KERNEL_VERSION}
else
depmod -a ${KERNEL_VERSION}
fi
}
2014-03-21 18:02:38 +00:00
pkg_postinst_kernel-image () {
2014-06-26 17:01:16 +00:00
update-alternatives --install /${KERNEL_IMAGEDEST}/${KERNEL_IMAGETYPE} ${KERNEL_IMAGETYPE} /${KERNEL_IMAGEDEST}/${KERNEL_IMAGETYPE}-${KERNEL_VERSION} ${KERNEL_PRIORITY} || true
2014-03-21 18:02:38 +00:00
}
2013-08-09 17:58:42 +00:00
pkg_postrm_kernel-image () {
update-alternatives --remove ${KERNEL_IMAGETYPE} ${KERNEL_IMAGETYPE}-${KERNEL_VERSION} || true
2006-05-30 20:08:51 +00:00
}
2013-02-03 17:31:30 +00:00
PACKAGESPLITFUNCS_prepend = "split_kernel_packages "
python split_kernel_packages () {
2014-09-21 11:08:55 +00:00
do_split_packages(d, root='/lib/firmware', file_regex='^(.*)\.(bin|fw|cis|dsp)$', output_pattern='kernel-firmware-%s', description='Firmware for %s', recursive=True, extra_depends='')
2005-08-31 10:45:47 +00:00
}
2007-12-06 09:43:11 +00:00
2013-04-10 12:36:47 +00:00
do_strip() {
if [ -n "${KERNEL_IMAGE_STRIP_EXTRA_SECTIONS}" ]; then
2014-12-12 20:47:43 +00:00
if [ "${KERNEL_IMAGETYPE}" != "vmlinux" ]; then
2013-04-10 12:36:47 +00:00
bbwarn "image type will not be stripped (not supported): ${KERNEL_IMAGETYPE}"
return
fi
cd ${B}
headers=`"$CROSS_COMPILE"readelf -S ${KERNEL_OUTPUT} | \
grep "^ \{1,\}\[[0-9 ]\{1,\}\] [^ ]" | \
sed "s/^ \{1,\}\[[0-9 ]\{1,\}\] //" | \
gawk '{print $1}'`
for str in ${KERNEL_IMAGE_STRIP_EXTRA_SECTIONS}; do {
2015-01-12 22:10:01 +00:00
if [ "$headers" != *"$str"* ]; then
2013-04-10 12:36:47 +00:00
bbwarn "Section not found: $str";
fi
"$CROSS_COMPILE"strip -s -R $str ${KERNEL_OUTPUT}
}; done
bbnote "KERNEL_IMAGE_STRIP_EXTRA_SECTIONS is set, stripping sections:" \
"${KERNEL_IMAGE_STRIP_EXTRA_SECTIONS}"
fi;
}
do_strip[dirs] = "${B}"
addtask do_strip before do_sizecheck after do_kernel_link_vmlinux
2007-12-06 09:43:11 +00:00
# Support checking the kernel size since some kernels need to reside in partitions
# with a fixed length or there is a limit in transferring the kernel to memory
do_sizecheck() {
2008-06-05 10:49:22 +00:00
if [ ! -z "${KERNEL_IMAGE_MAXSIZE}" ]; then
2014-07-07 09:33:59 +00:00
invalid=`echo ${KERNEL_IMAGE_MAXSIZE} | sed 's/[0-9]//g'`
if [ -n "$invalid" ]; then
die "Invalid KERNEL_IMAGE_MAXSIZE: ${KERNEL_IMAGE_MAXSIZE}, should be an integerx (The unit is Kbytes)"
fi
size=`du -ks ${B}/${KERNEL_OUTPUT} | awk '{ print $1}'`
2012-03-29 14:08:55 +00:00
if [ $size -ge ${KERNEL_IMAGE_MAXSIZE} ]; then
2014-07-07 09:33:59 +00:00
die "This kernel (size=$size(K) > ${KERNEL_IMAGE_MAXSIZE}(K)) is too big for your device. Please reduce the size of the kernel by making more of it modular."
2012-03-29 14:08:55 +00:00
fi
fi
2007-12-06 09:43:11 +00:00
}
2013-04-08 20:15:51 +00:00
do_sizecheck[dirs] = "${B}"
2007-12-06 09:43:11 +00:00
2013-04-10 12:36:47 +00:00
addtask sizecheck before do_install after do_strip
2008-02-06 15:27:26 +00:00
2013-04-15 11:07:01 +00:00
KERNEL_IMAGE_BASE_NAME ?= "${KERNEL_IMAGETYPE}-${PKGE}-${PKGV}-${PKGR}-${MACHINE}-${DATETIME}"
2010-12-16 08:56:15 +00:00
# Don't include the DATETIME variable in the sstate package signatures
KERNEL_IMAGE_BASE_NAME[vardepsexclude] = "DATETIME"
2008-06-05 10:49:22 +00:00
KERNEL_IMAGE_SYMLINK_NAME ?= "${KERNEL_IMAGETYPE}-${MACHINE}"
2013-04-15 11:07:01 +00:00
MODULE_IMAGE_BASE_NAME ?= "modules-${PKGE}-${PKGV}-${PKGR}-${MACHINE}-${DATETIME}"
2013-01-17 15:24:58 +00:00
MODULE_IMAGE_BASE_NAME[vardepsexclude] = "DATETIME"
2013-01-09 17:01:23 +00:00
MODULE_TARBALL_BASE_NAME ?= "${MODULE_IMAGE_BASE_NAME}.tgz"
2012-11-20 16:19:56 +00:00
# Don't include the DATETIME variable in the sstate package signatures
MODULE_TARBALL_SYMLINK_NAME ?= "modules-${MACHINE}.tgz"
2012-09-23 21:45:10 +00:00
MODULE_TARBALL_DEPLOY ?= "1"
2008-02-06 15:27:26 +00:00
2010-12-16 08:56:15 +00:00
kernel_do_deploy() {
2011-08-26 09:21:19 +00:00
install -m 0644 ${KERNEL_OUTPUT} ${DEPLOYDIR}/${KERNEL_IMAGE_BASE_NAME}.bin
2012-09-23 21:45:10 +00:00
if [ ${MODULE_TARBALL_DEPLOY} = "1" ] && (grep -q -i -e '^CONFIG_MODULES=y$' .config); then
2013-04-12 08:12:55 +00:00
mkdir -p ${D}/lib
2012-11-20 16:19:56 +00:00
tar -cvzf ${DEPLOYDIR}/${MODULE_TARBALL_BASE_NAME} -C ${D} lib
2013-06-05 09:20:50 +00:00
ln -sf ${MODULE_TARBALL_BASE_NAME} ${DEPLOYDIR}/${MODULE_TARBALL_SYMLINK_NAME}
2008-10-29 01:48:22 +00:00
fi
2008-06-05 10:49:22 +00:00
2013-05-21 22:18:53 +00:00
ln -sf ${KERNEL_IMAGE_BASE_NAME}.bin ${DEPLOYDIR}/${KERNEL_IMAGE_SYMLINK_NAME}.bin
ln -sf ${KERNEL_IMAGE_BASE_NAME}.bin ${DEPLOYDIR}/${KERNEL_IMAGETYPE}
2011-08-16 17:13:04 +00:00
2011-08-23 15:22:14 +00:00
cp ${COREBASE}/meta/files/deploydir_readme.txt ${DEPLOYDIR}/README_-_DO_NOT_DELETE_FILES_IN_THIS_DIRECTORY.txt
2013-11-22 14:23:02 +00:00
cd ${B}
# Update deploy directory
if [ -e "${KERNEL_OUTPUT}.initramfs" ]; then
echo "Copying deploy kernel-initramfs image and setting up links..."
initramfs_base_name=${INITRAMFS_BASE_NAME}
initramfs_symlink_name=${KERNEL_IMAGETYPE}-initramfs-${MACHINE}
install -m 0644 ${KERNEL_OUTPUT}.initramfs ${DEPLOYDIR}/${initramfs_base_name}.bin
cd ${DEPLOYDIR}
ln -sf ${initramfs_base_name}.bin ${initramfs_symlink_name}.bin
fi
2008-02-06 15:27:26 +00:00
}
2010-08-05 13:25:20 +00:00
do_deploy[dirs] = "${DEPLOYDIR} ${B}"
2013-04-15 11:07:01 +00:00
do_deploy[prefuncs] += "package_get_auto_pr"
2008-02-06 15:27:26 +00:00
kernel: move source and build output to work-shared
commit 3b3f7e785e279 [kernel: Rearrange for 1.8] began the process of
moving the kernel source and build artefacts out of sstate control and
into a shared location.
This changed triggered some workflow issues, as well as bugs related
to the kernel source containing build output, and hence being dirty and
breaking kernel rebuilds.
To solve these issues, and to make it clear that the kernel is not under
sstate control, we move the source and build outputs to:
work-shared/MACHINE/kernel-source
work-shared/MACHINE/kernel-build-artifacts
Where kernel-build-artifacts is the kernel build output and
kernel-source is kept "pristine". The build-artifacts contain everything
that is required to build external modules against the kernel source,
and includes the defconfig, the kernel-abiversion, System.map files and
output from "make scripts".
External module builds should either pass O= on the command line, or
set KBUILD_OUTPUT to point to the build-artifacts. module-base.bbclass
takes care of setting KBUILD_OUTPUT, so most existing external module
recipes are transparently adapted to the new source/build layout.
recipes that depend on the kernel source must have a depedency on the
do_shared_workdir task:
do_configure[depends] += "virtual/kernel:do_shared_workdir"
With this dependency added, the STAGING_KERNEL_DIR will be populated and
available to the rest of the build.
(From OE-Core rev: 6a1ff0e7eacef595738f2fed086986fd622ec32a)
Signed-off-by: Bruce Ashfield <bruce.ashfield@windriver.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2015-01-15 11:54:15 +00:00
addtask deploy after do_populate_sysroot
2010-09-08 14:48:31 +00:00
2010-12-16 08:56:15 +00:00
EXPORT_FUNCTIONS do_deploy