Add layer meta-stx-oran and distro poky-stx-oran
[pti/rtp.git] / meta-stx-oran / recipes-kernel / linux / kernel-devsrc.bb
1 #
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
16 SUMMARY = "Linux kernel Development Source"
17 DESCRIPTION = "Development source linux kernel. When built, this recipe packages the \
18 source of the preferred virtual/kernel provider and makes it available for full kernel \
19 development or external module builds"
20
21 SECTION = "kernel"
22
23 LICENSE = "GPLv2"
24
25 inherit linux-kernel-base
26
27 # Whilst not a module, this ensures we don't get multilib extended (which would make no sense)
28 inherit 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.
33 do_install[depends] += "virtual/kernel:do_shared_workdir"
34 # Need the source, not just the output of populate_sysroot
35 do_install[depends] += "virtual/kernel:do_install"
36
37 # There's nothing to do here, except install the source where we can package it
38 do_fetch[noexec] = "1"
39 do_unpack[noexec] = "1"
40 do_patch[noexec] = "1"
41 do_configure[noexec] = "1"
42 do_compile[noexec] = "1"
43 do_populate_sysroot[noexec] = "1"
44
45 S = "${STAGING_KERNEL_DIR}"
46 B = "${STAGING_KERNEL_BUILDDIR}"
47
48 KERNEL_VERSION = "${@get_kernelversion_headers('${S}')}"
49
50 PACKAGE_ARCH = "${MACHINE_ARCH}"
51
52 do_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
98 do_install[lockfiles] = "${TMPDIR}/kernel-scripts.lock"
99
100 PACKAGES = "kernel-devsrc"
101 FILES_${PN} = "${KERNEL_SRC_PATH}"
102 RDEPENDS_${PN} = "bc"
103
104 INSANE_SKIP_${PN} = "arch"