Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1 | SUMMARY = "Linux kernel Development Source" |
| 2 | DESCRIPTION = "Development source linux kernel. When built, this recipe packages the \ |
| 3 | source of the preferred virtual/kernel provider and makes it available for full kernel \ |
| 4 | development or external module builds" |
| 5 | |
| 6 | SECTION = "kernel" |
| 7 | |
Andrew Geissler | 7e0e3c0 | 2022-02-25 20:34:39 +0000 | [diff] [blame] | 8 | LICENSE = "GPL-2.0-only" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9 | |
| 10 | inherit linux-kernel-base |
| 11 | |
| 12 | # Whilst not a module, this ensures we don't get multilib extended (which would make no sense) |
| 13 | inherit module-base |
| 14 | |
| 15 | # We need the kernel to be staged (unpacked, patched and configured) before |
| 16 | # we can grab the source and make the source package. We also need the bits from |
| 17 | # ${B} not to change while we install, so virtual/kernel must finish do_compile. |
| 18 | do_install[depends] += "virtual/kernel:do_shared_workdir" |
| 19 | # Need the source, not just the output of populate_sysroot |
| 20 | do_install[depends] += "virtual/kernel:do_install" |
| 21 | |
| 22 | # There's nothing to do here, except install the source where we can package it |
| 23 | do_fetch[noexec] = "1" |
| 24 | do_unpack[noexec] = "1" |
| 25 | do_patch[noexec] = "1" |
| 26 | do_configure[noexec] = "1" |
| 27 | do_compile[noexec] = "1" |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 28 | deltask do_populate_sysroot |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 29 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 30 | S = "${STAGING_KERNEL_DIR}" |
| 31 | B = "${STAGING_KERNEL_BUILDDIR}" |
| 32 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 33 | PACKAGE_ARCH = "${MACHINE_ARCH}" |
| 34 | |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 35 | KERNEL_BUILD_ROOT="${nonarch_base_libdir}/modules/" |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 36 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 37 | do_install() { |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 38 | kerneldir=${D}${KERNEL_BUILD_ROOT}${KERNEL_VERSION} |
| 39 | install -d $kerneldir |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 40 | |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 41 | # create the directory structure |
| 42 | rm -f $kerneldir/build |
| 43 | rm -f $kerneldir/source |
| 44 | mkdir -p $kerneldir/build |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 45 | |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 46 | # for compatibility with some older variants of this package, we |
| 47 | # create a /usr/src/kernel symlink to /lib/modules/<version>/source |
| 48 | mkdir -p ${D}/usr/src |
| 49 | ( |
Patrick Williams | 73bd93f | 2024-02-20 08:07:48 -0600 | [diff] [blame] | 50 | cd ${D}/usr/src |
| 51 | ln -rs ${D}${KERNEL_BUILD_ROOT}${KERNEL_VERSION}/source kernel |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 52 | ) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 53 | |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 54 | # for on target purposes, we unify build and source |
| 55 | ( |
Patrick Williams | 73bd93f | 2024-02-20 08:07:48 -0600 | [diff] [blame] | 56 | cd $kerneldir |
| 57 | ln -s build source |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 58 | ) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 59 | |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 60 | # first copy everything |
| 61 | ( |
Patrick Williams | 73bd93f | 2024-02-20 08:07:48 -0600 | [diff] [blame] | 62 | cd ${S} |
| 63 | cp --parents $(find -type f -name "Makefile*" -o -name "Kconfig*") $kerneldir/build |
| 64 | cp --parents $(find -type f -name "Build" -o -name "Build.include") $kerneldir/build |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 65 | ) |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 66 | |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 67 | # then drop all but the needed Makefiles/Kconfig files |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 68 | rm -rf $kerneldir/build/scripts |
| 69 | rm -rf $kerneldir/build/include |
| 70 | |
| 71 | # now copy in parts from the build that we'll need later |
| 72 | ( |
Patrick Williams | 73bd93f | 2024-02-20 08:07:48 -0600 | [diff] [blame] | 73 | cd ${B} |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 74 | |
Patrick Williams | 73bd93f | 2024-02-20 08:07:48 -0600 | [diff] [blame] | 75 | if [ -s Module.symvers ]; then |
| 76 | cp Module.symvers $kerneldir/build |
| 77 | fi |
| 78 | cp System.map* $kerneldir/build |
| 79 | if [ -s Module.markers ]; then |
| 80 | cp Module.markers $kerneldir/build |
| 81 | fi |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 82 | |
Patrick Williams | 73bd93f | 2024-02-20 08:07:48 -0600 | [diff] [blame] | 83 | cp -a .config $kerneldir/build |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 84 | |
Patrick Williams | 73bd93f | 2024-02-20 08:07:48 -0600 | [diff] [blame] | 85 | # This scripts copy blow up QA, so for now, we require a more |
| 86 | # complex 'make scripts' to restore these, versus copying them |
| 87 | # here. Left as a reference to indicate that we know the scripts must |
| 88 | # be dealt with. |
| 89 | # cp -a scripts $kerneldir/build |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 90 | |
Patrick Williams | 73bd93f | 2024-02-20 08:07:48 -0600 | [diff] [blame] | 91 | # although module.lds can be regenerated on target via 'make modules_prepare' |
| 92 | # there are several places where 'makes scripts prepare' is done, and that won't |
| 93 | # regenerate the file. So we copy it onto the target as a migration to using |
| 94 | # modules_prepare |
| 95 | cp -a --parents scripts/module.lds $kerneldir/build/ 2>/dev/null || : |
Andrew Geissler | 6ce62a2 | 2020-11-30 19:58:47 -0600 | [diff] [blame] | 96 | |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 97 | if [ -d arch/${ARCH}/scripts ]; then |
Patrick Williams | 73bd93f | 2024-02-20 08:07:48 -0600 | [diff] [blame] | 98 | cp -a arch/${ARCH}/scripts $kerneldir/build/arch/${ARCH} |
| 99 | fi |
| 100 | if [ -f arch/${ARCH}/*lds ]; then |
| 101 | cp -a arch/${ARCH}/*lds $kerneldir/build/arch/${ARCH} |
| 102 | fi |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 103 | |
Patrick Williams | 73bd93f | 2024-02-20 08:07:48 -0600 | [diff] [blame] | 104 | rm -f $kerneldir/build/scripts/*.o |
| 105 | rm -f $kerneldir/build/scripts/*/*.o |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 106 | |
Patrick Williams | 73bd93f | 2024-02-20 08:07:48 -0600 | [diff] [blame] | 107 | if [ "${ARCH}" = "powerpc" ]; then |
| 108 | if [ -e arch/powerpc/lib/crtsavres.S ] || |
| 109 | [ -e arch/powerpc/lib/crtsavres.o ]; then |
| 110 | cp -a --parents arch/powerpc/lib/crtsavres.[So] $kerneldir/build/ |
Patrick Williams | 03907ee | 2022-05-01 06:28:52 -0500 | [diff] [blame] | 111 | fi |
Patrick Williams | 73bd93f | 2024-02-20 08:07:48 -0600 | [diff] [blame] | 112 | fi |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 113 | |
Patrick Williams | 73bd93f | 2024-02-20 08:07:48 -0600 | [diff] [blame] | 114 | if [ "${ARCH}" = "arm64" -o "${ARCH}" = "riscv" ]; then |
| 115 | if [ -e arch/${ARCH}/kernel/vdso/vdso.lds ]; then |
| 116 | cp -a --parents arch/${ARCH}/kernel/vdso/vdso.lds $kerneldir/build/ |
| 117 | fi |
| 118 | fi |
| 119 | if [ "${ARCH}" = "powerpc" ]; then |
| 120 | cp -a --parents arch/powerpc/kernel/vdso32/vdso32.lds $kerneldir/build 2>/dev/null || : |
| 121 | cp -a --parents arch/powerpc/kernel/vdso64/vdso64.lds $kerneldir/build 2>/dev/null || : |
| 122 | # v5.19+ |
| 123 | cp -a --parents arch/powerpc/kernel/vdso/vdso*.lds $kerneldir/build 2>/dev/null || : |
| 124 | fi |
Andrew Geissler | b7d2861 | 2020-07-24 16:15:54 -0500 | [diff] [blame] | 125 | |
Patrick Williams | 73bd93f | 2024-02-20 08:07:48 -0600 | [diff] [blame] | 126 | cp -a include $kerneldir/build/include |
Andrew Geissler | 6ce62a2 | 2020-11-30 19:58:47 -0600 | [diff] [blame] | 127 | |
Patrick Williams | 73bd93f | 2024-02-20 08:07:48 -0600 | [diff] [blame] | 128 | # we don't usually copy generated files, since they can be rebuilt on the target, |
| 129 | # but without this file, we get a forced syncconfig run in v5.8+, which prompts and |
| 130 | # breaks workflows. |
| 131 | cp -a --parents include/generated/autoconf.h $kerneldir/build 2>/dev/null || : |
| 132 | |
| 133 | rm -f $kerneldir/include/generated/.vdso-offsets.h.cmd |
| 134 | rm -f $kerneldir/build/include/generated/.vdso-offsets.h.cmd |
| 135 | rm -f $kerneldir/build/include/generated/.compat_vdso-offsets.h.cmd |
| 136 | rm -f $kerneldir/build/include/generated/.vdso32-offsets.h.cmd |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 137 | ) |
| 138 | |
| 139 | # now grab the chunks from the source tree that we need |
| 140 | ( |
Patrick Williams | 73bd93f | 2024-02-20 08:07:48 -0600 | [diff] [blame] | 141 | cd ${S} |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 142 | |
Patrick Williams | 73bd93f | 2024-02-20 08:07:48 -0600 | [diff] [blame] | 143 | cp -a scripts $kerneldir/build |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 144 | |
Patrick Williams | 73bd93f | 2024-02-20 08:07:48 -0600 | [diff] [blame] | 145 | # for v6.1+ (otherwise we are missing multiple default targets) |
| 146 | cp -a --parents Kbuild $kerneldir/build 2>/dev/null || : |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame] | 147 | |
Patrick Williams | 73bd93f | 2024-02-20 08:07:48 -0600 | [diff] [blame] | 148 | # For v6.6+ the debian packing is moved out to seperate rules file |
| 149 | # Remove as we else would ned to RDEPEND on make |
| 150 | rm $kerneldir/build/scripts/package/debian/rules 2>/dev/null || : |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 151 | |
Patrick Williams | 73bd93f | 2024-02-20 08:07:48 -0600 | [diff] [blame] | 152 | # if our build dir had objtool, it will also be rebuilt on target, so |
| 153 | # we copy what is required for that build |
| 154 | if [ -f ${B}/tools/objtool/objtool ]; then |
| 155 | # these are a few files associated with objtool, since we'll need to |
| 156 | # rebuild it |
| 157 | cp -a --parents tools/build/Build.include $kerneldir/build/ |
| 158 | cp -a --parents tools/build/Build $kerneldir/build/ |
| 159 | cp -a --parents tools/build/fixdep.c $kerneldir/build/ |
| 160 | cp -a --parents tools/scripts/utilities.mak $kerneldir/build/ |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 161 | |
Patrick Williams | 73bd93f | 2024-02-20 08:07:48 -0600 | [diff] [blame] | 162 | # extra files, just in case |
| 163 | cp -a --parents tools/objtool/* $kerneldir/build/ |
| 164 | cp -a --parents tools/lib/* $kerneldir/build/ |
| 165 | cp -a --parents tools/lib/subcmd/* $kerneldir/build/ |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 166 | |
Patrick Williams | 73bd93f | 2024-02-20 08:07:48 -0600 | [diff] [blame] | 167 | cp -a --parents tools/include/* $kerneldir/build/ |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 168 | |
Patrick Williams | 73bd93f | 2024-02-20 08:07:48 -0600 | [diff] [blame] | 169 | cp -a --parents $(find tools/arch/${ARCH}/ -type f) $kerneldir/build/ |
| 170 | fi |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 171 | |
Patrick Williams | 73bd93f | 2024-02-20 08:07:48 -0600 | [diff] [blame] | 172 | if [ "${ARCH}" = "arm64" ]; then |
| 173 | # arch/arm64/include/asm/xen references arch/arm |
| 174 | cp -a --parents arch/arm/include/asm/xen $kerneldir/build/ |
| 175 | # arch/arm64/include/asm/opcodes.h references arch/arm |
| 176 | cp -a --parents arch/arm/include/asm/opcodes.h $kerneldir/build/ |
| 177 | |
| 178 | # v6.1+ |
| 179 | cp -a --parents arch/arm64/kernel/asm-offsets.c $kerneldir/build/ |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame] | 180 | |
Brad Bishop | 79641f2 | 2019-09-10 07:20:22 -0400 | [diff] [blame] | 181 | cp -a --parents arch/arm64/kernel/vdso/*gettimeofday.* $kerneldir/build/ |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 182 | cp -a --parents arch/arm64/kernel/vdso/sigreturn.S $kerneldir/build/ |
| 183 | cp -a --parents arch/arm64/kernel/vdso/note.S $kerneldir/build/ |
| 184 | cp -a --parents arch/arm64/kernel/vdso/gen_vdso_offsets.sh $kerneldir/build/ |
| 185 | |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 186 | cp -a --parents arch/arm64/kernel/module.lds $kerneldir/build/ 2>/dev/null || : |
Andrew Geissler | 5f35090 | 2021-07-23 13:09:54 -0400 | [diff] [blame] | 187 | |
| 188 | # 5.13+ needs these tools |
| 189 | cp -a --parents arch/arm64/tools/gen-cpucaps.awk $kerneldir/build/ 2>/dev/null || : |
| 190 | cp -a --parents arch/arm64/tools/cpucaps $kerneldir/build/ 2>/dev/null || : |
| 191 | |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 192 | # 5.19+ |
| 193 | cp -a --parents arch/arm64/tools/gen-sysreg.awk $kerneldir/build/ 2>/dev/null || : |
| 194 | cp -a --parents arch/arm64/tools/sysreg $kerneldir/build/ 2>/dev/null || : |
| 195 | |
Andrew Geissler | 5f35090 | 2021-07-23 13:09:54 -0400 | [diff] [blame] | 196 | if [ -e $kerneldir/build/arch/arm64/tools/gen-cpucaps.awk ]; then |
| 197 | sed -i -e "s,#!.*awk.*,#!${USRBINPATH}/env awk," $kerneldir/build/arch/arm64/tools/gen-cpucaps.awk |
| 198 | fi |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 199 | if [ -e $kerneldir/build/arch/arm64/tools/gen-sysreg.awk ]; then |
| 200 | sed -i -e "s,#!.*awk.*,#!${USRBINPATH}/env awk," $kerneldir/build/arch/arm64/tools/gen-sysreg.awk |
| 201 | fi |
Patrick Williams | 73bd93f | 2024-02-20 08:07:48 -0600 | [diff] [blame] | 202 | fi |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 203 | |
Patrick Williams | 73bd93f | 2024-02-20 08:07:48 -0600 | [diff] [blame] | 204 | if [ "${ARCH}" = "powerpc" ]; then |
| 205 | # 5.0 needs these files, but don't error if they aren't present in the source |
| 206 | cp -a --parents arch/${ARCH}/kernel/syscalls/syscall.tbl $kerneldir/build/ 2>/dev/null || : |
| 207 | cp -a --parents arch/${ARCH}/kernel/syscalls/syscalltbl.sh $kerneldir/build/ 2>/dev/null || : |
| 208 | cp -a --parents arch/${ARCH}/kernel/syscalls/syscallhdr.sh $kerneldir/build/ 2>/dev/null || : |
| 209 | cp -a --parents arch/${ARCH}/kernel/vdso32/* $kerneldir/build/ 2>/dev/null || : |
| 210 | cp -a --parents arch/${ARCH}/kernel/vdso64/* $kerneldir/build/ 2>/dev/null || : |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 211 | |
Patrick Williams | 73bd93f | 2024-02-20 08:07:48 -0600 | [diff] [blame] | 212 | # v5.19+ |
| 213 | cp -a --parents arch/powerpc/kernel/vdso/*.S $kerneldir/build 2>/dev/null || : |
| 214 | cp -a --parents arch/powerpc/kernel/vdso/*gettimeofday.* $kerneldir/build 2>/dev/null || : |
| 215 | cp -a --parents arch/powerpc/kernel/vdso/gen_vdso*_offsets.sh $kerneldir/build/ 2>/dev/null || : |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame] | 216 | |
Patrick Williams | 73bd93f | 2024-02-20 08:07:48 -0600 | [diff] [blame] | 217 | # v6,1+ |
| 218 | cp -a --parents arch/powerpc/kernel/asm-offsets.c $kerneldir/build/ 2>/dev/null || : |
| 219 | cp -a --parents arch/powerpc/kernel/head_booke.h $kerneldir/build/ 2>/dev/null || : |
| 220 | fi |
| 221 | if [ "${ARCH}" = "riscv" ]; then |
Andrew Geissler | 595f630 | 2022-01-24 19:11:47 +0000 | [diff] [blame] | 222 | cp -a --parents arch/riscv/kernel/vdso/*gettimeofday.* $kerneldir/build/ |
| 223 | cp -a --parents arch/riscv/kernel/vdso/note.S $kerneldir/build/ |
Patrick Williams | 73bd93f | 2024-02-20 08:07:48 -0600 | [diff] [blame] | 224 | # v6.1+ |
| 225 | cp -a --parents arch/riscv/kernel/asm-offsets.c $kerneldir/build/ |
Patrick Williams | 03907ee | 2022-05-01 06:28:52 -0500 | [diff] [blame] | 226 | if [ -e arch/riscv/kernel/vdso/gen_vdso_offsets.sh ]; then |
| 227 | cp -a --parents arch/riscv/kernel/vdso/gen_vdso_offsets.sh $kerneldir/build/ |
| 228 | fi |
Patrick Williams | 73bd93f | 2024-02-20 08:07:48 -0600 | [diff] [blame] | 229 | cp -a --parents arch/riscv/kernel/vdso/* $kerneldir/build/ 2>/dev/null || : |
| 230 | if [ -e arch/riscv/kernel/compat_vdso/gen_compat_vdso_offsets.sh ]; then |
| 231 | cp -a --parents arch/riscv/kernel/compat_vdso/gen_compat_vdso_offsets.sh $kerneldir/build/ |
| 232 | fi |
| 233 | cp -a --parents arch/riscv/kernel/compat_vdso/* $kerneldir/build/ 2>/dev/null || : |
| 234 | fi |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 235 | |
Patrick Williams | 73bd93f | 2024-02-20 08:07:48 -0600 | [diff] [blame] | 236 | # include the machine specific headers for ARM variants, if available. |
| 237 | if [ "${ARCH}" = "arm" ]; then |
| 238 | cp -a --parents arch/${ARCH}/mach-*/include $kerneldir/build/ |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 239 | |
Patrick Williams | 73bd93f | 2024-02-20 08:07:48 -0600 | [diff] [blame] | 240 | # include a few files for 'make prepare' |
| 241 | cp -a --parents arch/arm/tools/gen-mach-types $kerneldir/build/ |
| 242 | cp -a --parents arch/arm/tools/mach-types $kerneldir/build/ |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 243 | |
Patrick Williams | 73bd93f | 2024-02-20 08:07:48 -0600 | [diff] [blame] | 244 | # 5.19+ |
| 245 | cp -a --parents arch/arm/tools/gen-sysreg.awk $kerneldir/build/ 2>/dev/null || : |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 246 | |
Patrick Williams | 73bd93f | 2024-02-20 08:07:48 -0600 | [diff] [blame] | 247 | # ARM syscall table tools only exist for kernels v4.10 or later |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 248 | SYSCALL_TOOLS=$(find arch/arm/tools -name "syscall*") |
| 249 | if [ -n "$SYSCALL_TOOLS" ] ; then |
Patrick Williams | 73bd93f | 2024-02-20 08:07:48 -0600 | [diff] [blame] | 250 | cp -a --parents $SYSCALL_TOOLS $kerneldir/build/ |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 251 | fi |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 252 | |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 253 | cp -a --parents arch/arm/kernel/module.lds $kerneldir/build/ 2>/dev/null || : |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame] | 254 | # v6.1+ |
| 255 | cp -a --parents arch/arm/kernel/asm-offsets.c $kerneldir/build/ 2>/dev/null || : |
| 256 | cp -a --parents arch/arm/kernel/signal.h $kerneldir/build/ 2>/dev/null || : |
Patrick Williams | 73bd93f | 2024-02-20 08:07:48 -0600 | [diff] [blame] | 257 | fi |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 258 | |
Patrick Williams | 73bd93f | 2024-02-20 08:07:48 -0600 | [diff] [blame] | 259 | if [ -d arch/${ARCH}/include ]; then |
| 260 | cp -a --parents arch/${ARCH}/include $kerneldir/build/ |
| 261 | fi |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 262 | |
Patrick Williams | 73bd93f | 2024-02-20 08:07:48 -0600 | [diff] [blame] | 263 | cp -a include $kerneldir/build |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 264 | |
Patrick Williams | 73bd93f | 2024-02-20 08:07:48 -0600 | [diff] [blame] | 265 | cp -a --parents lib/vdso/* $kerneldir/build/ 2>/dev/null || : |
Brad Bishop | 79641f2 | 2019-09-10 07:20:22 -0400 | [diff] [blame] | 266 | |
Patrick Williams | 73bd93f | 2024-02-20 08:07:48 -0600 | [diff] [blame] | 267 | cp -a --parents tools/include/tools/le_byteshift.h $kerneldir/build/ |
| 268 | cp -a --parents tools/include/tools/be_byteshift.h $kerneldir/build/ |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 269 | |
Patrick Williams | 73bd93f | 2024-02-20 08:07:48 -0600 | [diff] [blame] | 270 | # required for generate missing syscalls prepare phase |
| 271 | cp -a --parents $(find arch/x86 -type f -name "syscall_32.tbl") $kerneldir/build |
| 272 | cp -a --parents $(find arch/arm -type f -name "*.tbl") $kerneldir/build 2>/dev/null || : |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 273 | |
Patrick Williams | 73bd93f | 2024-02-20 08:07:48 -0600 | [diff] [blame] | 274 | if [ "${ARCH}" = "x86" ]; then |
| 275 | # files for 'make prepare' to succeed with kernel-devel |
| 276 | cp -a --parents $(find arch/x86 -type f -name "syscall_32.tbl") $kerneldir/build/ 2>/dev/null || : |
| 277 | cp -a --parents $(find arch/x86 -type f -name "syscalltbl.sh") $kerneldir/build/ 2>/dev/null || : |
| 278 | cp -a --parents $(find arch/x86 -type f -name "syscallhdr.sh") $kerneldir/build/ 2>/dev/null || : |
| 279 | cp -a --parents $(find arch/x86 -type f -name "syscall_64.tbl") $kerneldir/build/ 2>/dev/null || : |
| 280 | cp -a --parents arch/x86/tools/relocs_32.c $kerneldir/build/ |
| 281 | cp -a --parents arch/x86/tools/relocs_64.c $kerneldir/build/ |
| 282 | cp -a --parents arch/x86/tools/relocs.c $kerneldir/build/ |
| 283 | cp -a --parents arch/x86/tools/relocs_common.c $kerneldir/build/ |
| 284 | cp -a --parents arch/x86/tools/relocs.h $kerneldir/build/ |
| 285 | cp -a --parents arch/x86/tools/gen-insn-attr-x86.awk $kerneldir/build/ 2>/dev/null || : |
| 286 | cp -a --parents arch/x86/purgatory/purgatory.c $kerneldir/build/ |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 287 | |
Patrick Williams | 73bd93f | 2024-02-20 08:07:48 -0600 | [diff] [blame] | 288 | # 4.18 + have unified the purgatory files, so we ignore any errors if |
| 289 | # these files are not present |
| 290 | cp -a --parents arch/x86/purgatory/sha256.h $kerneldir/build/ 2>/dev/null || : |
| 291 | cp -a --parents arch/x86/purgatory/sha256.c $kerneldir/build/ 2>/dev/null || : |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 292 | |
Patrick Williams | 73bd93f | 2024-02-20 08:07:48 -0600 | [diff] [blame] | 293 | cp -a --parents arch/x86/purgatory/stack.S $kerneldir/build/ |
| 294 | cp -a --parents arch/x86/purgatory/string.c $kerneldir/build/ 2>/dev/null || : |
| 295 | cp -a --parents arch/x86/purgatory/setup-x86_64.S $kerneldir/build/ |
| 296 | cp -a --parents arch/x86/purgatory/entry64.S $kerneldir/build/ |
| 297 | cp -a --parents arch/x86/boot/string.h $kerneldir/build/ |
| 298 | cp -a --parents arch/x86/boot/string.c $kerneldir/build/ |
| 299 | cp -a --parents arch/x86/boot/compressed/string.c $kerneldir/build/ 2>/dev/null || : |
| 300 | cp -a --parents arch/x86/boot/ctype.h $kerneldir/build/ |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 301 | |
Patrick Williams | 73bd93f | 2024-02-20 08:07:48 -0600 | [diff] [blame] | 302 | # objtool requires these files |
| 303 | cp -a --parents arch/x86/lib/inat.c $kerneldir/build/ 2>/dev/null || : |
| 304 | cp -a --parents arch/x86/lib/insn.c $kerneldir/build/ 2>/dev/null || : |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame] | 305 | |
Patrick Williams | 73bd93f | 2024-02-20 08:07:48 -0600 | [diff] [blame] | 306 | # v6.1+ |
| 307 | cp -a --parents arch/x86/kernel/asm-offsets* $kerneldir/build || : |
| 308 | # for capabilities.h, vmx.h |
| 309 | cp -a --parents arch/x86/kvm/vmx/*.h $kerneldir/build || : |
| 310 | # for lapic.h, hyperv.h .... |
| 311 | cp -a --parents arch/x86/kvm/*.h $kerneldir/build || : |
| 312 | fi |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 313 | |
Patrick Williams | 73bd93f | 2024-02-20 08:07:48 -0600 | [diff] [blame] | 314 | # moved from arch/mips to all arches for v6.1+ |
| 315 | cp -a --parents kernel/time/timeconst.bc $kerneldir/build 2>/dev/null || : |
| 316 | cp -a --parents kernel/bounds.c $kerneldir/build 2>/dev/null || : |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame] | 317 | |
Patrick Williams | 73bd93f | 2024-02-20 08:07:48 -0600 | [diff] [blame] | 318 | if [ "${ARCH}" = "mips" ]; then |
| 319 | cp -a --parents arch/mips/Kbuild.platforms $kerneldir/build/ |
| 320 | cp --parents $(find -type f -name "Platform") $kerneldir/build |
| 321 | cp --parents arch/mips/boot/tools/relocs* $kerneldir/build |
| 322 | cp -a --parents arch/mips/kernel/asm-offsets.c $kerneldir/build |
| 323 | cp -a --parents Kbuild $kerneldir/build |
| 324 | cp -a --parents arch/mips/kernel/syscalls/*.sh $kerneldir/build 2>/dev/null || : |
| 325 | cp -a --parents arch/mips/kernel/syscalls/*.tbl $kerneldir/build 2>/dev/null || : |
| 326 | cp -a --parents arch/mips/tools/elf-entry.c $kerneldir/build 2>/dev/null || : |
| 327 | fi |
| 328 | |
| 329 | if [ "${ARCH}" = "loongarch" ]; then |
| 330 | cp -a --parents arch/loongarch/kernel/asm-offsets.c $kerneldir/build |
| 331 | cp -a --parents Kbuild $kerneldir/build |
| 332 | cp -a --parents arch/loongarch/vdso/*.S $kerneldir/build 2>/dev/null || : |
| 333 | cp -a --parents arch/loongarch/vdso/*gettimeofday.* $kerneldir/build 2>/dev/null || : |
| 334 | cp -a --parents arch/loongarch/vdso/*getcpu.* $kerneldir/build 2>/dev/null || : |
| 335 | cp -a --parents arch/loongarch/vdso/gen_vdso*_offsets.sh $kerneldir/build/ 2>/dev/null || : |
| 336 | fi |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 337 | |
| 338 | # required to build scripts/selinux/genheaders/genheaders |
| 339 | cp -a --parents security/selinux/include/* $kerneldir/build/ |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 340 | |
Patrick Williams | 73bd93f | 2024-02-20 08:07:48 -0600 | [diff] [blame] | 341 | # copy any localversion files |
| 342 | cp -a localversion* $kerneldir/build/ 2>/dev/null || : |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 343 | ) |
| 344 | |
| 345 | # Make sure the Makefile and version.h have a matching timestamp so that |
| 346 | # external modules can be built |
| 347 | touch -r $kerneldir/build/Makefile $kerneldir/build/include/generated/uapi/linux/version.h |
| 348 | |
Andrew Geissler | fc113ea | 2023-03-31 09:59:46 -0500 | [diff] [blame] | 349 | # This fixes a warning that the compilers don't match when building a module |
| 350 | # Change: CONFIG_CC_VERSION_TEXT="x86_64-poky-linux-gcc (GCC) 12.2.0" to "gcc (GCC) 12.2.0" |
| 351 | # #define CONFIG_CC_VERSION_TEXT "x86_64-poky-linux-gcc (GCC) 12.2.0" to "gcc (GCC) 12.2.0" |
| 352 | sed -i 's/CONFIG_CC_VERSION_TEXT=".*\(gcc.*\)"/CONFIG_CC_VERSION_TEXT="\1"/' "$kerneldir/build/.config" |
| 353 | sed -i 's/#define CONFIG_CC_VERSION_TEXT ".*\(gcc.*\)"/#define CONFIG_CC_VERSION_TEXT "\1"/' $kerneldir/build/include/generated/autoconf.h |
| 354 | sed -i 's/CONFIG_CC_VERSION_TEXT=".*\(gcc.*\)"/CONFIG_CC_VERSION_TEXT="\1"/' $kerneldir/build/include/config/auto.conf |
| 355 | |
Andrew Geissler | b7d2861 | 2020-07-24 16:15:54 -0500 | [diff] [blame] | 356 | # make sure these are at least as old as the .config, or rebuilds will trigger |
| 357 | touch -r $kerneldir/build/.config $kerneldir/build/include/generated/autoconf.h 2>/dev/null || : |
| 358 | touch -r $kerneldir/build/.config $kerneldir/build/include/config/auto.conf* 2>/dev/null || : |
| 359 | |
| 360 | if [ -e "$kerneldir/build/include/config/auto.conf.cmd" ]; then |
Andrew Geissler | 635e0e4 | 2020-08-21 15:58:33 -0500 | [diff] [blame] | 361 | sed -i 's/ifneq "$(CC)" ".*-linux-.*gcc.*$/ifneq "$(CC)" "gcc"/' "$kerneldir/build/include/config/auto.conf.cmd" |
| 362 | sed -i 's/ifneq "$(LD)" ".*-linux-.*ld.bfd.*$/ifneq "$(LD)" "ld"/' "$kerneldir/build/include/config/auto.conf.cmd" |
Andrew Geissler | 95ac1b8 | 2021-03-31 14:34:31 -0500 | [diff] [blame] | 363 | sed -i 's/ifneq "$(AR)" ".*-linux-.*ar.*$/ifneq "$(AR)" "ar"/' "$kerneldir/build/include/config/auto.conf.cmd" |
William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 364 | sed -i 's/ifneq "$(OBJCOPY)" ".*-linux-.*objcopy.*$/ifneq "$(OBJCOPY)" "objcopy"/' "$kerneldir/build/include/config/auto.conf.cmd" |
Andrew Geissler | 5f35090 | 2021-07-23 13:09:54 -0400 | [diff] [blame] | 365 | if [ "${ARCH}" = "powerpc" ]; then |
| 366 | sed -i 's/ifneq "$(NM)" ".*-linux-.*nm.*$/ifneq "$(NM)" "nm --synthetic"/' "$kerneldir/build/include/config/auto.conf.cmd" |
| 367 | else |
| 368 | sed -i 's/ifneq "$(NM)" ".*-linux-.*nm.*$/ifneq "$(NM)" "nm"/' "$kerneldir/build/include/config/auto.conf.cmd" |
| 369 | fi |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 370 | sed -i 's/ifneq "$(HOSTCXX)" ".*$/ifneq "$(HOSTCXX)" "g++"/' "$kerneldir/build/include/config/auto.conf.cmd" |
| 371 | sed -i 's/ifneq "$(HOSTCC)" ".*$/ifneq "$(HOSTCC)" "gcc"/' "$kerneldir/build/include/config/auto.conf.cmd" |
Andrew Geissler | b7d2861 | 2020-07-24 16:15:54 -0500 | [diff] [blame] | 372 | sed -i 's/ifneq "$(CC_VERSION_TEXT)".*\(gcc.*\)"/ifneq "$(CC_VERSION_TEXT)" "\1"/' "$kerneldir/build/include/config/auto.conf.cmd" |
| 373 | sed -i 's/ifneq "$(srctree)" ".*"/ifneq "$(srctree)" "."/' "$kerneldir/build/include/config/auto.conf.cmd" |
Andrew Geissler | 635e0e4 | 2020-08-21 15:58:33 -0500 | [diff] [blame] | 374 | # we don't build against the defconfig, so make sure it isn't the trigger for syncconfig |
| 375 | sed -i 's/ifneq "$(KBUILD_DEFCONFIG)".*"\(.*\)"/ifneq "\1" "\1"/' "$kerneldir/build/include/config/auto.conf.cmd" |
Andrew Geissler | b7d2861 | 2020-07-24 16:15:54 -0500 | [diff] [blame] | 376 | fi |
| 377 | |
Brad Bishop | 79641f2 | 2019-09-10 07:20:22 -0400 | [diff] [blame] | 378 | # make the scripts python3 safe. We won't be running these, and if they are |
| 379 | # left as /usr/bin/python rootfs assembly will fail, since we only have python3 |
| 380 | # in the RDEPENDS (and the python3 package does not include /usr/bin/python) |
| 381 | for ss in $(find $kerneldir/build/scripts -type f -name '*'); do |
Patrick Williams | 73bd93f | 2024-02-20 08:07:48 -0600 | [diff] [blame] | 382 | sed -i 's,/usr/bin/python2,/usr/bin/env python3,' "$ss" |
| 383 | sed -i 's,/usr/bin/env python2,/usr/bin/env python3,' "$ss" |
| 384 | sed -i 's,/usr/bin/python,/usr/bin/env python3,' "$ss" |
Brad Bishop | 79641f2 | 2019-09-10 07:20:22 -0400 | [diff] [blame] | 385 | done |
| 386 | |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 387 | chown -R root:root ${D} |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 388 | } |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 389 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 390 | # Ensure we don't race against "make scripts" during cpio |
| 391 | do_install[lockfiles] = "${TMPDIR}/kernel-scripts.lock" |
| 392 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 393 | FILES:${PN} = "${KERNEL_BUILD_ROOT} ${KERNEL_SRC_PATH}" |
| 394 | FILES:${PN}-dbg += "${KERNEL_BUILD_ROOT}*/build/scripts/*/.debug/*" |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 395 | |
Patrick Williams | 73bd93f | 2024-02-20 08:07:48 -0600 | [diff] [blame] | 396 | RDEPENDS:${PN} = "bc python3-core flex bison ${TCLIBC}-utils gawk" |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 397 | # 4.15+ needs these next two RDEPENDS |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 398 | RDEPENDS:${PN} += "openssl-dev util-linux" |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 399 | # and x86 needs a bit more for 4.15+ |
Andrew Geissler | d159c7f | 2021-09-02 21:05:58 -0500 | [diff] [blame] | 400 | RDEPENDS:${PN} += "${@bb.utils.contains('ARCH', 'x86', 'elfutils-dev', '', d)}" |
Andrew Geissler | fc113ea | 2023-03-31 09:59:46 -0500 | [diff] [blame] | 401 | # powerpc needs elfutils on 6.3+ |
| 402 | RDEPENDS:${PN} += "${@bb.utils.contains('ARCH', 'powerpc', 'elfutils-dev', '', d)}" |
Andrew Geissler | 635e0e4 | 2020-08-21 15:58:33 -0500 | [diff] [blame] | 403 | # 5.8+ needs gcc-plugins libmpc-dev |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 404 | RDEPENDS:${PN} += "gcc-plugins libmpc-dev" |
Andrew Geissler | 5f35090 | 2021-07-23 13:09:54 -0400 | [diff] [blame] | 405 | # 5.13+ needs grep for powerpc |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 406 | RDEPENDS:${PN}:append:powerpc = " grep" |