[1/2] linux-module: honor modules Makefile

Message ID 20220826175122.20254-1-henning.schild@siemens.com
State Superseded, archived
Headers show
Series [1/2] linux-module: honor modules Makefile | expand

Commit Message

Henning Schild Aug. 26, 2022, 9:51 a.m. UTC
External modules might have their own appends and target definitions in
their Makefile. All we need to give them is the target name and KDIR,
not dive into KDIR right away.

Signed-off-by: Henning Schild <henning.schild@siemens.com>
---
 meta/recipes-kernel/linux-module/files/debian/rules.tmpl | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Henning Schild Aug. 26, 2022, 9:53 a.m. UTC | #1
After a discussion on
"[PATCH] linux-module: make sure out-of-tree modules win over built-in"
this is now another attempt to fix the issue of module order.

This time we improve Isar to honor the Makefile of such a module, so it
can itself deploy additional files if it wants.

In a second patch we even call the "install" target so such a module
could decide to install additional files in "install" and not in
"modules_install"

Henning

Am Fri, 26 Aug 2022 19:51:21 +0200
schrieb Henning Schild <henning.schild@siemens.com>:

> External modules might have their own appends and target definitions
> in their Makefile. All we need to give them is the target name and
> KDIR, not dive into KDIR right away.
> 
> Signed-off-by: Henning Schild <henning.schild@siemens.com>
> ---
>  meta/recipes-kernel/linux-module/files/debian/rules.tmpl | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/meta/recipes-kernel/linux-module/files/debian/rules.tmpl
> b/meta/recipes-kernel/linux-module/files/debian/rules.tmpl index
> d3bd7dc30f21..0d16186b5ff3 100755 ---
> a/meta/recipes-kernel/linux-module/files/debian/rules.tmpl +++
> b/meta/recipes-kernel/linux-module/files/debian/rules.tmpl @@ -48,13
> +48,13 @@ KDIR := $(shell dpkg -L $(KERNEL_DEP) | grep
> "/lib/modules/.*/build") endif 
>  override_dh_auto_clean:
> -	$(MAKE) -C $(KDIR) M=$(PWD) clean
> +	$(MAKE) KDIR=$(KDIR) clean
>  
>  override_dh_auto_build:
> -	$(MAKE) -C $(KDIR) M=$(PWD) modules
> +	$(MAKE) KDIR=$(KDIR) modules
>  
>  override_dh_auto_install:
> -	$(MAKE) -C $(KDIR) M=$(PWD)
> INSTALL_MOD_PATH=$(PWD)/debian/${PN} modules_install
> +	$(MAKE) KDIR=$(KDIR) INSTALL_MOD_PATH=$(PWD)/debian/${PN}
> modules_install 
>  %:
>  	CFLAGS= LDFLAGS= dh $@ --parallel
Henning Schild Aug. 26, 2022, 10:52 a.m. UTC | #2
I just gave this one to CI to digest. My guess is that it will fail to
build meta-isar/recipes-kernel/example-module because its Makefile is
really just too simplistic.

So that file might need to be updated to become more realistic.

Henning

Am Fri, 26 Aug 2022 19:51:21 +0200
schrieb Henning Schild <henning.schild@siemens.com>:

> External modules might have their own appends and target definitions
> in their Makefile. All we need to give them is the target name and
> KDIR, not dive into KDIR right away.
> 
> Signed-off-by: Henning Schild <henning.schild@siemens.com>
> ---
>  meta/recipes-kernel/linux-module/files/debian/rules.tmpl | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/meta/recipes-kernel/linux-module/files/debian/rules.tmpl
> b/meta/recipes-kernel/linux-module/files/debian/rules.tmpl index
> d3bd7dc30f21..0d16186b5ff3 100755 ---
> a/meta/recipes-kernel/linux-module/files/debian/rules.tmpl +++
> b/meta/recipes-kernel/linux-module/files/debian/rules.tmpl @@ -48,13
> +48,13 @@ KDIR := $(shell dpkg -L $(KERNEL_DEP) | grep
> "/lib/modules/.*/build") endif 
>  override_dh_auto_clean:
> -	$(MAKE) -C $(KDIR) M=$(PWD) clean
> +	$(MAKE) KDIR=$(KDIR) clean
>  
>  override_dh_auto_build:
> -	$(MAKE) -C $(KDIR) M=$(PWD) modules
> +	$(MAKE) KDIR=$(KDIR) modules
>  
>  override_dh_auto_install:
> -	$(MAKE) -C $(KDIR) M=$(PWD)
> INSTALL_MOD_PATH=$(PWD)/debian/${PN} modules_install
> +	$(MAKE) KDIR=$(KDIR) INSTALL_MOD_PATH=$(PWD)/debian/${PN}
> modules_install 
>  %:
>  	CFLAGS= LDFLAGS= dh $@ --parallel
Henning Schild Aug. 27, 2022, 12:56 a.m. UTC | #3
Am Fri, 26 Aug 2022 20:52:36 +0200
schrieb Henning Schild <henning.schild@siemens.com>:

> I just gave this one to CI to digest. My guess is that it will fail to
> build meta-isar/recipes-kernel/example-module because its Makefile is
> really just too simplistic.

Indeed

/usr/bin/make KDIR=/lib/modules/5.10.0-17-amd64/build clean

make[2]: Entering directory '/<<PKGBUILDDIR>>'

make[2]: *** No rule to make target 'clean'.  Stop.
make[2]: Leaving directory '/<<PKGBUILDDIR>>'
make[1]: *** [debian/rules:51: override_dh_auto_clean] Error 2
make[1]: Leaving directory '/<<PKGBUILDDIR>>'

make: *** [debian/rules:61: clean] Error 2

In the end i ran things manually. CI at Ilbers did not finish over
night, not even one of two pipelines. And CI at Siemens has sstate
issues. We should _really_ have only one that is public and powerful.

> So that file might need to be updated to become more realistic.

Will send a v2 with a patch to fix that Makefile of example-module.

Henning

> Henning
> 
> Am Fri, 26 Aug 2022 19:51:21 +0200
> schrieb Henning Schild <henning.schild@siemens.com>:
> 
> > External modules might have their own appends and target definitions
> > in their Makefile. All we need to give them is the target name and
> > KDIR, not dive into KDIR right away.
> > 
> > Signed-off-by: Henning Schild <henning.schild@siemens.com>
> > ---
> >  meta/recipes-kernel/linux-module/files/debian/rules.tmpl | 6 +++---
> >  1 file changed, 3 insertions(+), 3 deletions(-)
> > 
> > diff --git
> > a/meta/recipes-kernel/linux-module/files/debian/rules.tmpl
> > b/meta/recipes-kernel/linux-module/files/debian/rules.tmpl index
> > d3bd7dc30f21..0d16186b5ff3 100755 ---
> > a/meta/recipes-kernel/linux-module/files/debian/rules.tmpl +++
> > b/meta/recipes-kernel/linux-module/files/debian/rules.tmpl @@
> > -48,13 +48,13 @@ KDIR := $(shell dpkg -L $(KERNEL_DEP) | grep
> > "/lib/modules/.*/build") endif override_dh_auto_clean:
> > -	$(MAKE) -C $(KDIR) M=$(PWD) clean
> > +	$(MAKE) KDIR=$(KDIR) clean
> >  
> >  override_dh_auto_build:
> > -	$(MAKE) -C $(KDIR) M=$(PWD) modules
> > +	$(MAKE) KDIR=$(KDIR) modules
> >  
> >  override_dh_auto_install:
> > -	$(MAKE) -C $(KDIR) M=$(PWD)
> > INSTALL_MOD_PATH=$(PWD)/debian/${PN} modules_install
> > +	$(MAKE) KDIR=$(KDIR) INSTALL_MOD_PATH=$(PWD)/debian/${PN}
> > modules_install 
> >  %:
> >  	CFLAGS= LDFLAGS= dh $@ --parallel  
>

Patch

diff --git a/meta/recipes-kernel/linux-module/files/debian/rules.tmpl b/meta/recipes-kernel/linux-module/files/debian/rules.tmpl
index d3bd7dc30f21..0d16186b5ff3 100755
--- a/meta/recipes-kernel/linux-module/files/debian/rules.tmpl
+++ b/meta/recipes-kernel/linux-module/files/debian/rules.tmpl
@@ -48,13 +48,13 @@  KDIR := $(shell dpkg -L $(KERNEL_DEP) | grep "/lib/modules/.*/build")
 endif
 
 override_dh_auto_clean:
-	$(MAKE) -C $(KDIR) M=$(PWD) clean
+	$(MAKE) KDIR=$(KDIR) clean
 
 override_dh_auto_build:
-	$(MAKE) -C $(KDIR) M=$(PWD) modules
+	$(MAKE) KDIR=$(KDIR) modules
 
 override_dh_auto_install:
-	$(MAKE) -C $(KDIR) M=$(PWD) INSTALL_MOD_PATH=$(PWD)/debian/${PN} modules_install
+	$(MAKE) KDIR=$(KDIR) INSTALL_MOD_PATH=$(PWD)/debian/${PN} modules_install
 
 %:
 	CFLAGS= LDFLAGS= dh $@ --parallel