[PATCH 04/21] kbuild: define and use more generic symlink command

Ahmad Fatoum a.fatoum at pengutronix.de
Thu Jun 5 04:35:13 PDT 2025


We currently use symlinks only between files in the same directory.
Let's make it possible to symlink across directories as well.

No functional change.

Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
 Makefile             | 2 +-
 images/Makefile      | 2 +-
 scripts/Makefile.lib | 4 ++--
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/Makefile b/Makefile
index 031d5bdd3e20..2abd03cb0a74 100644
--- a/Makefile
+++ b/Makefile
@@ -816,7 +816,7 @@ export KBUILD_BINARY ?= barebox.bin
 # the default value.
 
 barebox-flash-image: $(KBUILD_IMAGE) FORCE
-	$(call if_changed,ln)
+	$(call if_changed,symlink)
 
 barebox-flash-images: $(KBUILD_IMAGE)
 	@echo $^ > $@
diff --git a/images/Makefile b/images/Makefile
index 91123ada4744..c8ab8fc015ae 100644
--- a/images/Makefile
+++ b/images/Makefile
@@ -240,7 +240,7 @@ __images_install: images
 PHONY += __images_install
 
 $(flash-link): $(link-dest) FORCE
-	$(call if_changed,ln)
+	$(call if_changed,symlink)
 
 $(flash-list): $(image-y-path)
 	@for i in $^; do if [ -s $$i ]; then echo $$i; fi; done > $@
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index b10119797686..e960d62ce59e 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -529,8 +529,8 @@ cmd_comp_copy ?= cat $(filter-out FORCE,$^) > $@; \
 quiet_cmd_disasm = DISASM  $@
 cmd_disasm = $(OBJDUMP) -d $< > $@
 
-quiet_cmd_ln = LN      $@
-cmd_ln = ln -sf $< $@
+quiet_cmd_symlink = LN      $@
+      cmd_symlink = mkdir -p $(dir $@) ; ln -fsn --relative $< $@
 
 quiet_cmd_check_size = CHKSIZE $2
       cmd_check_size = set -e;						\
-- 
2.39.5




More information about the barebox mailing list