kbuild: create a build directory automatically for out-of-tree build
authorMasahiro Yamada <yamada.m@jp.panasonic.com>
Mon, 24 Mar 2014 04:55:27 +0000 (13:55 +0900)
committerTom Rini <trini@ti.com>
Fri, 28 Mar 2014 19:06:31 +0000 (15:06 -0400)
Prior to Kbuild, the build system created a build directory,
when it did not exist, for out-of-tree build.

This feature was dropped when we switched to Kbuild
because many of lines in makefiles were copied from Linux Kernel.
(In Linux Kernel, we have to create a build directory by ourselves
before starting build.)

That feature seems worth reviving for less typing
even if our code and Linux Kernel diverge.

Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
Suggested-by: Simon Glass <sjg@chromium.org>
Acked-by: Simon Glass <sjg@chromium.org>
Tested-by: Simon Glass <sjg@chromium.org>
Makefile

index e7232186273fae0df000761428a61a4d7c4a0c1e..341f336ce5e3c8ee3420cda78623f469dea1bcdd 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -124,7 +124,8 @@ ifneq ($(KBUILD_OUTPUT),)
 # Invoke a second make in the output directory, passing relevant variables
 # check that the output directory actually exists
 saved-output := $(KBUILD_OUTPUT)
-KBUILD_OUTPUT := $(shell cd $(KBUILD_OUTPUT) && /bin/pwd)
+KBUILD_OUTPUT := $(shell mkdir -p $(KBUILD_OUTPUT) && cd $(KBUILD_OUTPUT) \
+                                                               && /bin/pwd)
 $(if $(KBUILD_OUTPUT),, \
      $(error output directory "$(saved-output)" does not exist))