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 | ( |
| 50 | cd ${D}/usr/src |
Andrew Geissler | 595f630 | 2022-01-24 19:11:47 +0000 | [diff] [blame] | 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 | ( |
| 56 | cd $kerneldir |
| 57 | ln -s build source |
| 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 | ( |
| 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 |
| 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 | ( |
| 73 | cd ${B} |
| 74 | |
| 75 | cp Module.symvers $kerneldir/build |
| 76 | cp System.map* $kerneldir/build |
| 77 | if [ -s Module.markers ]; then |
| 78 | cp Module.markers $kerneldir/build |
| 79 | fi |
| 80 | |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 81 | cp -a .config $kerneldir/build |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 82 | |
| 83 | # This scripts copy blow up QA, so for now, we require a more |
| 84 | # complex 'make scripts' to restore these, versus copying them |
| 85 | # here. Left as a reference to indicate that we know the scripts must |
| 86 | # be dealt with. |
| 87 | # cp -a scripts $kerneldir/build |
| 88 | |
Andrew Geissler | 6ce62a2 | 2020-11-30 19:58:47 -0600 | [diff] [blame] | 89 | # although module.lds can be regenerated on target via 'make modules_prepare' |
| 90 | # there are several places where 'makes scripts prepare' is done, and that won't |
| 91 | # regenerate the file. So we copy it onto the target as a migration to using |
| 92 | # modules_prepare |
| 93 | cp -a --parents scripts/module.lds $kerneldir/build/ 2>/dev/null || : |
| 94 | |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 95 | if [ -d arch/${ARCH}/scripts ]; then |
| 96 | cp -a arch/${ARCH}/scripts $kerneldir/build/arch/${ARCH} |
| 97 | fi |
| 98 | if [ -f arch/${ARCH}/*lds ]; then |
| 99 | cp -a arch/${ARCH}/*lds $kerneldir/build/arch/${ARCH} |
| 100 | fi |
| 101 | |
| 102 | rm -f $kerneldir/build/scripts/*.o |
| 103 | rm -f $kerneldir/build/scripts/*/*.o |
| 104 | |
| 105 | if [ "${ARCH}" = "powerpc" ]; then |
| 106 | if [ -e arch/powerpc/lib/crtsavres.S ] || |
| 107 | [ -e arch/powerpc/lib/crtsavres.o ]; then |
| 108 | cp -a --parents arch/powerpc/lib/crtsavres.[So] $kerneldir/build/ |
| 109 | fi |
| 110 | fi |
| 111 | |
Andrew Geissler | 595f630 | 2022-01-24 19:11:47 +0000 | [diff] [blame] | 112 | if [ "${ARCH}" = "arm64" -o "${ARCH}" = "riscv" ]; then |
| 113 | cp -a --parents arch/${ARCH}/kernel/vdso/vdso.lds $kerneldir/build/ |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 114 | fi |
Andrew Geissler | 5f35090 | 2021-07-23 13:09:54 -0400 | [diff] [blame] | 115 | if [ "${ARCH}" = "powerpc" ]; then |
| 116 | cp -a --parents arch/powerpc/kernel/vdso32/vdso32.lds $kerneldir/build 2>/dev/null || : |
| 117 | cp -a --parents arch/powerpc/kernel/vdso64/vdso64.lds $kerneldir/build 2>/dev/null || : |
| 118 | fi |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 119 | |
| 120 | cp -a include $kerneldir/build/include |
Andrew Geissler | b7d2861 | 2020-07-24 16:15:54 -0500 | [diff] [blame] | 121 | |
| 122 | # we don't usually copy generated files, since they can be rebuilt on the target, |
| 123 | # but without this file, we get a forced syncconfig run in v5.8+, which prompts and |
| 124 | # breaks workflows. |
| 125 | cp -a --parents include/generated/autoconf.h $kerneldir/build 2>/dev/null || : |
Andrew Geissler | 6ce62a2 | 2020-11-30 19:58:47 -0600 | [diff] [blame] | 126 | |
| 127 | if [ -e $kerneldir/include/generated/.vdso-offsets.h.cmd ]; then |
| 128 | rm $kerneldir/include/generated/.vdso-offsets.h.cmd |
| 129 | fi |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 130 | ) |
| 131 | |
| 132 | # now grab the chunks from the source tree that we need |
| 133 | ( |
| 134 | cd ${S} |
| 135 | |
| 136 | cp -a scripts $kerneldir/build |
| 137 | |
| 138 | # if our build dir had objtool, it will also be rebuilt on target, so |
| 139 | # we copy what is required for that build |
| 140 | if [ -f ${B}/tools/objtool/objtool ]; then |
| 141 | # these are a few files associated with objtool, since we'll need to |
| 142 | # rebuild it |
| 143 | cp -a --parents tools/build/Build.include $kerneldir/build/ |
| 144 | cp -a --parents tools/build/Build $kerneldir/build/ |
| 145 | cp -a --parents tools/build/fixdep.c $kerneldir/build/ |
| 146 | cp -a --parents tools/scripts/utilities.mak $kerneldir/build/ |
| 147 | |
| 148 | # extra files, just in case |
| 149 | cp -a --parents tools/objtool/* $kerneldir/build/ |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 150 | cp -a --parents tools/lib/* $kerneldir/build/ |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 151 | cp -a --parents tools/lib/subcmd/* $kerneldir/build/ |
| 152 | |
| 153 | cp -a --parents tools/include/* $kerneldir/build/ |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 154 | |
| 155 | cp -a --parents $(find tools/arch/${ARCH}/ -type f) $kerneldir/build/ |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 156 | fi |
| 157 | |
| 158 | if [ "${ARCH}" = "arm64" ]; then |
| 159 | # arch/arm64/include/asm/xen references arch/arm |
| 160 | cp -a --parents arch/arm/include/asm/xen $kerneldir/build/ |
| 161 | # arch/arm64/include/asm/opcodes.h references arch/arm |
| 162 | cp -a --parents arch/arm/include/asm/opcodes.h $kerneldir/build/ |
| 163 | |
Brad Bishop | 79641f2 | 2019-09-10 07:20:22 -0400 | [diff] [blame] | 164 | cp -a --parents arch/arm64/kernel/vdso/*gettimeofday.* $kerneldir/build/ |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 165 | cp -a --parents arch/arm64/kernel/vdso/sigreturn.S $kerneldir/build/ |
| 166 | cp -a --parents arch/arm64/kernel/vdso/note.S $kerneldir/build/ |
| 167 | cp -a --parents arch/arm64/kernel/vdso/gen_vdso_offsets.sh $kerneldir/build/ |
| 168 | |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 169 | 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] | 170 | |
| 171 | # 5.13+ needs these tools |
| 172 | cp -a --parents arch/arm64/tools/gen-cpucaps.awk $kerneldir/build/ 2>/dev/null || : |
| 173 | cp -a --parents arch/arm64/tools/cpucaps $kerneldir/build/ 2>/dev/null || : |
| 174 | |
| 175 | if [ -e $kerneldir/build/arch/arm64/tools/gen-cpucaps.awk ]; then |
| 176 | sed -i -e "s,#!.*awk.*,#!${USRBINPATH}/env awk," $kerneldir/build/arch/arm64/tools/gen-cpucaps.awk |
| 177 | fi |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 178 | fi |
| 179 | |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 180 | if [ "${ARCH}" = "powerpc" ]; then |
| 181 | # 5.0 needs these files, but don't error if they aren't present in the source |
| 182 | cp -a --parents arch/${ARCH}/kernel/syscalls/syscall.tbl $kerneldir/build/ 2>/dev/null || : |
| 183 | cp -a --parents arch/${ARCH}/kernel/syscalls/syscalltbl.sh $kerneldir/build/ 2>/dev/null || : |
| 184 | cp -a --parents arch/${ARCH}/kernel/syscalls/syscallhdr.sh $kerneldir/build/ 2>/dev/null || : |
Andrew Geissler | 5f35090 | 2021-07-23 13:09:54 -0400 | [diff] [blame] | 185 | cp -a --parents arch/${ARCH}/kernel/vdso32/* $kerneldir/build/ 2>/dev/null || : |
| 186 | cp -a --parents arch/${ARCH}/kernel/vdso64/* $kerneldir/build/ 2>/dev/null || : |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 187 | fi |
Andrew Geissler | 595f630 | 2022-01-24 19:11:47 +0000 | [diff] [blame] | 188 | if [ "${ARCH}" = "riscv" ]; then |
| 189 | cp -a --parents arch/riscv/kernel/vdso/*gettimeofday.* $kerneldir/build/ |
| 190 | cp -a --parents arch/riscv/kernel/vdso/note.S $kerneldir/build/ |
| 191 | cp -a --parents arch/riscv/kernel/vdso/gen_vdso_offsets.sh $kerneldir/build/ |
| 192 | cp -a --parents arch/riscv/kernel/vdso/* $kerneldir/build/ 2>/dev/null || : |
| 193 | fi |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 194 | |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 195 | # include the machine specific headers for ARM variants, if available. |
| 196 | if [ "${ARCH}" = "arm" ]; then |
| 197 | cp -a --parents arch/${ARCH}/mach-*/include $kerneldir/build/ |
| 198 | |
| 199 | # include a few files for 'make prepare' |
| 200 | cp -a --parents arch/arm/tools/gen-mach-types $kerneldir/build/ |
| 201 | cp -a --parents arch/arm/tools/mach-types $kerneldir/build/ |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 202 | |
| 203 | # ARM syscall table tools only exist for kernels v4.10 or later |
| 204 | SYSCALL_TOOLS=$(find arch/arm/tools -name "syscall*") |
| 205 | if [ -n "$SYSCALL_TOOLS" ] ; then |
| 206 | cp -a --parents $SYSCALL_TOOLS $kerneldir/build/ |
| 207 | fi |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 208 | |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 209 | cp -a --parents arch/arm/kernel/module.lds $kerneldir/build/ 2>/dev/null || : |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 210 | fi |
| 211 | |
| 212 | if [ -d arch/${ARCH}/include ]; then |
| 213 | cp -a --parents arch/${ARCH}/include $kerneldir/build/ |
| 214 | fi |
| 215 | |
| 216 | cp -a include $kerneldir/build |
| 217 | |
Brad Bishop | 79641f2 | 2019-09-10 07:20:22 -0400 | [diff] [blame] | 218 | cp -a --parents lib/vdso/* $kerneldir/build/ 2>/dev/null || : |
| 219 | |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 220 | cp -a --parents tools/include/tools/le_byteshift.h $kerneldir/build/ |
| 221 | cp -a --parents tools/include/tools/be_byteshift.h $kerneldir/build/ |
| 222 | |
| 223 | # required for generate missing syscalls prepare phase |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 224 | cp -a --parents $(find arch/x86 -type f -name "syscall_32.tbl") $kerneldir/build |
| 225 | 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] | 226 | |
| 227 | if [ "${ARCH}" = "x86" ]; then |
| 228 | # files for 'make prepare' to succeed with kernel-devel |
Andrew Geissler | d159c7f | 2021-09-02 21:05:58 -0500 | [diff] [blame] | 229 | cp -a --parents $(find arch/x86 -type f -name "syscall_32.tbl") $kerneldir/build/ 2>/dev/null || : |
| 230 | cp -a --parents $(find arch/x86 -type f -name "syscalltbl.sh") $kerneldir/build/ 2>/dev/null || : |
| 231 | cp -a --parents $(find arch/x86 -type f -name "syscallhdr.sh") $kerneldir/build/ 2>/dev/null || : |
| 232 | cp -a --parents $(find arch/x86 -type f -name "syscall_64.tbl") $kerneldir/build/ 2>/dev/null || : |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 233 | cp -a --parents arch/x86/tools/relocs_32.c $kerneldir/build/ |
| 234 | cp -a --parents arch/x86/tools/relocs_64.c $kerneldir/build/ |
| 235 | cp -a --parents arch/x86/tools/relocs.c $kerneldir/build/ |
| 236 | cp -a --parents arch/x86/tools/relocs_common.c $kerneldir/build/ |
| 237 | cp -a --parents arch/x86/tools/relocs.h $kerneldir/build/ |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 238 | cp -a --parents arch/x86/tools/gen-insn-attr-x86.awk $kerneldir/build/ 2>/dev/null || : |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 239 | cp -a --parents arch/x86/purgatory/purgatory.c $kerneldir/build/ |
| 240 | |
| 241 | # 4.18 + have unified the purgatory files, so we ignore any errors if |
| 242 | # these files are not present |
| 243 | cp -a --parents arch/x86/purgatory/sha256.h $kerneldir/build/ 2>/dev/null || : |
| 244 | cp -a --parents arch/x86/purgatory/sha256.c $kerneldir/build/ 2>/dev/null || : |
| 245 | |
| 246 | cp -a --parents arch/x86/purgatory/stack.S $kerneldir/build/ |
Brad Bishop | c68388fc | 2019-08-26 01:33:31 -0400 | [diff] [blame] | 247 | cp -a --parents arch/x86/purgatory/string.c $kerneldir/build/ 2>/dev/null || : |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 248 | cp -a --parents arch/x86/purgatory/setup-x86_64.S $kerneldir/build/ |
| 249 | cp -a --parents arch/x86/purgatory/entry64.S $kerneldir/build/ |
| 250 | cp -a --parents arch/x86/boot/string.h $kerneldir/build/ |
| 251 | cp -a --parents arch/x86/boot/string.c $kerneldir/build/ |
Brad Bishop | c68388fc | 2019-08-26 01:33:31 -0400 | [diff] [blame] | 252 | cp -a --parents arch/x86/boot/compressed/string.c $kerneldir/build/ 2>/dev/null || : |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 253 | cp -a --parents arch/x86/boot/ctype.h $kerneldir/build/ |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 254 | |
| 255 | # objtool requires these files |
| 256 | cp -a --parents arch/x86/lib/inat.c $kerneldir/build/ 2>/dev/null || : |
| 257 | cp -a --parents arch/x86/lib/insn.c $kerneldir/build/ 2>/dev/null || : |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 258 | fi |
| 259 | |
| 260 | if [ "${ARCH}" = "mips" ]; then |
| 261 | cp -a --parents arch/mips/Kbuild.platforms $kerneldir/build/ |
| 262 | cp --parents $(find -type f -name "Platform") $kerneldir/build |
| 263 | cp --parents arch/mips/boot/tools/relocs* $kerneldir/build |
| 264 | cp -a --parents arch/mips/kernel/asm-offsets.c $kerneldir/build |
| 265 | cp -a --parents kernel/time/timeconst.bc $kerneldir/build |
| 266 | cp -a --parents kernel/bounds.c $kerneldir/build |
| 267 | cp -a --parents Kbuild $kerneldir/build |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 268 | cp -a --parents arch/mips/kernel/syscalls/*.sh $kerneldir/build 2>/dev/null || : |
| 269 | cp -a --parents arch/mips/kernel/syscalls/*.tbl $kerneldir/build 2>/dev/null || : |
| 270 | cp -a --parents arch/mips/tools/elf-entry.c $kerneldir/build 2>/dev/null || : |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 271 | fi |
| 272 | |
| 273 | # required to build scripts/selinux/genheaders/genheaders |
| 274 | cp -a --parents security/selinux/include/* $kerneldir/build/ |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 275 | |
| 276 | # copy any localversion files |
| 277 | cp -a localversion* $kerneldir/build/ 2>/dev/null || : |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 278 | ) |
| 279 | |
| 280 | # Make sure the Makefile and version.h have a matching timestamp so that |
| 281 | # external modules can be built |
| 282 | touch -r $kerneldir/build/Makefile $kerneldir/build/include/generated/uapi/linux/version.h |
| 283 | |
| 284 | # Copy .config to include/config/auto.conf so "make prepare" is unnecessary. |
| 285 | cp $kerneldir/build/.config $kerneldir/build/include/config/auto.conf |
| 286 | |
Andrew Geissler | b7d2861 | 2020-07-24 16:15:54 -0500 | [diff] [blame] | 287 | # make sure these are at least as old as the .config, or rebuilds will trigger |
| 288 | touch -r $kerneldir/build/.config $kerneldir/build/include/generated/autoconf.h 2>/dev/null || : |
| 289 | touch -r $kerneldir/build/.config $kerneldir/build/include/config/auto.conf* 2>/dev/null || : |
| 290 | |
| 291 | if [ -e "$kerneldir/build/include/config/auto.conf.cmd" ]; then |
Andrew Geissler | 635e0e4 | 2020-08-21 15:58:33 -0500 | [diff] [blame] | 292 | sed -i 's/ifneq "$(CC)" ".*-linux-.*gcc.*$/ifneq "$(CC)" "gcc"/' "$kerneldir/build/include/config/auto.conf.cmd" |
| 293 | 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] | 294 | 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] | 295 | 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] | 296 | if [ "${ARCH}" = "powerpc" ]; then |
| 297 | sed -i 's/ifneq "$(NM)" ".*-linux-.*nm.*$/ifneq "$(NM)" "nm --synthetic"/' "$kerneldir/build/include/config/auto.conf.cmd" |
| 298 | else |
| 299 | sed -i 's/ifneq "$(NM)" ".*-linux-.*nm.*$/ifneq "$(NM)" "nm"/' "$kerneldir/build/include/config/auto.conf.cmd" |
| 300 | fi |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 301 | sed -i 's/ifneq "$(HOSTCXX)" ".*$/ifneq "$(HOSTCXX)" "g++"/' "$kerneldir/build/include/config/auto.conf.cmd" |
| 302 | 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] | 303 | sed -i 's/ifneq "$(CC_VERSION_TEXT)".*\(gcc.*\)"/ifneq "$(CC_VERSION_TEXT)" "\1"/' "$kerneldir/build/include/config/auto.conf.cmd" |
| 304 | 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] | 305 | # we don't build against the defconfig, so make sure it isn't the trigger for syncconfig |
| 306 | 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] | 307 | fi |
| 308 | |
Brad Bishop | 79641f2 | 2019-09-10 07:20:22 -0400 | [diff] [blame] | 309 | # make the scripts python3 safe. We won't be running these, and if they are |
| 310 | # left as /usr/bin/python rootfs assembly will fail, since we only have python3 |
| 311 | # in the RDEPENDS (and the python3 package does not include /usr/bin/python) |
| 312 | for ss in $(find $kerneldir/build/scripts -type f -name '*'); do |
| 313 | sed -i 's,/usr/bin/python2,/usr/bin/env python3,' "$ss" |
| 314 | sed -i 's,/usr/bin/env python2,/usr/bin/env python3,' "$ss" |
| 315 | sed -i 's,/usr/bin/python,/usr/bin/env python3,' "$ss" |
| 316 | done |
| 317 | |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 318 | chown -R root:root ${D} |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 319 | } |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 320 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 321 | # Ensure we don't race against "make scripts" during cpio |
| 322 | do_install[lockfiles] = "${TMPDIR}/kernel-scripts.lock" |
| 323 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 324 | FILES:${PN} = "${KERNEL_BUILD_ROOT} ${KERNEL_SRC_PATH}" |
| 325 | FILES:${PN}-dbg += "${KERNEL_BUILD_ROOT}*/build/scripts/*/.debug/*" |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 326 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 327 | RDEPENDS:${PN} = "bc python3 flex bison ${TCLIBC}-utils" |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 328 | # 4.15+ needs these next two RDEPENDS |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 329 | RDEPENDS:${PN} += "openssl-dev util-linux" |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 330 | # and x86 needs a bit more for 4.15+ |
Andrew Geissler | d159c7f | 2021-09-02 21:05:58 -0500 | [diff] [blame] | 331 | RDEPENDS:${PN} += "${@bb.utils.contains('ARCH', 'x86', 'elfutils-dev', '', d)}" |
Andrew Geissler | 635e0e4 | 2020-08-21 15:58:33 -0500 | [diff] [blame] | 332 | # 5.8+ needs gcc-plugins libmpc-dev |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 333 | RDEPENDS:${PN} += "gcc-plugins libmpc-dev" |
Andrew Geissler | 5f35090 | 2021-07-23 13:09:54 -0400 | [diff] [blame] | 334 | # 5.13+ needs awk for arm64 |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 335 | RDEPENDS:${PN}:append:aarch64 = " gawk" |
Andrew Geissler | 5f35090 | 2021-07-23 13:09:54 -0400 | [diff] [blame] | 336 | # 5.13+ needs grep for powerpc |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 337 | RDEPENDS:${PN}:append:powerpc = " grep" |