summaryrefslogtreecommitdiffstats
path: root/scripts/Makefile.build
diff options
context:
space:
mode:
authorMasahiro Yamada <masahiroy@kernel.org>2020-05-19 16:13:47 +0900
committerSascha Hauer <s.hauer@pengutronix.de>2020-05-20 13:16:57 +0200
commit9fefbc860860dc8f85724dd989572dbb2fdba5b1 (patch)
tree2d9dde9dbc9185923bda4deebb3bdb0d4a3810c9 /scripts/Makefile.build
parente4e36abf1cf104f5853ee828332ad28f2c9f801b (diff)
downloadbarebox-9fefbc860860dc8f85724dd989572dbb2fdba5b1.tar.gz
barebox-9fefbc860860dc8f85724dd989572dbb2fdba5b1.tar.xz
kbuild: resync mkdir code with Linux 5.7-rc6
Kbuild automatically creates the output directories for O= builds. Previously it called mkdir too much. Linux optimized this a lot. Let's import the outcome so it works faster. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'scripts/Makefile.build')
-rw-r--r--scripts/Makefile.build25
1 files changed, 12 insertions, 13 deletions
diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index f4e7719801..d94ad488d7 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -49,15 +49,6 @@ ifneq ($(hostprogs)$(hostprogs-y)$(hostprogs-m),)
include scripts/Makefile.host
endif
-ifdef building_out_of_srctree
-# Create output directory if not already present
-_dummy := $(shell [ -d $(obj) ] || mkdir -p $(obj))
-
-# Create directories for object files if directory does not exist
-# Needed when obj-y := dir/file.o syntax is used
-_dummy := $(foreach d,$(obj-dirs), $(shell [ -d $(d) ] || mkdir -p $(d)))
-endif
-
ifndef obj
$(warning kbuild: Makefile.build is included improperly)
endif
@@ -332,11 +323,19 @@ FORCE:
# optimization, we don't need to read them if the target does not
# exist, we will rebuild anyway in that case.
-targets := $(wildcard $(sort $(targets)))
-cmd_files := $(wildcard $(foreach f,$(targets),$(dir $(f)).$(notdir $(f)).cmd))
+existing-targets := $(wildcard $(sort $(targets)))
-ifneq ($(cmd_files),)
- include $(cmd_files)
+-include $(foreach f,$(existing-targets),$(dir $(f)).$(notdir $(f)).cmd)
+
+ifdef building_out_of_srctree
+# Create directories for object files if they do not exist
+obj-dirs := $(sort $(obj) $(patsubst %/,%, $(dir $(targets))))
+# If targets exist, their directories apparently exist. Skip mkdir.
+existing-dirs := $(sort $(patsubst %/,%, $(dir $(existing-targets))))
+obj-dirs := $(strip $(filter-out $(existing-dirs), $(obj-dirs)))
+ifneq ($(obj-dirs),)
+$(shell mkdir -p $(obj-dirs))
+endif
endif
.PHONY: $(PHONY)