blob: 6764598d488323881ed4181bee606ace0a9df2c9 [file] [log] [blame]
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001SUMMARY = "Linux kernel Development Source"
2DESCRIPTION = "Development source linux kernel. When built, this recipe packages the \
3source of the preferred virtual/kernel provider and makes it available for full kernel \
4development or external module builds"
5
6SECTION = "kernel"
7
Andrew Geissler7e0e3c02022-02-25 20:34:39 +00008LICENSE = "GPL-2.0-only"
Patrick Williamsc124f4f2015-09-15 14:41:29 -05009
10inherit linux-kernel-base
11
12# Whilst not a module, this ensures we don't get multilib extended (which would make no sense)
13inherit 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.
18do_install[depends] += "virtual/kernel:do_shared_workdir"
19# Need the source, not just the output of populate_sysroot
20do_install[depends] += "virtual/kernel:do_install"
21
22# There's nothing to do here, except install the source where we can package it
23do_fetch[noexec] = "1"
24do_unpack[noexec] = "1"
25do_patch[noexec] = "1"
26do_configure[noexec] = "1"
27do_compile[noexec] = "1"
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080028deltask do_populate_sysroot
Patrick Williamsc124f4f2015-09-15 14:41:29 -050029
Patrick Williamsc124f4f2015-09-15 14:41:29 -050030S = "${STAGING_KERNEL_DIR}"
31B = "${STAGING_KERNEL_BUILDDIR}"
32
Patrick Williamsc124f4f2015-09-15 14:41:29 -050033PACKAGE_ARCH = "${MACHINE_ARCH}"
34
Brad Bishop19323692019-04-05 15:28:33 -040035KERNEL_BUILD_ROOT="${nonarch_base_libdir}/modules/"
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080036
Patrick Williamsc124f4f2015-09-15 14:41:29 -050037do_install() {
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080038 kerneldir=${D}${KERNEL_BUILD_ROOT}${KERNEL_VERSION}
39 install -d $kerneldir
Patrick Williamsc124f4f2015-09-15 14:41:29 -050040
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080041 # create the directory structure
42 rm -f $kerneldir/build
43 rm -f $kerneldir/source
44 mkdir -p $kerneldir/build
Patrick Williamsc124f4f2015-09-15 14:41:29 -050045
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080046 # 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 Geissler595f6302022-01-24 19:11:47 +000051 ln -rs ${D}${KERNEL_BUILD_ROOT}${KERNEL_VERSION}/source kernel
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080052 )
Patrick Williamsc124f4f2015-09-15 14:41:29 -050053
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080054 # for on target purposes, we unify build and source
55 (
56 cd $kerneldir
57 ln -s build source
58 )
Patrick Williamsc124f4f2015-09-15 14:41:29 -050059
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080060 # 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 Bishop316dfdd2018-06-25 12:45:53 -040066
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080067 # then drop all but the needed Makefiles/Kconfig files
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080068 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
Andrew Geissler9aee5002022-03-30 16:27:02 +000075 if [ -s Module.symvers ]; then
76 cp Module.symvers $kerneldir/build
77 fi
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080078 cp System.map* $kerneldir/build
79 if [ -s Module.markers ]; then
80 cp Module.markers $kerneldir/build
81 fi
82
Andrew Geissler82c905d2020-04-13 13:39:40 -050083 cp -a .config $kerneldir/build
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080084
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
90
Andrew Geissler6ce62a22020-11-30 19:58:47 -060091 # 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 || :
96
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080097 if [ -d arch/${ARCH}/scripts ]; then
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
103
104 rm -f $kerneldir/build/scripts/*.o
105 rm -f $kerneldir/build/scripts/*/*.o
106
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/
111 fi
112 fi
113
Andrew Geissler595f6302022-01-24 19:11:47 +0000114 if [ "${ARCH}" = "arm64" -o "${ARCH}" = "riscv" ]; then
Patrick Williams03907ee2022-05-01 06:28:52 -0500115 if [ -e arch/${ARCH}/kernel/vdso/vdso.lds ]; then
116 cp -a --parents arch/${ARCH}/kernel/vdso/vdso.lds $kerneldir/build/
117 fi
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800118 fi
Andrew Geissler5f350902021-07-23 13:09:54 -0400119 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 || :
Patrick Williams92b42cb2022-09-03 06:53:57 -0500122 # v5.19+
123 cp -a --parents arch/powerpc/kernel/vdso/vdso*.lds $kerneldir/build 2>/dev/null || :
Andrew Geissler5f350902021-07-23 13:09:54 -0400124 fi
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800125
126 cp -a include $kerneldir/build/include
Andrew Geisslerb7d28612020-07-24 16:15:54 -0500127
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 || :
Andrew Geissler6ce62a22020-11-30 19:58:47 -0600132
Andrew Geissler615f2f12022-07-15 14:00:58 -0500133 if [ -e $kerneldir/include/generated/.vdso-offsets.h.cmd ] ||
134 [ -e $kerneldir/build/include/generated/.vdso-offsets.h.cmd ] ||
135 [ -e $kerneldir/build/include/generated/.vdso32-offsets.h.cmd ] ; then
136 rm -f $kerneldir/include/generated/.vdso-offsets.h.cmd
137 rm -f $kerneldir/build/include/generated/.vdso-offsets.h.cmd
138 rm -f $kerneldir/build/include/generated/.vdso32-offsets.h.cmd
Andrew Geissler6ce62a22020-11-30 19:58:47 -0600139 fi
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800140 )
141
142 # now grab the chunks from the source tree that we need
143 (
144 cd ${S}
145
146 cp -a scripts $kerneldir/build
147
Andrew Geissler517393d2023-01-13 08:55:19 -0600148 # for v6.1+ (otherwise we are missing multiple default targets)
149 cp -a --parents Kbuild $kerneldir/build 2>/dev/null || :
150
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800151 # if our build dir had objtool, it will also be rebuilt on target, so
152 # we copy what is required for that build
153 if [ -f ${B}/tools/objtool/objtool ]; then
154 # these are a few files associated with objtool, since we'll need to
155 # rebuild it
156 cp -a --parents tools/build/Build.include $kerneldir/build/
157 cp -a --parents tools/build/Build $kerneldir/build/
158 cp -a --parents tools/build/fixdep.c $kerneldir/build/
159 cp -a --parents tools/scripts/utilities.mak $kerneldir/build/
160
161 # extra files, just in case
162 cp -a --parents tools/objtool/* $kerneldir/build/
Andrew Geissler82c905d2020-04-13 13:39:40 -0500163 cp -a --parents tools/lib/* $kerneldir/build/
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800164 cp -a --parents tools/lib/subcmd/* $kerneldir/build/
165
166 cp -a --parents tools/include/* $kerneldir/build/
Andrew Geissler82c905d2020-04-13 13:39:40 -0500167
168 cp -a --parents $(find tools/arch/${ARCH}/ -type f) $kerneldir/build/
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800169 fi
170
171 if [ "${ARCH}" = "arm64" ]; then
172 # arch/arm64/include/asm/xen references arch/arm
173 cp -a --parents arch/arm/include/asm/xen $kerneldir/build/
174 # arch/arm64/include/asm/opcodes.h references arch/arm
175 cp -a --parents arch/arm/include/asm/opcodes.h $kerneldir/build/
176
Andrew Geissler517393d2023-01-13 08:55:19 -0600177 # v6.1+
178 cp -a --parents arch/arm64/kernel/asm-offsets.c $kerneldir/build/
179
Brad Bishop79641f22019-09-10 07:20:22 -0400180 cp -a --parents arch/arm64/kernel/vdso/*gettimeofday.* $kerneldir/build/
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800181 cp -a --parents arch/arm64/kernel/vdso/sigreturn.S $kerneldir/build/
182 cp -a --parents arch/arm64/kernel/vdso/note.S $kerneldir/build/
183 cp -a --parents arch/arm64/kernel/vdso/gen_vdso_offsets.sh $kerneldir/build/
184
Andrew Geissler82c905d2020-04-13 13:39:40 -0500185 cp -a --parents arch/arm64/kernel/module.lds $kerneldir/build/ 2>/dev/null || :
Andrew Geissler5f350902021-07-23 13:09:54 -0400186
187 # 5.13+ needs these tools
188 cp -a --parents arch/arm64/tools/gen-cpucaps.awk $kerneldir/build/ 2>/dev/null || :
189 cp -a --parents arch/arm64/tools/cpucaps $kerneldir/build/ 2>/dev/null || :
190
Patrick Williams92b42cb2022-09-03 06:53:57 -0500191 # 5.19+
192 cp -a --parents arch/arm64/tools/gen-sysreg.awk $kerneldir/build/ 2>/dev/null || :
193 cp -a --parents arch/arm64/tools/sysreg $kerneldir/build/ 2>/dev/null || :
194
Andrew Geissler5f350902021-07-23 13:09:54 -0400195 if [ -e $kerneldir/build/arch/arm64/tools/gen-cpucaps.awk ]; then
196 sed -i -e "s,#!.*awk.*,#!${USRBINPATH}/env awk," $kerneldir/build/arch/arm64/tools/gen-cpucaps.awk
197 fi
Patrick Williams92b42cb2022-09-03 06:53:57 -0500198 if [ -e $kerneldir/build/arch/arm64/tools/gen-sysreg.awk ]; then
199 sed -i -e "s,#!.*awk.*,#!${USRBINPATH}/env awk," $kerneldir/build/arch/arm64/tools/gen-sysreg.awk
200 fi
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800201 fi
202
Brad Bishop19323692019-04-05 15:28:33 -0400203 if [ "${ARCH}" = "powerpc" ]; then
204 # 5.0 needs these files, but don't error if they aren't present in the source
205 cp -a --parents arch/${ARCH}/kernel/syscalls/syscall.tbl $kerneldir/build/ 2>/dev/null || :
206 cp -a --parents arch/${ARCH}/kernel/syscalls/syscalltbl.sh $kerneldir/build/ 2>/dev/null || :
207 cp -a --parents arch/${ARCH}/kernel/syscalls/syscallhdr.sh $kerneldir/build/ 2>/dev/null || :
Andrew Geissler5f350902021-07-23 13:09:54 -0400208 cp -a --parents arch/${ARCH}/kernel/vdso32/* $kerneldir/build/ 2>/dev/null || :
209 cp -a --parents arch/${ARCH}/kernel/vdso64/* $kerneldir/build/ 2>/dev/null || :
Patrick Williams92b42cb2022-09-03 06:53:57 -0500210
211 # v5.19+
212 cp -a --parents arch/powerpc/kernel/vdso/*.S $kerneldir/build 2>/dev/null || :
213 cp -a --parents arch/powerpc/kernel/vdso/*gettimeofday.* $kerneldir/build 2>/dev/null || :
214 cp -a --parents arch/powerpc/kernel/vdso/gen_vdso*_offsets.sh $kerneldir/build/ 2>/dev/null || :
Andrew Geissler517393d2023-01-13 08:55:19 -0600215
216 # v6,1+
217 cp -a --parents arch/powerpc/kernel/asm-offsets.c $kerneldir/build/ 2>/dev/null || :
Andrew Geissler6aa7eec2023-03-03 12:41:14 -0600218 cp -a --parents arch/powerpc/kernel/head_booke.h $kerneldir/build/ 2>/dev/null || :
Brad Bishop19323692019-04-05 15:28:33 -0400219 fi
Andrew Geissler595f6302022-01-24 19:11:47 +0000220 if [ "${ARCH}" = "riscv" ]; then
221 cp -a --parents arch/riscv/kernel/vdso/*gettimeofday.* $kerneldir/build/
222 cp -a --parents arch/riscv/kernel/vdso/note.S $kerneldir/build/
Patrick Williams03907ee2022-05-01 06:28:52 -0500223 if [ -e arch/riscv/kernel/vdso/gen_vdso_offsets.sh ]; then
224 cp -a --parents arch/riscv/kernel/vdso/gen_vdso_offsets.sh $kerneldir/build/
225 fi
Andrew Geissler595f6302022-01-24 19:11:47 +0000226 cp -a --parents arch/riscv/kernel/vdso/* $kerneldir/build/ 2>/dev/null || :
227 fi
Brad Bishop19323692019-04-05 15:28:33 -0400228
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800229 # include the machine specific headers for ARM variants, if available.
230 if [ "${ARCH}" = "arm" ]; then
231 cp -a --parents arch/${ARCH}/mach-*/include $kerneldir/build/
232
233 # include a few files for 'make prepare'
234 cp -a --parents arch/arm/tools/gen-mach-types $kerneldir/build/
235 cp -a --parents arch/arm/tools/mach-types $kerneldir/build/
Brad Bishop19323692019-04-05 15:28:33 -0400236
Patrick Williams92b42cb2022-09-03 06:53:57 -0500237 # 5.19+
238 cp -a --parents arch/arm/tools/gen-sysreg.awk $kerneldir/build/ 2>/dev/null || :
239
Brad Bishop19323692019-04-05 15:28:33 -0400240 # ARM syscall table tools only exist for kernels v4.10 or later
241 SYSCALL_TOOLS=$(find arch/arm/tools -name "syscall*")
242 if [ -n "$SYSCALL_TOOLS" ] ; then
243 cp -a --parents $SYSCALL_TOOLS $kerneldir/build/
244 fi
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800245
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600246 cp -a --parents arch/arm/kernel/module.lds $kerneldir/build/ 2>/dev/null || :
Andrew Geissler517393d2023-01-13 08:55:19 -0600247 # v6.1+
248 cp -a --parents arch/arm/kernel/asm-offsets.c $kerneldir/build/ 2>/dev/null || :
249 cp -a --parents arch/arm/kernel/signal.h $kerneldir/build/ 2>/dev/null || :
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800250 fi
251
252 if [ -d arch/${ARCH}/include ]; then
253 cp -a --parents arch/${ARCH}/include $kerneldir/build/
254 fi
255
256 cp -a include $kerneldir/build
257
Brad Bishop79641f22019-09-10 07:20:22 -0400258 cp -a --parents lib/vdso/* $kerneldir/build/ 2>/dev/null || :
259
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800260 cp -a --parents tools/include/tools/le_byteshift.h $kerneldir/build/
261 cp -a --parents tools/include/tools/be_byteshift.h $kerneldir/build/
262
263 # required for generate missing syscalls prepare phase
Andrew Geissler82c905d2020-04-13 13:39:40 -0500264 cp -a --parents $(find arch/x86 -type f -name "syscall_32.tbl") $kerneldir/build
265 cp -a --parents $(find arch/arm -type f -name "*.tbl") $kerneldir/build 2>/dev/null || :
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800266
267 if [ "${ARCH}" = "x86" ]; then
268 # files for 'make prepare' to succeed with kernel-devel
Andrew Geisslerd159c7f2021-09-02 21:05:58 -0500269 cp -a --parents $(find arch/x86 -type f -name "syscall_32.tbl") $kerneldir/build/ 2>/dev/null || :
270 cp -a --parents $(find arch/x86 -type f -name "syscalltbl.sh") $kerneldir/build/ 2>/dev/null || :
271 cp -a --parents $(find arch/x86 -type f -name "syscallhdr.sh") $kerneldir/build/ 2>/dev/null || :
272 cp -a --parents $(find arch/x86 -type f -name "syscall_64.tbl") $kerneldir/build/ 2>/dev/null || :
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800273 cp -a --parents arch/x86/tools/relocs_32.c $kerneldir/build/
274 cp -a --parents arch/x86/tools/relocs_64.c $kerneldir/build/
275 cp -a --parents arch/x86/tools/relocs.c $kerneldir/build/
276 cp -a --parents arch/x86/tools/relocs_common.c $kerneldir/build/
277 cp -a --parents arch/x86/tools/relocs.h $kerneldir/build/
Andrew Geissler82c905d2020-04-13 13:39:40 -0500278 cp -a --parents arch/x86/tools/gen-insn-attr-x86.awk $kerneldir/build/ 2>/dev/null || :
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800279 cp -a --parents arch/x86/purgatory/purgatory.c $kerneldir/build/
280
281 # 4.18 + have unified the purgatory files, so we ignore any errors if
282 # these files are not present
283 cp -a --parents arch/x86/purgatory/sha256.h $kerneldir/build/ 2>/dev/null || :
284 cp -a --parents arch/x86/purgatory/sha256.c $kerneldir/build/ 2>/dev/null || :
285
286 cp -a --parents arch/x86/purgatory/stack.S $kerneldir/build/
Brad Bishopc68388fc2019-08-26 01:33:31 -0400287 cp -a --parents arch/x86/purgatory/string.c $kerneldir/build/ 2>/dev/null || :
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800288 cp -a --parents arch/x86/purgatory/setup-x86_64.S $kerneldir/build/
289 cp -a --parents arch/x86/purgatory/entry64.S $kerneldir/build/
290 cp -a --parents arch/x86/boot/string.h $kerneldir/build/
291 cp -a --parents arch/x86/boot/string.c $kerneldir/build/
Brad Bishopc68388fc2019-08-26 01:33:31 -0400292 cp -a --parents arch/x86/boot/compressed/string.c $kerneldir/build/ 2>/dev/null || :
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800293 cp -a --parents arch/x86/boot/ctype.h $kerneldir/build/
Andrew Geissler82c905d2020-04-13 13:39:40 -0500294
295 # objtool requires these files
296 cp -a --parents arch/x86/lib/inat.c $kerneldir/build/ 2>/dev/null || :
297 cp -a --parents arch/x86/lib/insn.c $kerneldir/build/ 2>/dev/null || :
Andrew Geissler517393d2023-01-13 08:55:19 -0600298
299 # v6.1+
300 cp -a --parents arch/x86/kernel/asm-offsets* $kerneldir/build || :
301 # for capabilities.h, vmx.h
302 cp -a --parents arch/x86/kvm/vmx/*.h $kerneldir/build || :
303 # for lapic.h, hyperv.h ....
304 cp -a --parents arch/x86/kvm/*.h $kerneldir/build || :
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800305 fi
306
Andrew Geissler517393d2023-01-13 08:55:19 -0600307 # moved from arch/mips to all arches for v6.1+
308 cp -a --parents kernel/time/timeconst.bc $kerneldir/build 2>/dev/null || :
309 cp -a --parents kernel/bounds.c $kerneldir/build 2>/dev/null || :
310
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800311 if [ "${ARCH}" = "mips" ]; then
312 cp -a --parents arch/mips/Kbuild.platforms $kerneldir/build/
313 cp --parents $(find -type f -name "Platform") $kerneldir/build
314 cp --parents arch/mips/boot/tools/relocs* $kerneldir/build
315 cp -a --parents arch/mips/kernel/asm-offsets.c $kerneldir/build
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800316 cp -a --parents Kbuild $kerneldir/build
Brad Bishop19323692019-04-05 15:28:33 -0400317 cp -a --parents arch/mips/kernel/syscalls/*.sh $kerneldir/build 2>/dev/null || :
318 cp -a --parents arch/mips/kernel/syscalls/*.tbl $kerneldir/build 2>/dev/null || :
319 cp -a --parents arch/mips/tools/elf-entry.c $kerneldir/build 2>/dev/null || :
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800320 fi
321
322 # required to build scripts/selinux/genheaders/genheaders
323 cp -a --parents security/selinux/include/* $kerneldir/build/
Brad Bishopc342db32019-05-15 21:57:59 -0400324
325 # copy any localversion files
326 cp -a localversion* $kerneldir/build/ 2>/dev/null || :
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800327 )
328
329 # Make sure the Makefile and version.h have a matching timestamp so that
330 # external modules can be built
331 touch -r $kerneldir/build/Makefile $kerneldir/build/include/generated/uapi/linux/version.h
332
Andrew Geisslerfc113ea2023-03-31 09:59:46 -0500333 # This fixes a warning that the compilers don't match when building a module
334 # Change: CONFIG_CC_VERSION_TEXT="x86_64-poky-linux-gcc (GCC) 12.2.0" to "gcc (GCC) 12.2.0"
335 # #define CONFIG_CC_VERSION_TEXT "x86_64-poky-linux-gcc (GCC) 12.2.0" to "gcc (GCC) 12.2.0"
336 sed -i 's/CONFIG_CC_VERSION_TEXT=".*\(gcc.*\)"/CONFIG_CC_VERSION_TEXT="\1"/' "$kerneldir/build/.config"
337 sed -i 's/#define CONFIG_CC_VERSION_TEXT ".*\(gcc.*\)"/#define CONFIG_CC_VERSION_TEXT "\1"/' $kerneldir/build/include/generated/autoconf.h
338 sed -i 's/CONFIG_CC_VERSION_TEXT=".*\(gcc.*\)"/CONFIG_CC_VERSION_TEXT="\1"/' $kerneldir/build/include/config/auto.conf
339
Andrew Geisslerb7d28612020-07-24 16:15:54 -0500340 # make sure these are at least as old as the .config, or rebuilds will trigger
341 touch -r $kerneldir/build/.config $kerneldir/build/include/generated/autoconf.h 2>/dev/null || :
342 touch -r $kerneldir/build/.config $kerneldir/build/include/config/auto.conf* 2>/dev/null || :
343
344 if [ -e "$kerneldir/build/include/config/auto.conf.cmd" ]; then
Andrew Geissler635e0e42020-08-21 15:58:33 -0500345 sed -i 's/ifneq "$(CC)" ".*-linux-.*gcc.*$/ifneq "$(CC)" "gcc"/' "$kerneldir/build/include/config/auto.conf.cmd"
346 sed -i 's/ifneq "$(LD)" ".*-linux-.*ld.bfd.*$/ifneq "$(LD)" "ld"/' "$kerneldir/build/include/config/auto.conf.cmd"
Andrew Geissler95ac1b82021-03-31 14:34:31 -0500347 sed -i 's/ifneq "$(AR)" ".*-linux-.*ar.*$/ifneq "$(AR)" "ar"/' "$kerneldir/build/include/config/auto.conf.cmd"
William A. Kennington IIIac69b482021-06-02 12:28:27 -0700348 sed -i 's/ifneq "$(OBJCOPY)" ".*-linux-.*objcopy.*$/ifneq "$(OBJCOPY)" "objcopy"/' "$kerneldir/build/include/config/auto.conf.cmd"
Andrew Geissler5f350902021-07-23 13:09:54 -0400349 if [ "${ARCH}" = "powerpc" ]; then
350 sed -i 's/ifneq "$(NM)" ".*-linux-.*nm.*$/ifneq "$(NM)" "nm --synthetic"/' "$kerneldir/build/include/config/auto.conf.cmd"
351 else
352 sed -i 's/ifneq "$(NM)" ".*-linux-.*nm.*$/ifneq "$(NM)" "nm"/' "$kerneldir/build/include/config/auto.conf.cmd"
353 fi
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500354 sed -i 's/ifneq "$(HOSTCXX)" ".*$/ifneq "$(HOSTCXX)" "g++"/' "$kerneldir/build/include/config/auto.conf.cmd"
355 sed -i 's/ifneq "$(HOSTCC)" ".*$/ifneq "$(HOSTCC)" "gcc"/' "$kerneldir/build/include/config/auto.conf.cmd"
Andrew Geisslerb7d28612020-07-24 16:15:54 -0500356 sed -i 's/ifneq "$(CC_VERSION_TEXT)".*\(gcc.*\)"/ifneq "$(CC_VERSION_TEXT)" "\1"/' "$kerneldir/build/include/config/auto.conf.cmd"
357 sed -i 's/ifneq "$(srctree)" ".*"/ifneq "$(srctree)" "."/' "$kerneldir/build/include/config/auto.conf.cmd"
Andrew Geissler635e0e42020-08-21 15:58:33 -0500358 # we don't build against the defconfig, so make sure it isn't the trigger for syncconfig
359 sed -i 's/ifneq "$(KBUILD_DEFCONFIG)".*"\(.*\)"/ifneq "\1" "\1"/' "$kerneldir/build/include/config/auto.conf.cmd"
Andrew Geisslerb7d28612020-07-24 16:15:54 -0500360 fi
361
Brad Bishop79641f22019-09-10 07:20:22 -0400362 # make the scripts python3 safe. We won't be running these, and if they are
363 # left as /usr/bin/python rootfs assembly will fail, since we only have python3
364 # in the RDEPENDS (and the python3 package does not include /usr/bin/python)
365 for ss in $(find $kerneldir/build/scripts -type f -name '*'); do
366 sed -i 's,/usr/bin/python2,/usr/bin/env python3,' "$ss"
367 sed -i 's,/usr/bin/env python2,/usr/bin/env python3,' "$ss"
368 sed -i 's,/usr/bin/python,/usr/bin/env python3,' "$ss"
369 done
370
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800371 chown -R root:root ${D}
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500372}
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800373
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500374# Ensure we don't race against "make scripts" during cpio
375do_install[lockfiles] = "${TMPDIR}/kernel-scripts.lock"
376
Patrick Williams213cb262021-08-07 19:21:33 -0500377FILES:${PN} = "${KERNEL_BUILD_ROOT} ${KERNEL_SRC_PATH}"
378FILES:${PN}-dbg += "${KERNEL_BUILD_ROOT}*/build/scripts/*/.debug/*"
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800379
Patrick Williams8e7b46e2023-05-01 14:19:06 -0500380RDEPENDS:${PN} = "bc python3-core flex bison ${TCLIBC}-utils"
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800381# 4.15+ needs these next two RDEPENDS
Patrick Williams213cb262021-08-07 19:21:33 -0500382RDEPENDS:${PN} += "openssl-dev util-linux"
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800383# and x86 needs a bit more for 4.15+
Andrew Geisslerd159c7f2021-09-02 21:05:58 -0500384RDEPENDS:${PN} += "${@bb.utils.contains('ARCH', 'x86', 'elfutils-dev', '', d)}"
Andrew Geisslerfc113ea2023-03-31 09:59:46 -0500385# powerpc needs elfutils on 6.3+
386RDEPENDS:${PN} += "${@bb.utils.contains('ARCH', 'powerpc', 'elfutils-dev', '', d)}"
Andrew Geissler635e0e42020-08-21 15:58:33 -0500387# 5.8+ needs gcc-plugins libmpc-dev
Patrick Williams213cb262021-08-07 19:21:33 -0500388RDEPENDS:${PN} += "gcc-plugins libmpc-dev"
Andrew Geissler5f350902021-07-23 13:09:54 -0400389# 5.13+ needs awk for arm64
Patrick Williams213cb262021-08-07 19:21:33 -0500390RDEPENDS:${PN}:append:aarch64 = " gawk"
Andrew Geissler5f350902021-07-23 13:09:54 -0400391# 5.13+ needs grep for powerpc
Patrick Williams213cb262021-08-07 19:21:33 -0500392RDEPENDS:${PN}:append:powerpc = " grep"