]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
kbuild: let fixdep directly write to .*.cmd files
authorIlias Apalodimas <ilias.apalodimas@linaro.org>
Tue, 20 May 2025 05:21:22 +0000 (08:21 +0300)
committerTom Rini <trini@konsulko.com>
Fri, 30 May 2025 00:42:37 +0000 (18:42 -0600)
Backport from kernel
commit 392885ee82d3 ("kbuild: let fixdep directly write to .*.cmd files")

Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Makefile
scripts/Kbuild.include
scripts/Makefile.build

index 15c7e633b8749ccd9f26bd0370d6da678b4522fc..09d36b8cbbed066ecdbf365ad515c5d0269c411c 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -2538,14 +2538,11 @@ quiet_cmd_rmdirs = $(if $(wildcard $(rm-dirs)),CLEAN   $(wildcard $(rm-dirs)))
 quiet_cmd_rmfiles = $(if $(wildcard $(rm-files)),CLEAN   $(wildcard $(rm-files)))
       cmd_rmfiles = rm -f $(rm-files)
 
-# read all saved command lines
-
-cmd_files := $(wildcard .*.cmd)
-
-ifneq ($(cmd_files),)
-  $(cmd_files): ;      # Do not try to update included dependency files
-  include $(cmd_files)
-endif
+# read saved command lines for existing targets
+existing-targets := $(wildcard $(sort $(targets)))
+cmd_files := $(foreach f,$(existing-targets),$(dir $(f)).$(notdir $(f)).cmd)
+$(cmd_files): ;        # Do not try to update included dependency files
+-include $(cmd_files)
 
 endif    #ifeq ($(config-targets),1)
 endif    #ifeq ($(mixed-targets),1)
index 2ef687ea895a840c8209e9a006bc397886973072..6ef66c451eb1f7dfb1da4ea03b5b4def933f7dc1 100644 (file)
@@ -274,9 +274,8 @@ if_changed_dep = $(if $(strip $(any-prereq) $(arg-check) ),                  \
 
 cmd_and_fixdep =                                                            \
        $(echo-cmd) $(cmd_$(1));                                             \
-       scripts/basic/fixdep $(depfile) $@ '$(make-cmd)' > $(dot-target).tmp;\
-       rm -f $(depfile);                                                    \
-       mv -f $(dot-target).tmp $(dot-target).cmd;
+       scripts/basic/fixdep $(depfile) $@ '$(make-cmd)' > $(dot-target).cmd;\
+       rm -f $(depfile)
 
 # Usage: $(call if_changed_rule,foo)
 # Will check if $(cmd_foo) or any of the prerequisites changed,
index d90b0b7aa6a0ce07bf9e57f88a713e9f45ccbbc8..2f2d5d4afc25ca8caf1f7dbd9f8457466b8d66d1 100644 (file)
@@ -410,14 +410,17 @@ FORCE:
 # optimization, we don't need to read them if the target does not
 # exist, we will rebuild anyway in that case.
 
-cmd_files := $(wildcard $(foreach f,$(sort $(targets)),$(dir $(f)).$(notdir $(f)).cmd))
+existing-targets := $(wildcard $(sort $(targets)))
 
-ifneq ($(cmd_files),)
-  include $(cmd_files)
-endif
+-include $(foreach f,$(existing-targets),$(dir $(f)).$(notdir $(f)).cmd)
 
 # 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
 
 .PHONY: $(PHONY)