Skip to contentSkip to conversation

try to create KBUILD_OUTPUT automatically

RFC PATCH Superseded Peter Foley 3 participants 3 messages Oct 22, 2011 – Dec 11, 2011 Kbuild

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 try to create KBUILD_OUTPUT automatically

This patch makes it possible to execute make O=work instead of mkdir work
make O=work

---
 Makefile |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
Makefile +1 -1
index 2652089..a4769ac 100644
@@ -117,7 +117,7 @@ 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))
 
Signature · 1 line
1.7.7
#1 lore raw
Quoted 3 lines · Peter Foley

This patch makes it possible to execute make O=work instead of mkdir work
make O=work

The case can be made that this is a Bad Idea, because it means you can't catch a typo in your O= setting. This is particularly bad when it silently fails to update the stuff in out-dir because you did a 'make O=out-diir'.

So NACK on this, if anybody cares what I think... ;)

#2 lore raw
In reply to Peter Foley
Quoted 14 lines · Peter Foley

This patch makes it possible to execute make O=work instead of mkdir work
make O=work

---
 Makefile |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
Makefile +0 -0
index 2652089..a4769ac 100644

Makefile ifneq ($(KBUILD_OUTPUT),) · line 122

Quoted 7 lines
Makefile +1 -1
@@ -117,7 +117,7 @@ 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))

I think it's a good idea, but please also change the comment and error message. The command will now only fail if the directory cannot be created, not if it does not exist.

Michal