diff mbox series

[RFC,01/68] kbuild: skip sub-make for in-tree build with GNU Make 4.x

Message ID 155373004377.7602.1209303093988055088.stgit@warthog.procyon.org.uk
State New
Headers show
Series [RFC,01/68] kbuild: skip sub-make for in-tree build with GNU Make 4.x | expand

Commit Message

David Howells March 27, 2019, 11:40 p.m. UTC
From: Masahiro Yamada <yamada.masahiro@socionext.com>


Commit 2b50f7ab6368 ("kbuild: add workaround for Debian make-kpkg")
annoyed people who want to wrap the top Makefile with GNUmakefile
or something in order to customize it for their use.

On second thought, we do not need to run the sub-make for in-tree
build with Make 4.x because the 'MAKEFLAGS += -rR' issue only happens
on GNU Make 3.x.

With this commit, people will get back the workflow, and the Debian
make-kpkg will still work.

Fixes: 2b50f7ab6368 ("kbuild: add workaround for Debian make-kpkg")
Reported-by: Andreas Schwab <schwab@suse.de>
Reported-by: David Howells <dhowells@redhat.com>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>

Signed-off-by: David Howells <dhowells@redhat.com>

---

 Makefile |   31 +++++++++++++++----------------
 1 file changed, 15 insertions(+), 16 deletions(-)

Comments

Masahiro Yamada March 28, 2019, 12:53 a.m. UTC | #1
David,


On Thu, Mar 28, 2019 at 8:41 AM David Howells <dhowells@redhat.com> wrote:
>

> From: Masahiro Yamada <yamada.masahiro@socionext.com>

>

> Commit 2b50f7ab6368 ("kbuild: add workaround for Debian make-kpkg")

> annoyed people who want to wrap the top Makefile with GNUmakefile

> or something in order to customize it for their use.

>

> On second thought, we do not need to run the sub-make for in-tree

> build with Make 4.x because the 'MAKEFLAGS += -rR' issue only happens

> on GNU Make 3.x.

>

> With this commit, people will get back the workflow, and the Debian

> make-kpkg will still work.

>

> Fixes: 2b50f7ab6368 ("kbuild: add workaround for Debian make-kpkg")

> Reported-by: Andreas Schwab <schwab@suse.de>

> Reported-by: David Howells <dhowells@redhat.com>

> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>

> Signed-off-by: David Howells <dhowells@redhat.com>



Why should this patch be included in a
totally unrelated patch series?


I already applied this to my fixes branch,
and am planning to send a PR to Linus soon.

(Sorry, I missed to send a PR for -rc2)




> ---

>

>  Makefile |   31 +++++++++++++++----------------

>  1 file changed, 15 insertions(+), 16 deletions(-)

>

> diff --git a/Makefile b/Makefile

> index c0a34064c574..cd38d203e71a 100644

> --- a/Makefile

> +++ b/Makefile

> @@ -31,26 +31,12 @@ _all:

>  # descending is started. They are now explicitly listed as the

>  # prepare rule.

>

> -# Ugly workaround for Debian make-kpkg:

> -# make-kpkg directly includes the top Makefile of Linux kernel. In such a case,

> -# skip sub-make to support debian_* targets in ruleset/kernel_version.mk, but

> -# displays warning to discourage such abusage.

> -ifneq ($(word 2, $(MAKEFILE_LIST)),)

> -$(warning Do not include top Makefile of Linux Kernel)

> -sub-make-done := 1

> -MAKEFLAGS += -rR

> -endif

> -

>  ifneq ($(sub-make-done),1)

>

>  # Do not use make's built-in rules and variables

>  # (this increases performance and avoids hard-to-debug behaviour)

>  MAKEFLAGS += -rR

>

> -# 'MAKEFLAGS += -rR' does not become immediately effective for old

> -# GNU Make versions. Cancel implicit rules for this Makefile.

> -$(lastword $(MAKEFILE_LIST)): ;

> -

>  # Avoid funny character set dependencies

>  unexport LC_ALL

>  LC_COLLATE=C

> @@ -153,6 +139,7 @@ $(if $(KBUILD_OUTPUT),, \

>  # 'sub-make' below.

>  MAKEFLAGS += --include-dir=$(CURDIR)

>

> +need-sub-make := 1

>  else

>

>  # Do not print "Entering directory ..." at all for in-tree build.

> @@ -160,6 +147,15 @@ MAKEFLAGS += --no-print-directory

>

>  endif # ifneq ($(KBUILD_OUTPUT),)

>

> +ifneq ($(filter 3.%,$(MAKE_VERSION)),)

> +# 'MAKEFLAGS += -rR' does not immediately become effective for GNU Make 3.x

> +# We need to run sub-make to avoid implicit rules in the top Makefile.

> +need-sub-make := 1

> +# Cancel implicit rules for this Makefile.

> +$(lastword $(MAKEFILE_LIST)): ;

> +endif

> +

> +ifeq ($(need-sub-make),1)

>  PHONY += $(MAKECMDGOALS) sub-make

>

>  $(filter-out _all sub-make $(CURDIR)/Makefile, $(MAKECMDGOALS)) _all: sub-make

> @@ -171,8 +167,11 @@ sub-make:

>         $(if $(KBUILD_OUTPUT),-C $(KBUILD_OUTPUT) KBUILD_SRC=$(CURDIR)) \

>         -f $(CURDIR)/Makefile $(filter-out _all sub-make,$(MAKECMDGOALS))

>

> -else # sub-make-done

> +endif # need-sub-make

> +endif # sub-make-done

> +

>  # We process the rest of the Makefile if this is the final invocation of make

> +ifeq ($(need-sub-make),)

>

>  # Do not print "Entering directory ...",

>  # but we want to display it when entering to the output directory

> @@ -1757,7 +1756,7 @@ existing-targets := $(wildcard $(sort $(targets)))

>

>  endif   # ifeq ($(config-targets),1)

>  endif   # ifeq ($(mixed-targets),1)

> -endif   # sub-make-done

> +endif   # need-sub-make

>

>  PHONY += FORCE

>  FORCE:

>



-- 
Best Regards
Masahiro Yamada
Masahiro Yamada March 30, 2019, 12:11 p.m. UTC | #2
On Thu, Mar 28, 2019 at 9:53 AM Masahiro Yamada
<yamada.masahiro@socionext.com> wrote:
>

> David,

>

>

> On Thu, Mar 28, 2019 at 8:41 AM David Howells <dhowells@redhat.com> wrote:

> >

> > From: Masahiro Yamada <yamada.masahiro@socionext.com>

> >

> > Commit 2b50f7ab6368 ("kbuild: add workaround for Debian make-kpkg")

> > annoyed people who want to wrap the top Makefile with GNUmakefile

> > or something in order to customize it for their use.

> >

> > On second thought, we do not need to run the sub-make for in-tree

> > build with Make 4.x because the 'MAKEFLAGS += -rR' issue only happens

> > on GNU Make 3.x.

> >

> > With this commit, people will get back the workflow, and the Debian

> > make-kpkg will still work.

> >

> > Fixes: 2b50f7ab6368 ("kbuild: add workaround for Debian make-kpkg")

> > Reported-by: Andreas Schwab <schwab@suse.de>

> > Reported-by: David Howells <dhowells@redhat.com>

> > Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>

> > Signed-off-by: David Howells <dhowells@redhat.com>

>

>

> Why should this patch be included in a

> totally unrelated patch series?

>

>

> I already applied this to my fixes branch,

> and am planning to send a PR to Linus soon.

>

> (Sorry, I missed to send a PR for -rc2)



Now, this landed in Linus tree.



-- 
Best Regards
Masahiro Yamada
David Howells April 10, 2019, 9:54 a.m. UTC | #3
Masahiro Yamada <yamada.masahiro@socionext.com> wrote:

> Why should this patch be included in a

> totally unrelated patch series?


Sorry, I forgot to exclude it.  It's in all my branches that I've touched
since upstream got broken.  I've now rebased and it's gone from this branch.

David
diff mbox series

Patch

diff --git a/Makefile b/Makefile
index c0a34064c574..cd38d203e71a 100644
--- a/Makefile
+++ b/Makefile
@@ -31,26 +31,12 @@  _all:
 # descending is started. They are now explicitly listed as the
 # prepare rule.
 
-# Ugly workaround for Debian make-kpkg:
-# make-kpkg directly includes the top Makefile of Linux kernel. In such a case,
-# skip sub-make to support debian_* targets in ruleset/kernel_version.mk, but
-# displays warning to discourage such abusage.
-ifneq ($(word 2, $(MAKEFILE_LIST)),)
-$(warning Do not include top Makefile of Linux Kernel)
-sub-make-done := 1
-MAKEFLAGS += -rR
-endif
-
 ifneq ($(sub-make-done),1)
 
 # Do not use make's built-in rules and variables
 # (this increases performance and avoids hard-to-debug behaviour)
 MAKEFLAGS += -rR
 
-# 'MAKEFLAGS += -rR' does not become immediately effective for old
-# GNU Make versions. Cancel implicit rules for this Makefile.
-$(lastword $(MAKEFILE_LIST)): ;
-
 # Avoid funny character set dependencies
 unexport LC_ALL
 LC_COLLATE=C
@@ -153,6 +139,7 @@  $(if $(KBUILD_OUTPUT),, \
 # 'sub-make' below.
 MAKEFLAGS += --include-dir=$(CURDIR)
 
+need-sub-make := 1
 else
 
 # Do not print "Entering directory ..." at all for in-tree build.
@@ -160,6 +147,15 @@  MAKEFLAGS += --no-print-directory
 
 endif # ifneq ($(KBUILD_OUTPUT),)
 
+ifneq ($(filter 3.%,$(MAKE_VERSION)),)
+# 'MAKEFLAGS += -rR' does not immediately become effective for GNU Make 3.x
+# We need to run sub-make to avoid implicit rules in the top Makefile.
+need-sub-make := 1
+# Cancel implicit rules for this Makefile.
+$(lastword $(MAKEFILE_LIST)): ;
+endif
+
+ifeq ($(need-sub-make),1)
 PHONY += $(MAKECMDGOALS) sub-make
 
 $(filter-out _all sub-make $(CURDIR)/Makefile, $(MAKECMDGOALS)) _all: sub-make
@@ -171,8 +167,11 @@  sub-make:
 	$(if $(KBUILD_OUTPUT),-C $(KBUILD_OUTPUT) KBUILD_SRC=$(CURDIR)) \
 	-f $(CURDIR)/Makefile $(filter-out _all sub-make,$(MAKECMDGOALS))
 
-else # sub-make-done
+endif # need-sub-make
+endif # sub-make-done
+
 # We process the rest of the Makefile if this is the final invocation of make
+ifeq ($(need-sub-make),)
 
 # Do not print "Entering directory ...",
 # but we want to display it when entering to the output directory
@@ -1757,7 +1756,7 @@  existing-targets := $(wildcard $(sort $(targets)))
 
 endif   # ifeq ($(config-targets),1)
 endif   # ifeq ($(mixed-targets),1)
-endif   # sub-make-done
+endif   # need-sub-make
 
 PHONY += FORCE
 FORCE: