kernel-devsrc: fix for kernel module compilation
[pti/rtp.git] / meta-stx / recipes-kernel / linux / kernel-devsrc.bbappend
1 #
2 # Copyright (C) 2019 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
17 do_install() {
18     kerneldir=${D}${KERNEL_SRC_PATH}
19     install -d $kerneldir
20
21     install -d ${D}${KERNEL_BUILD_ROOT}${KERNEL_VERSION}
22     (
23         cd ${D}${KERNEL_BUILD_ROOT}${KERNEL_VERSION}
24         rm -f source build
25         ln -s ${KERNEL_SRC_PATH} source
26         ln -s ${KERNEL_SRC_PATH} build
27     )
28
29     #
30     # Copy the staging dir source (and module build support) into the devsrc structure.
31     # We can keep this copy simple and take everything, since a we'll clean up any build
32     # artifacts afterwards, and the extra i/o is not significant
33     #
34     cd ${B}
35     find . -type d -name '.git*' -prune -o -path '.debug' -prune -o -type f -print0 | cpio --null -pdlu $kerneldir
36     cd ${S}
37     find . -type d -name '.git*' -prune -o -type d -name '.kernel-meta' -prune -o -type f -print0 | cpio --null -pdlu $kerneldir
38
39     # Explicitly set KBUILD_OUTPUT to ensure that the image directory is cleaned and not
40     # The main build artifacts. We clean the directory to avoid QA errors on mismatched
41     # architecture (since scripts and helpers are native format).
42     KBUILD_OUTPUT="$kerneldir"
43     oe_runmake -C $kerneldir CC="${KERNEL_CC}" LD="${KERNEL_LD}" clean _mrproper_scripts
44
45     # Clean objtool
46     oe_runmake -C $kerneldir/tools/objtool CC="${KERNEL_CC}" LD="${KERNEL_LD}" clean
47
48     cd $kerneldir
49     ln -sf System.map-* System.map
50
51     # make clean generates an absolute path symlink called "source"
52     # in $kerneldir points to $kerneldir, which doesn't make any
53     # sense, so remove it.
54     if [ -L $kerneldir/source ]; then
55         bbnote "Removing $kerneldir/source symlink"
56         rm -f $kerneldir/source
57     fi
58
59     # As of Linux kernel version 3.0.1, the clean target removes
60     # arch/powerpc/lib/crtsavres.o which is present in
61     # KBUILD_LDFLAGS_MODULE, making it required to build external modules.
62     if [ ${ARCH} = "powerpc" ]; then
63             mkdir -p $kerneldir/arch/powerpc/lib/
64             cp ${B}/arch/powerpc/lib/crtsavres.o $kerneldir/arch/powerpc/lib/crtsavres.o
65     fi
66
67     chown -R root:root ${D}
68 }
69
70 INSANE_SKIP_${PN} = "arch"