blob: a9e3e6c1f62e91b6ac5926dc1b9dd069817a4cbd [file] [log] [blame]
Jackie Huang4051bba2021-03-18 10:58:53 +08001#
2# Copyright (C) 2019-2021 Wind River Systems, Inc.
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15
16SUMMARY = "Linux kernel Development Source"
17DESCRIPTION = "Development source linux kernel. When built, this recipe packages the \
18source of the preferred virtual/kernel provider and makes it available for full kernel \
19development or external module builds"
20
21SECTION = "kernel"
22
23LICENSE = "GPLv2"
24
25inherit linux-kernel-base
26
27# Whilst not a module, this ensures we don't get multilib extended (which would make no sense)
28inherit module-base
29
30# We need the kernel to be staged (unpacked, patched and configured) before
31# we can grab the source and make the source package. We also need the bits from
32# ${B} not to change while we install, so virtual/kernel must finish do_compile.
33do_install[depends] += "virtual/kernel:do_shared_workdir"
34# Need the source, not just the output of populate_sysroot
35do_install[depends] += "virtual/kernel:do_install"
36
37# There's nothing to do here, except install the source where we can package it
38do_fetch[noexec] = "1"
39do_unpack[noexec] = "1"
40do_patch[noexec] = "1"
41do_configure[noexec] = "1"
42do_compile[noexec] = "1"
43do_populate_sysroot[noexec] = "1"
44
45S = "${STAGING_KERNEL_DIR}"
46B = "${STAGING_KERNEL_BUILDDIR}"
47
48KERNEL_VERSION = "${@get_kernelversion_headers('${S}')}"
49
50PACKAGE_ARCH = "${MACHINE_ARCH}"
51
52do_install() {
53 kerneldir=${D}${KERNEL_SRC_PATH}
54 install -d $kerneldir
55
56 #
57 # Copy the staging dir source (and module build support) into the devsrc structure.
58 # We can keep this copy simple and take everything, since a we'll clean up any build
59 # artifacts afterwards, and the extra i/o is not significant
60 #
61 cd ${B}
62 find . -type d -name '.git*' -prune -o -path '.debug' -prune -o -type f -print0 | cpio --null -pdlu $kerneldir
63 cd ${S}
64 find . -type d -name '.git*' -prune -o -type d -name '.kernel-meta' -prune -o -type f -print0 | cpio --null -pdlu $kerneldir
65
66 # Explicitly set KBUILD_OUTPUT to ensure that the image directory is cleaned and not
67 # The main build artifacts. We clean the directory to avoid QA errors on mismatched
68 # architecture (since scripts and helpers are native format).
69 KBUILD_OUTPUT="$kerneldir"
70 oe_runmake -C $kerneldir CC="${KERNEL_CC}" LD="${KERNEL_LD}" clean _mrproper_scripts
71
72 # make clean generates an absolute path symlink called "source"
73 # in $kerneldir points to $kerneldir, which doesn't make any
74 # sense, so remove it.
75 if [ -L $kerneldir/source ]; then
76 bbnote "Removing $kerneldir/source symlink"
77 rm -f $kerneldir/source
78 fi
79
80 # As of Linux kernel version 3.0.1, the clean target removes
81 # arch/powerpc/lib/crtsavres.o which is present in
82 # KBUILD_LDFLAGS_MODULE, making it required to build external modules.
83 if [ ${ARCH} = "powerpc" ]; then
84 mkdir -p $kerneldir/arch/powerpc/lib/
85 cp ${B}/arch/powerpc/lib/crtsavres.o $kerneldir/arch/powerpc/lib/crtsavres.o
86 fi
87
88 # Remove fixdep/objtool as they won't be target binaries
89 for i in fixdep objtool; do
90 if [ -e $kerneldir/tools/objtool/$i ]; then
91 rm -rf $kerneldir/tools/objtool/$i
92 fi
93 done
94
95 chown -R root:root ${D}
96}
97# Ensure we don't race against "make scripts" during cpio
98do_install[lockfiles] = "${TMPDIR}/kernel-scripts.lock"
99
100PACKAGES = "kernel-devsrc"
101FILES_${PN} = "${KERNEL_SRC_PATH}"
102RDEPENDS_${PN} = "bc"
103
104INSANE_SKIP_${PN} = "arch"