[v2,2/3] linux-module: honor modules Makefile

Message ID 20220827085905.6116-2-henning.schild@siemens.com
State Rejected, archived
Headers show
Series [v2,1/3] example-module: improve Makefile to be more realistic | expand

Commit Message

Henning Schild Aug. 27, 2022, 12:59 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

Jan Kiszka Sept. 1, 2022, 8:08 a.m. UTC | #1
On 27.08.22 10:59, Henning Schild wrote:
> 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.

My observation with external modules makefile having their own rules is
that they generally also have their own KDIR variables. There is no
standard way of telling those pick up the kernel from a standard place
and install it at the standard location.

> 
> 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

This breaks existing users with makefile that are unusable or do not
have own rules. I would refrain from that breakage.

If you have a more complex case than what we support, you can simply
provide your own rules and can then even account for the other
specialties that usually come with such module makefiles.

Same arguing applies to patch 3.

Jan
Henning Schild Sept. 1, 2022, 9:17 a.m. UTC | #2
Am Thu, 1 Sep 2022 18:08:08 +0200
schrieb Jan Kiszka <jan.kiszka@siemens.com>:

> On 27.08.22 10:59, Henning Schild wrote:
> > 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.  
> 
> My observation with external modules makefile having their own rules
> is that they generally also have their own KDIR variables. There is no
> standard way of telling those pick up the kernel from a standard place
> and install it at the standard location.
> 
> > 
> > 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  
> 
> This breaks existing users with makefile that are unusable or do not
> have own rules. I would refrain from that breakage.
> 
> If you have a more complex case than what we support, you can simply
> provide your own rules and can then even account for the other
> specialties that usually come with such module makefiles.
> 
> Same arguing applies to patch 3.

I am not sure i would agree that the example Makefile is indeed valid,
since it does not allow self sustained building with a simple "make
modules_install". But yes for modules with such Makefiles this would be
a breaking change.

Will go and carry the special rules entries downstream, while i still
think Isar should take that and rather make those weirdos carry their
own rules ... accepting a breakage.

But i have no clue how "weird" vs "common" it would be to have such a
super-minimal Makefile. And my case is probably also not "common"
enough to ague for too long.

Henning

> Jan
>
Jan Kiszka Sept. 1, 2022, 11:46 a.m. UTC | #3
On 01.09.22 19:17, Henning Schild wrote:
> Am Thu, 1 Sep 2022 18:08:08 +0200
> schrieb Jan Kiszka <jan.kiszka@siemens.com>:
> 
>> On 27.08.22 10:59, Henning Schild wrote:
>>> 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.  
>>
>> My observation with external modules makefile having their own rules
>> is that they generally also have their own KDIR variables. There is no
>> standard way of telling those pick up the kernel from a standard place
>> and install it at the standard location.
>>
>>>
>>> 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  
>>
>> This breaks existing users with makefile that are unusable or do not
>> have own rules. I would refrain from that breakage.
>>
>> If you have a more complex case than what we support, you can simply
>> provide your own rules and can then even account for the other
>> specialties that usually come with such module makefiles.
>>
>> Same arguing applies to patch 3.
> 
> I am not sure i would agree that the example Makefile is indeed valid,
> since it does not allow self sustained building with a simple "make
> modules_install". But yes for modules with such Makefiles this would be
> a breaking change.
> 
> Will go and carry the special rules entries downstream, while i still
> think Isar should take that and rather make those weirdos carry their
> own rules ... accepting a breakage.
> 
> But i have no clue how "weird" vs "common" it would be to have such a
> super-minimal Makefile. And my case is probably also not "common"
> enough to ague for too long.

Isar implements to official way of writing external module makefiles and
invoking them, see
https://www.kernel.org/doc/html/latest/kbuild/modules.html#command-syntax.
Anything beyond in its generic code would be guesswork about how
makefiles were written, what they expect as input etc.

Jan

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