public inbox for isar-users@googlegroups.com
 help / color / mirror / Atom feed
From: Felix Moessbauer <felix.moessbauer@siemens.com>
To: isar-users@googlegroups.com
Cc: jan.kiszka@siemens.com, Felix Moessbauer <felix.moessbauer@siemens.com>
Subject: [PATCH 1/1] add support for non-default modules dir in linux-module
Date: Wed,  6 Dec 2023 19:33:12 +0800	[thread overview]
Message-ID: <20231206113312.93461-1-felix.moessbauer@siemens.com> (raw)

When building a custom kernel module, the `KBuild` file might be located in
a subdirectory. To support this use-case, set `MODULE_DIR=$(PWD)/subdir` in
the module build recipe.

Previously some sed replacements of the generated rules file where
needed to support this, in case the modules dir referenced files in
parent directories.

Signed-off-by: Felix Moessbauer <felix.moessbauer@siemens.com>
---
 RECIPE-API-CHANGELOG.md                                  | 6 ++++++
 meta/recipes-kernel/linux-module/files/debian/rules.tmpl | 6 +++---
 meta/recipes-kernel/linux-module/module.inc              | 3 +++
 3 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/RECIPE-API-CHANGELOG.md b/RECIPE-API-CHANGELOG.md
index 9d1fa540..bea12871 100644
--- a/RECIPE-API-CHANGELOG.md
+++ b/RECIPE-API-CHANGELOG.md
@@ -560,3 +560,9 @@ Default value is '-I' which sets filter to:
 Use `IMAGER_INSTALL:wic` instead of `WIC_IMAGER_INSTALL`. The latter is still
 supported, but a warning is issued when it is used. Future versions will drop
 `WIC_IMAGER_INSTALL` completely.
+
+### Add MODULE_DIR to decouple sources dir from modules dir in custom-module
+
+When building a custom kernel module, the `KBuild` file might be located in
+a subdirectory. To support this use-case, set `MODULE_DIR=$(PWD)/subdir` in
+the module build recipe.
diff --git a/meta/recipes-kernel/linux-module/files/debian/rules.tmpl b/meta/recipes-kernel/linux-module/files/debian/rules.tmpl
index 7d950e38..bc4e09cb 100755
--- a/meta/recipes-kernel/linux-module/files/debian/rules.tmpl
+++ b/meta/recipes-kernel/linux-module/files/debian/rules.tmpl
@@ -46,16 +46,16 @@ KDIR := $(shell dpkg -L $(KERNEL_DEP) | grep "/lib/modules/.*/build")
 endif
 
 override_dh_auto_clean:
-	$(MAKE) -C $(KDIR) M=$(PWD) clean
+	$(MAKE) -C $(KDIR) M=${MODULE_DIR} clean
 
 override_dh_auto_build:
-	$(MAKE) -C $(KDIR) M=$(PWD) $(PARALLEL_MAKE) modules
+	$(MAKE) -C $(KDIR) M=${MODULE_DIR} $(PARALLEL_MAKE) modules
 ifneq ($(filter pkg.sign,$(DEB_BUILD_PROFILES)),)
 	find . -name "*.ko" -print -exec $(KDIR)/scripts/sign-file ${SIGNATURE_HASHFN} ${SIGNATURE_KEYFILE} ${SIGNATURE_CERTFILE} {} \;
 endif
 
 override_dh_auto_install:
-	$(MAKE) -C $(KDIR) M=$(PWD) INSTALL_MOD_PATH=$(PWD)/debian/${PN} modules_install
+	$(MAKE) -C $(KDIR) M=${MODULE_DIR} INSTALL_MOD_PATH=$(PWD)/debian/${PN} modules_install
 
 %:
 	CFLAGS= LDFLAGS= dh $@
diff --git a/meta/recipes-kernel/linux-module/module.inc b/meta/recipes-kernel/linux-module/module.inc
index 333c66bc..269da6ae 100644
--- a/meta/recipes-kernel/linux-module/module.inc
+++ b/meta/recipes-kernel/linux-module/module.inc
@@ -10,6 +10,8 @@ FILESPATH:append := ":${FILE_DIRNAME}/files"
 DESCRIPTION ?= "Custom kernel module ${PN}"
 
 KERNEL_NAME ?= ""
+# directory with KBuild file (M=${MODULE_DIR})
+MODULE_DIR ?= "$(PWD)"
 
 PN .= "-${KERNEL_NAME}"
 
@@ -36,6 +38,7 @@ TEMPLATE_VARS += " \
     KERNEL_TYPE \
     KERNEL_IMAGE_PKG \
     KERNEL_HEADERS_PKG \
+    MODULE_DIR \
     DEBIAN_BUILD_DEPENDS \
     SIGNATURE_KEYFILE \
     SIGNATURE_CERTFILE \
-- 
2.39.2


             reply	other threads:[~2023-12-06 11:33 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-06 11:33 Felix Moessbauer [this message]
2023-12-07  0:57 ` Jan Kiszka
2023-12-14  7:14 ` Uladzimir Bely

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231206113312.93461-1-felix.moessbauer@siemens.com \
    --to=felix.moessbauer@siemens.com \
    --cc=isar-users@googlegroups.com \
    --cc=jan.kiszka@siemens.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox