Message ID | 20231206113312.93461-1-felix.moessbauer@siemens.com |
---|---|
State | Accepted, archived |
Headers | show |
Series | [1/1] add support for non-default modules dir in linux-module | expand |
On 06.12.23 19:33, Felix Moessbauer wrote: > 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 \ Looks good to me. Thanks, Jan
On Wed, 2023-12-06 at 19:33 +0800, 'Felix Moessbauer' via isar-users wrote: > 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(-) Applied to next, thanks.
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 \
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(-)