All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] kbuild: strip the last slash in KBUILD_EXTMOD
@ 2017-02-22 15:08 Wei Yang
  2017-03-11 13:34 ` Masahiro Yamada
  0 siblings, 1 reply; 4+ messages in thread
From: Wei Yang @ 2017-02-22 15:08 UTC (permalink / raw)
  To: mmarek; +Cc: linux-kbuild, linux-kernel, Wei Yang

Current kbuild will build the target again if we run "make M=dir" and "make
M=dir/" by turns, since if_changed will see the prerequisite is changed.
The behavior may confuse the user a little, since actually we are building
the same target and no difference.

According to current implementation in scripts/Makefile.build, the obj
passed to next level is a directory name with last slash stripped. This
patch strips the last slash in KBUILD_EXTMOD which is assigned from "M=".

Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
---
 Makefile | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/Makefile b/Makefile
index b1037774e8e8..db6ed60928ab 100644
--- a/Makefile
+++ b/Makefile
@@ -184,13 +184,15 @@ endif
 # Old syntax make ... SUBDIRS=$PWD is still supported
 # Setting the environment variable KBUILD_EXTMOD take precedence
 ifdef SUBDIRS
-  KBUILD_EXTMOD ?= $(SUBDIRS)
+  __KBUILD_EXTMOD ?= $(SUBDIRS)
 endif
 
 ifeq ("$(origin M)", "command line")
-  KBUILD_EXTMOD := $(M)
+  __KBUILD_EXTMOD := $(M)
 endif
 
+KBUILD_EXTMOD = $(patsubst %/,%,$(__KBUILD_EXTMOD))
+
 # If building an external module we do not care about the all: rule
 # but instead _all depend on modules
 PHONY += all
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] kbuild: strip the last slash in KBUILD_EXTMOD
  2017-02-22 15:08 [PATCH] kbuild: strip the last slash in KBUILD_EXTMOD Wei Yang
@ 2017-03-11 13:34 ` Masahiro Yamada
  2017-03-12 11:56   ` Wei Yang
  0 siblings, 1 reply; 4+ messages in thread
From: Masahiro Yamada @ 2017-03-11 13:34 UTC (permalink / raw)
  To: Wei Yang
  Cc: Michal Marek, Linux Kbuild mailing list, Linux Kernel Mailing List

Hi Wei,


2017-02-23 0:08 GMT+09:00 Wei Yang <richard.weiyang@gmail.com>:
> Current kbuild will build the target again if we run "make M=dir" and "make
> M=dir/" by turns, since if_changed will see the prerequisite is changed.
> The behavior may confuse the user a little, since actually we are building
> the same target and no difference.
>
> According to current implementation in scripts/Makefile.build, the obj
> passed to next level is a directory name with last slash stripped. This
> patch strips the last slash in KBUILD_EXTMOD which is assigned from "M=".
>
> Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
> ---
>  Makefile | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/Makefile b/Makefile
> index b1037774e8e8..db6ed60928ab 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -184,13 +184,15 @@ endif
>  # Old syntax make ... SUBDIRS=$PWD is still supported
>  # Setting the environment variable KBUILD_EXTMOD take precedence
>  ifdef SUBDIRS
> -  KBUILD_EXTMOD ?= $(SUBDIRS)
> +  __KBUILD_EXTMOD ?= $(SUBDIRS)
>  endif
>
>  ifeq ("$(origin M)", "command line")
> -  KBUILD_EXTMOD := $(M)
> +  __KBUILD_EXTMOD := $(M)
>  endif
>
> +KBUILD_EXTMOD = $(patsubst %/,%,$(__KBUILD_EXTMOD))
> +
>  # If building an external module we do not care about the all: rule
>  # but instead _all depend on modules
>  PHONY += all

This patch would break a use-case
where KBUILD_EXTMOD is given as an environment.



Maybe adding the following should be enough?

KBUILD_EXTMOD := $(patsubst %/,%,$(KBUILD_EXTMOD))


-- 
Best Regards
Masahiro Yamada

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] kbuild: strip the last slash in KBUILD_EXTMOD
  2017-03-11 13:34 ` Masahiro Yamada
@ 2017-03-12 11:56   ` Wei Yang
  0 siblings, 0 replies; 4+ messages in thread
From: Wei Yang @ 2017-03-12 11:56 UTC (permalink / raw)
  To: Masahiro Yamada
  Cc: Wei Yang, Michal Marek, Linux Kbuild mailing list,
	Linux Kernel Mailing List

[-- Attachment #1: Type: text/plain, Size: 2213 bytes --]

On Sat, Mar 11, 2017 at 10:34:50PM +0900, Masahiro Yamada wrote:
>Hi Wei,
>
>
>2017-02-23 0:08 GMT+09:00 Wei Yang <richard.weiyang@gmail.com>:
>> Current kbuild will build the target again if we run "make M=dir" and "make
>> M=dir/" by turns, since if_changed will see the prerequisite is changed.
>> The behavior may confuse the user a little, since actually we are building
>> the same target and no difference.
>>
>> According to current implementation in scripts/Makefile.build, the obj
>> passed to next level is a directory name with last slash stripped. This
>> patch strips the last slash in KBUILD_EXTMOD which is assigned from "M=".
>>
>> Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
>> ---
>>  Makefile | 6 ++++--
>>  1 file changed, 4 insertions(+), 2 deletions(-)
>>
>> diff --git a/Makefile b/Makefile
>> index b1037774e8e8..db6ed60928ab 100644
>> --- a/Makefile
>> +++ b/Makefile
>> @@ -184,13 +184,15 @@ endif
>>  # Old syntax make ... SUBDIRS=$PWD is still supported
>>  # Setting the environment variable KBUILD_EXTMOD take precedence
>>  ifdef SUBDIRS
>> -  KBUILD_EXTMOD ?= $(SUBDIRS)
>> +  __KBUILD_EXTMOD ?= $(SUBDIRS)
>>  endif
>>
>>  ifeq ("$(origin M)", "command line")
>> -  KBUILD_EXTMOD := $(M)
>> +  __KBUILD_EXTMOD := $(M)
>>  endif
>>
>> +KBUILD_EXTMOD = $(patsubst %/,%,$(__KBUILD_EXTMOD))
>> +
>>  # If building an external module we do not care about the all: rule
>>  # but instead _all depend on modules
>>  PHONY += all
>
>This patch would break a use-case
>where KBUILD_EXTMOD is given as an environment.
>

Hi, Masahiro 

Thanks for your comment.

Got your point, you are right.

>
>
>Maybe adding the following should be enough?
>
>KBUILD_EXTMOD := $(patsubst %/,%,$(KBUILD_EXTMOD))
>

Yep, it looks good.

BTW, I found another interesting thing.

     make M=dir//// 

is also a valid target in kbuild.

Even this is a very rare case, I plan to use this to handle it.

KBUILD_EXTMOD := $(subst $(CURDIR)/,,$(KBUILD_EXTMOD))

This also works for an out tree build.

I would send out v2 soon, hope you like this.

>
>-- 
>Best Regards
>Masahiro Yamada

-- 
Wei Yang
Help you, Help me

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH] kbuild: strip the last slash in KBUILD_EXTMOD
@ 2017-03-12 12:01 Wei Yang
  0 siblings, 0 replies; 4+ messages in thread
From: Wei Yang @ 2017-03-12 12:01 UTC (permalink / raw)
  To: mmarek; +Cc: linux-kbuild, linux-kernel, Wei Yang, Masahiro Yamada

Current kbuild will build the target again if we run "make M=dir" and "make
M=dir/" by turns, since if_changed will see the prerequisite is changed.
The behavior may confuse the user a little, since actually we are building
the same target and no difference.

According to current implementation in scripts/Makefile.build, the obj
passed to next level is a directory name with last slash stripped. This
patch strips the last slash, and slashes in case user doing so, in
KBUILD_EXTMOD which is assigned from "M=".

Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
CC: Masahiro Yamada <yamada.masahiro@socionext.com>

---
v2:
   * remote the temp variable __KBUILD_EXTMOD, since this breaks the user
     case
   * use realpath to strips all the slash at the end, then remote the
     common part if it is an in tree build to make it the same behavior as
     previous version
---
 Makefile | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/Makefile b/Makefile
index b8dfb24b1911..7f12e88cc0fb 100644
--- a/Makefile
+++ b/Makefile
@@ -191,6 +191,8 @@ ifeq ("$(origin M)", "command line")
   KBUILD_EXTMOD := $(M)
 endif
 
+KBUILD_EXTMOD := $(subst $(CURDIR)/,,$(realpath $(KBUILD_EXTMOD)))
+
 # If building an external module we do not care about the all: rule
 # but instead _all depend on modules
 PHONY += all
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-03-12 12:11 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-22 15:08 [PATCH] kbuild: strip the last slash in KBUILD_EXTMOD Wei Yang
2017-03-11 13:34 ` Masahiro Yamada
2017-03-12 11:56   ` Wei Yang
2017-03-12 12:01 Wei Yang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.