Hello Richard, Thank you for your precious feedback. In fact, "makefile-getvar" script is minimalistic and it reads only variables defined directly in the Makefile and does not retrieve the complete Make variable database. For example, in "cryptodev-module" out-of-tree module Makefile, "M" was defined through "KERNEL_MAKE_OPTS" variable:
In Makefile: ... KERNEL_MAKE_OPTS := -C $(KERNEL_DIR) M=$(CURDIR) ... modules_install: $(MAKE) $(KERNEL_MAKE_OPTS) modules_install ... In this case, "cryptodev-module" can read the "KERNEL_MAKE_OPTS" variable but can not read the "M" variable. Therefore, I think it's a good idea to follow your suggestion and move the Python function to "meta/lib/oe". BR, Anis On Wed, Aug 26, 2026 at 10:34 AM Richard Purdie < [email protected]> wrote: > On Tue, 2026-08-25 at 22:49 +0200, Anis Bougrine wrote: > > Fixes [YOCTO #12927] > > > > Out-of-tree module Makefiles invoke the kernel Makefile by appending > > the M= (the module directory) variable to the MAKEFLAGS. > > However, they usually do not provide a modules_sign target. Therefore, > > the kernel modules_sign target has to be invoked manually after > retrieving > > M= variable from package source code Makefile. > > > > This function retrieves the M= variable from an external module Makefile. > > > > Reported-by: Ross Burton <[email protected]> > > Signed-off-by: Anis Bougrine <[email protected]> > > --- > > .../kernel-module-split.bbclass | 21 +++++++++++++++++++ > > 1 file changed, 21 insertions(+) > > > > diff --git a/meta/classes-recipe/kernel-module-split.bbclass > b/meta/classes-recipe/kernel-module-split.bbclass > > index ab2f0d1c37..bde7cd02dd 100644 > > --- a/meta/classes-recipe/kernel-module-split.bbclass > > +++ b/meta/classes-recipe/kernel-module-split.bbclass > > @@ -42,6 +42,27 @@ KERNEL_MODULE_PACKAGE_PREFIX ?= "" > > KERNEL_MODULE_PACKAGE_SUFFIX ?= "-${KERNEL_VERSION}" > > KERNEL_MODULE_PROVIDE_VIRTUAL ?= "1" > > > > +def get_ext_mod(d): > > + """ > > + Extract the resolved Kbuild M= variable from an out of tree module > Makefile variable database. > > + """ > > + import re > > + import bb.process > > + > > + try: > > + output = bb.process.run( > > + "make -C %s --dry-run --print-data-base" % d.getVar("B") > > + )[0] > > + except bb.process.ExecutionError: > > + return d.getVar("S") > > + > > + for line in output.splitlines(): > > + m = re.match(r'^M\s*=\s*(.*)$', line) > > + if m: > > + return m.group(1).strip() > > + > > + return d.getVar("S") > > + > > python split_kernel_module_packages () { > > import re > > > > Sorry, a couple of more things. I'm not sure if it helps but there is a > scripts/makefile-getvar which may be a simpler way to do this? It was > created for this kind of usage. > > Also, we're aiming to move python functions into meta/lib/oe, probably > kernel.py in this case so new functions should really go in there. > > Cheers, > > Richard >
-=-=-=-=-=-=-=-=-=-=-=- Links: You receive all messages sent to this group. View/Reply Online (#244390): https://lists.openembedded.org/g/openembedded-core/message/244390 Mute This Topic: https://lists.openembedded.org/mt/120927789/21656 Group Owner: [email protected] Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [[email protected]] -=-=-=-=-=-=-=-=-=-=-=-
