linux-kbuild.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/4] kbuild: Fix the dependency handling of multi-objs targets
@ 2014-08-19  7:34 Masahiro Yamada
  2014-08-19  7:34 ` [PATCH 1/4] kbuild: handle multi-objs dependency appropriately Masahiro Yamada
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Masahiro Yamada @ 2014-08-19  7:34 UTC (permalink / raw)
  To: linux-kbuild; +Cc: Masahiro Yamada, linux-kernel, Yann E. MORIN, Michal Marek


1/4 and 2/4 fix the core scripts.

3/4 and 4/4 refactors scripts/kconfig/Makefile based on 2/4.



Masahiro Yamada (4):
  kbuild: handle multi-objs dependency appropriately
  kbuild: handle the dependency of multi-objs hostprogs appropriately
  kbuild: refactor script/kconfig/Makefile
  kbuild: remove redundant clean-files from scripts/kconfig/Makefile

 scripts/Makefile.build   | 10 ++++------
 scripts/Makefile.host    |  6 ++++--
 scripts/Makefile.lib     |  9 +++++++++
 scripts/kconfig/Makefile | 35 +++--------------------------------
 4 files changed, 20 insertions(+), 40 deletions(-)

-- 
1.9.1


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

* [PATCH 1/4] kbuild: handle multi-objs dependency appropriately
  2014-08-19  7:34 [PATCH 0/4] kbuild: Fix the dependency handling of multi-objs targets Masahiro Yamada
@ 2014-08-19  7:34 ` Masahiro Yamada
  2014-08-19  7:34 ` [PATCH 2/4] kbuild: handle the dependency of multi-objs hostprogs appropriately Masahiro Yamada
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Masahiro Yamada @ 2014-08-19  7:34 UTC (permalink / raw)
  To: linux-kbuild; +Cc: Masahiro Yamada, Michal Marek, linux-kernel

The comment in scripts/Makefile.build says as follows:

  We would rather have a list of rules like
        foo.o: $(foo-objs)
  but that's not so easy, so we rather make all composite objects depend
  on the set of all their parts

This commit makes it possible!

For example, assume a Makefile like this

  obj-m = foo.o bar.o
  foo-objs := foo1.o foo2.o
  bar-objs := bar1.o bar2.o

Without this patch, foo.o depends on all of
foo1.o foo2.o bar1.o bar2.o.
It looks funny that foo.o is regenerated when bar1.c is updated.

Now we can handle the dependency of foo.o and bar.o separately.

Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
---

 scripts/Makefile.build | 10 ++++------
 scripts/Makefile.lib   |  9 +++++++++
 2 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index bf3e677..5b09d36 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -382,16 +382,14 @@ cmd_link_multi-y = $(LD) $(ld_flags) -r -o $@ $(link_multi_deps) $(cmd_secanalys
 quiet_cmd_link_multi-m = LD [M]  $@
 cmd_link_multi-m = $(cmd_link_multi-y)
 
-# We would rather have a list of rules like
-# 	foo.o: $(foo-objs)
-# but that's not so easy, so we rather make all composite objects depend
-# on the set of all their parts
-$(multi-used-y) : %.o: $(multi-objs-y) FORCE
+$(multi-used-y): FORCE
 	$(call if_changed,link_multi-y)
+$(call multi_depend, $(multi-used-y), .o, -objs -y)
 
-$(multi-used-m) : %.o: $(multi-objs-m) FORCE
+$(multi-used-m): FORCE
 	$(call if_changed,link_multi-m)
 	@{ echo $(@:.o=.ko); echo $(link_multi_deps); } > $(MODVERDIR)/$(@F:.o=.mod)
+$(call multi_depend, $(multi-used-m), .o, -objs -y)
 
 targets += $(multi-used-y) $(multi-used-m)
 
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index 260bf8a..54be19a 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -159,6 +159,15 @@ dtc_cpp_flags  = -Wp,-MD,$(depfile).pre.tmp -nostdinc                    \
 modname-multi = $(sort $(foreach m,$(multi-used),\
 		$(if $(filter $(subst $(obj)/,,$*.o), $($(m:.o=-objs)) $($(m:.o=-y))),$(m:.o=))))
 
+# Useful for describing the dependency of composite objects
+# Usage:
+#   $(call multi_depend, multi_used_targets, suffix_to_remove, suffix_to_add)
+define multi_depend
+$(foreach m, $(notdir $1), \
+	$(eval $(obj)/$m: \
+	$(addprefix $(obj)/, $(foreach s, $3, $($(m:%$(strip $2)=%$(s)))))))
+endef
+
 ifdef REGENERATE_PARSERS
 
 # GPERF
-- 
1.9.1


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

* [PATCH 2/4] kbuild: handle the dependency of multi-objs hostprogs appropriately
  2014-08-19  7:34 [PATCH 0/4] kbuild: Fix the dependency handling of multi-objs targets Masahiro Yamada
  2014-08-19  7:34 ` [PATCH 1/4] kbuild: handle multi-objs dependency appropriately Masahiro Yamada
@ 2014-08-19  7:34 ` Masahiro Yamada
  2014-08-19  7:34 ` [PATCH 3/4] kbuild: refactor script/kconfig/Makefile Masahiro Yamada
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Masahiro Yamada @ 2014-08-19  7:34 UTC (permalink / raw)
  To: linux-kbuild; +Cc: Masahiro Yamada, Michal Marek, linux-kernel

Assume we have a Makefile like:

hostprogs-y := foo bar
foo-objs := foo1.o foo2.o
bar-objs := bar1.o bar2.o

Without this commit, the host program foo depends on all of
foo1.o foo2.o bar1.o bar2.o.

This commit allows to handle the dependency of each host program
separately.

Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
---

 scripts/Makefile.host | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/scripts/Makefile.host b/scripts/Makefile.host
index ab5980f..133edfa 100644
--- a/scripts/Makefile.host
+++ b/scripts/Makefile.host
@@ -96,8 +96,9 @@ quiet_cmd_host-cmulti	= HOSTLD  $@
       cmd_host-cmulti	= $(HOSTCC) $(HOSTLDFLAGS) -o $@ \
 			  $(addprefix $(obj)/,$($(@F)-objs)) \
 			  $(HOST_LOADLIBES) $(HOSTLOADLIBES_$(@F))
-$(host-cmulti): $(obj)/%: $(host-cobjs) FORCE
+$(host-cmulti): FORCE
 	$(call if_changed,host-cmulti)
+$(call multi_depend, $(host-cmulti), , -objs)
 
 # Create .o file from a single .c file
 # host-cobjs -> .o
@@ -113,8 +114,9 @@ quiet_cmd_host-cxxmulti	= HOSTLD  $@
 			  $(foreach o,objs cxxobjs,\
 			  $(addprefix $(obj)/,$($(@F)-$(o)))) \
 			  $(HOST_LOADLIBES) $(HOSTLOADLIBES_$(@F))
-$(host-cxxmulti): $(obj)/%: $(host-cobjs) $(host-cxxobjs) FORCE
+$(host-cxxmulti): FORCE
 	$(call if_changed,host-cxxmulti)
+$(call multi_depend, $(host-cxxmulti), , -objs -cxxobjs)
 
 # Create .o file from a single .cc (C++) file
 quiet_cmd_host-cxxobjs	= HOSTCXX $@
-- 
1.9.1


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

* [PATCH 3/4] kbuild: refactor script/kconfig/Makefile
  2014-08-19  7:34 [PATCH 0/4] kbuild: Fix the dependency handling of multi-objs targets Masahiro Yamada
  2014-08-19  7:34 ` [PATCH 1/4] kbuild: handle multi-objs dependency appropriately Masahiro Yamada
  2014-08-19  7:34 ` [PATCH 2/4] kbuild: handle the dependency of multi-objs hostprogs appropriately Masahiro Yamada
@ 2014-08-19  7:34 ` Masahiro Yamada
  2014-08-19  7:34 ` [PATCH 4/4] kbuild: remove redundant clean-files from scripts/kconfig/Makefile Masahiro Yamada
  2014-08-19  8:58 ` [PATCH 0/4] kbuild: Fix the dependency handling of multi-objs targets Michal Marek
  4 siblings, 0 replies; 6+ messages in thread
From: Masahiro Yamada @ 2014-08-19  7:34 UTC (permalink / raw)
  To: linux-kbuild; +Cc: Masahiro Yamada, Yann E. MORIN, linux-kernel

Now it is harmless to add all host programs to hostprogs-y.

Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
---

 scripts/kconfig/Makefile | 34 +++-------------------------------
 1 file changed, 3 insertions(+), 31 deletions(-)

diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile
index 9c4d241..76f6171 100644
--- a/scripts/kconfig/Makefile
+++ b/scripts/kconfig/Makefile
@@ -157,35 +157,7 @@ qconf-cxxobjs	:= qconf.o
 qconf-objs	:= zconf.tab.o
 gconf-objs	:= gconf.o zconf.tab.o
 
-hostprogs-y := conf
-
-ifeq ($(MAKECMDGOALS),nconfig)
-	hostprogs-y += nconf
-endif
-
-ifeq ($(MAKECMDGOALS),menuconfig)
-	hostprogs-y += mconf
-endif
-
-ifeq ($(MAKECMDGOALS),update-po-config)
-	hostprogs-y += kxgettext
-endif
-
-ifeq ($(MAKECMDGOALS),xconfig)
-	qconf-target := 1
-endif
-ifeq ($(MAKECMDGOALS),gconfig)
-	gconf-target := 1
-endif
-
-
-ifeq ($(qconf-target),1)
-	hostprogs-y += qconf
-endif
-
-ifeq ($(gconf-target),1)
-	hostprogs-y += gconf
-endif
+hostprogs-y := conf nconf mconf kxgettext qconf gconf
 
 clean-files	:= qconf.moc .tmp_qtcheck .tmp_gtkcheck
 clean-files	+= zconf.tab.c zconf.lex.c zconf.hash.c gconf.glade.h
@@ -224,7 +196,7 @@ HOSTLOADLIBES_nconf	= $(shell \
 				|| echo "-lmenu -lpanel -lncurses"  )
 $(obj)/qconf.o: $(obj)/.tmp_qtcheck
 
-ifeq ($(qconf-target),1)
+ifeq ($(MAKECMDGOALS),xconfig)
 $(obj)/.tmp_qtcheck: $(src)/Makefile
 -include $(obj)/.tmp_qtcheck
 
@@ -281,7 +253,7 @@ endif
 
 $(obj)/gconf.o: $(obj)/.tmp_gtkcheck
 
-ifeq ($(gconf-target),1)
+ifeq ($(MAKECMDGOALS),gconfig)
 -include $(obj)/.tmp_gtkcheck
 
 # GTK needs some extra effort, too...
-- 
1.9.1


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

* [PATCH 4/4] kbuild: remove redundant clean-files from scripts/kconfig/Makefile
  2014-08-19  7:34 [PATCH 0/4] kbuild: Fix the dependency handling of multi-objs targets Masahiro Yamada
                   ` (2 preceding siblings ...)
  2014-08-19  7:34 ` [PATCH 3/4] kbuild: refactor script/kconfig/Makefile Masahiro Yamada
@ 2014-08-19  7:34 ` Masahiro Yamada
  2014-08-19  8:58 ` [PATCH 0/4] kbuild: Fix the dependency handling of multi-objs targets Michal Marek
  4 siblings, 0 replies; 6+ messages in thread
From: Masahiro Yamada @ 2014-08-19  7:34 UTC (permalink / raw)
  To: linux-kbuild; +Cc: Masahiro Yamada, Yann E. MORIN, linux-kernel

Now mconf, qconf, gconf, nconf are always added to hostprogs-y.
Files added to hostprogs-y are removed by "make clean".

Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
---

 scripts/kconfig/Makefile | 1 -
 1 file changed, 1 deletion(-)

diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile
index 76f6171..e7bf38e 100644
--- a/scripts/kconfig/Makefile
+++ b/scripts/kconfig/Makefile
@@ -161,7 +161,6 @@ hostprogs-y := conf nconf mconf kxgettext qconf gconf
 
 clean-files	:= qconf.moc .tmp_qtcheck .tmp_gtkcheck
 clean-files	+= zconf.tab.c zconf.lex.c zconf.hash.c gconf.glade.h
-clean-files     += mconf qconf gconf nconf
 clean-files     += config.pot linux.pot
 
 # Check that we have the required ncurses stuff installed for lxdialog (menuconfig)
-- 
1.9.1


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

* Re: [PATCH 0/4] kbuild: Fix the dependency handling of multi-objs targets
  2014-08-19  7:34 [PATCH 0/4] kbuild: Fix the dependency handling of multi-objs targets Masahiro Yamada
                   ` (3 preceding siblings ...)
  2014-08-19  7:34 ` [PATCH 4/4] kbuild: remove redundant clean-files from scripts/kconfig/Makefile Masahiro Yamada
@ 2014-08-19  8:58 ` Michal Marek
  4 siblings, 0 replies; 6+ messages in thread
From: Michal Marek @ 2014-08-19  8:58 UTC (permalink / raw)
  To: Masahiro Yamada, linux-kbuild; +Cc: linux-kernel, Yann E. MORIN

On 2014-08-19 09:34, Masahiro Yamada wrote:
> 1/4 and 2/4 fix the core scripts.
> 
> 3/4 and 4/4 refactors scripts/kconfig/Makefile based on 2/4.
> 
> 
> 
> Masahiro Yamada (4):
>   kbuild: handle multi-objs dependency appropriately
>   kbuild: handle the dependency of multi-objs hostprogs appropriately
>   kbuild: refactor script/kconfig/Makefile
>   kbuild: remove redundant clean-files from scripts/kconfig/Makefile

Applied to kbuild.git#kbuild, thanks!

Michal


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

end of thread, other threads:[~2014-08-19  8:58 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-08-19  7:34 [PATCH 0/4] kbuild: Fix the dependency handling of multi-objs targets Masahiro Yamada
2014-08-19  7:34 ` [PATCH 1/4] kbuild: handle multi-objs dependency appropriately Masahiro Yamada
2014-08-19  7:34 ` [PATCH 2/4] kbuild: handle the dependency of multi-objs hostprogs appropriately Masahiro Yamada
2014-08-19  7:34 ` [PATCH 3/4] kbuild: refactor script/kconfig/Makefile Masahiro Yamada
2014-08-19  7:34 ` [PATCH 4/4] kbuild: remove redundant clean-files from scripts/kconfig/Makefile Masahiro Yamada
2014-08-19  8:58 ` [PATCH 0/4] kbuild: Fix the dependency handling of multi-objs targets Michal Marek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).