public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* regression in kbiuld with O=
@ 2006-04-04 15:24 Al Viro
  2006-04-04 21:46 ` Sam Ravnborg
  2006-04-05 10:51 ` Sam Ravnborg
  0 siblings, 2 replies; 3+ messages in thread
From: Al Viro @ 2006-04-04 15:24 UTC (permalink / raw)
  To: Sam Ravnborg; +Cc: linux-kernel

make O=../test kernel/sched.o produces kernel/sched.o is source tree
now.  AFAICS, breakage started in 06300b21f4c79fd1578f4b7ca4b314fbab61a383
(kbuild: support building individual files for external modules).

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

* Re: regression in kbiuld with O=
  2006-04-04 15:24 regression in kbiuld with O= Al Viro
@ 2006-04-04 21:46 ` Sam Ravnborg
  2006-04-05 10:51 ` Sam Ravnborg
  1 sibling, 0 replies; 3+ messages in thread
From: Sam Ravnborg @ 2006-04-04 21:46 UTC (permalink / raw)
  To: Al Viro; +Cc: linux-kernel

On Tue, Apr 04, 2006 at 04:24:30PM +0100, Al Viro wrote:
> make O=../test kernel/sched.o produces kernel/sched.o is source tree
> now.  AFAICS, breakage started in 06300b21f4c79fd1578f4b7ca4b314fbab61a383
> (kbuild: support building individual files for external modules).
Thanks. I will take a look tomorrow.

	Sam

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

* Re: regression in kbiuld with O=
  2006-04-04 15:24 regression in kbiuld with O= Al Viro
  2006-04-04 21:46 ` Sam Ravnborg
@ 2006-04-05 10:51 ` Sam Ravnborg
  1 sibling, 0 replies; 3+ messages in thread
From: Sam Ravnborg @ 2006-04-05 10:51 UTC (permalink / raw)
  To: Al Viro; +Cc: linux-kernel

On Tue, Apr 04, 2006 at 04:24:30PM +0100, Al Viro wrote:
> make O=../test kernel/sched.o produces kernel/sched.o is source tree
> now.  AFAICS, breakage started in 06300b21f4c79fd1578f4b7ca4b314fbab61a383
> (kbuild: support building individual files for external modules).

Fixed by patch below.
Tested with diverse combinations of separate outut directories and
external modules.
The target-dir variable was renamed to build-dir to better relect usage.
Also added dependency on prepare for %.ko targets so it can be used on
a cleaned tree.

	Sam

diff --git a/Makefile b/Makefile
index b401942..131950c 100644
--- a/Makefile
+++ b/Makefile
@@ -1275,40 +1275,43 @@ kernelversion:
 
 # Single targets
 # ---------------------------------------------------------------------------
-# The directory part is taken from first prerequisite, so this
-# works even with external modules
+# Single targets are compatible with:
+# - build whith mixed source and output
+# - build with separate output dir 'make O=...'
+# - external modules
+#
+#  target-dir => where to store outputfile
+#  build-dir  => directory in kernel source tree to use
+
+ifeq ($(KBUILD_EXTMOD),)
+        build-dir  = $(dir $@)
+        target-dir = $(dir $@)
+else
+        zap-slash=$(filter-out .,$(patsubst %/,%,$(dir $@)))
+        build-dir  = $(KBUILD_EXTMOD)$(if $(zap-slash),/$(zap-slash))
+        target-dir = $(if $(KBUILD_EXTMOD),$(dir $<),$(dir $@))
+endif
+
 %.s: %.c prepare scripts FORCE
-	$(Q)$(MAKE) $(build)=$(dir $<) $(dir $<)$(notdir $@)
+	$(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
 %.i: %.c prepare scripts FORCE
-	$(Q)$(MAKE) $(build)=$(dir $<) $(dir $<)$(notdir $@)
+	$(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
 %.o: %.c prepare scripts FORCE
-	$(Q)$(MAKE) $(build)=$(dir $<) $(dir $<)$(notdir $@)
+	$(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
 %.lst: %.c prepare scripts FORCE
-	$(Q)$(MAKE) $(build)=$(dir $<) $(dir $<)$(notdir $@)
+	$(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
 %.s: %.S prepare scripts FORCE
-	$(Q)$(MAKE) $(build)=$(dir $<) $(dir $<)$(notdir $@)
+	$(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
 %.o: %.S prepare scripts FORCE
-	$(Q)$(MAKE) $(build)=$(dir $<) $(dir $<)$(notdir $@)
-
-# For external modules we shall include any directory of the target,
-# but usual case there is no directory part.
-# make M=`pwd` module.o     => $(dir $@)=./
-# make M=`pwd` foo/module.o => $(dir $@)=foo/
-# make M=`pwd` /            => $(dir $@)=/
- 
-ifeq ($(KBUILD_EXTMOD),)
-        target-dir = $(@D)
-else
-        zap-slash=$(filter-out .,$(patsubst %/,%,$(dir $@)))
-        target-dir = $(KBUILD_EXTMOD)$(if $(zap-slash),/$(zap-slash))
-endif
+	$(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
 
-/ %/:      scripts prepare FORCE
+# Modules
+/ %/: prepare scripts FORCE
 	$(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
-	$(build)=$(target-dir)
-%.ko: scripts FORCE
+	$(build)=$(build-dir)
+%.ko: prepare scripts FORCE
 	$(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1)   \
-	$(build)=$(target-dir) $(@:.ko=.o)
+	$(build)=$(build-dir) $(@:.ko=.o)
 	$(Q)$(MAKE) -rR -f $(srctree)/scripts/Makefile.modpost
 
 # FIXME Should go into a make.lib or something 

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

end of thread, other threads:[~2006-04-05 10:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-04-04 15:24 regression in kbiuld with O= Al Viro
2006-04-04 21:46 ` Sam Ravnborg
2006-04-05 10:51 ` Sam Ravnborg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox