[PATCH 05/21] kbuild: collect compatibility symlink creation in symlink-y
Ahmad Fatoum
a.fatoum at pengutronix.de
Thu Jun 5 04:35:14 PDT 2025
This allows for easier addition of symlinks, which is something we are
going to do soon for the fuzzing support.
Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
Makefile | 21 ++++++++++++---------
images/Makefile | 10 +++++++++-
scripts/Makefile.lib | 2 ++
3 files changed, 23 insertions(+), 10 deletions(-)
diff --git a/Makefile b/Makefile
index 2abd03cb0a74..ecaf195b726d 100644
--- a/Makefile
+++ b/Makefile
@@ -815,9 +815,6 @@ export KBUILD_BINARY ?= barebox.bin
# Also any assignments in arch/$(SRCARCH)/Makefile take precedence over
# the default value.
-barebox-flash-image: $(KBUILD_IMAGE) FORCE
- $(call if_changed,symlink)
-
barebox-flash-images: $(KBUILD_IMAGE)
@echo $^ > $@
@@ -826,16 +823,22 @@ images: barebox.bin FORCE
images/%: barebox.bin FORCE
$(Q)$(MAKE) $(build)=images $@
-ifdef CONFIG_EFI_STUB
-all: barebox.bin images barebox.efi
-barebox.efi: FORCE
- $(Q)ln -fsn images/barebox-dt-2nd.img $@
-else ifdef CONFIG_PBL_IMAGE
+ifdef CONFIG_PBL_IMAGE
+SYMLINK_TARGET_barebox.efi = images/barebox-dt-2nd.img
+symlink-$(CONFIG_EFI_STUB) += barebox.efi
all: barebox.bin images
else
-all: barebox-flash-image barebox-flash-images
+SYMLINK_TARGET_barebox-flash-image = $(KBUILD_IMAGE)
+symlink-y += barebox-flash-image
+all: barebox-flash-images
endif
+all: $(symlink-y)
+
+.SECONDEXPANSION:
+$(symlink-y): $$(SYMLINK_TARGET_$$(@F)) FORCE
+ $(call if_changed,symlink_quiet)
+
common-$(CONFIG_PBL_IMAGE) += pbl/
common-$(CONFIG_DEFAULT_ENVIRONMENT) += defaultenv/
diff --git a/images/Makefile b/images/Makefile
index c8ab8fc015ae..ca37c054ae9c 100644
--- a/images/Makefile
+++ b/images/Makefile
@@ -223,9 +223,12 @@ flash-list := $(obj)/../barebox-flash-images
# multiple images
flash-link := $(obj)/../barebox-flash-image
link-dest := $(if $(filter 1,$(words $(image-y))),$(image-y-path),multi-image-build)
+
+symlink-y-path := $(addprefix $(obj)/,$(symlink-y))
+
multi-image-build:
-images: $(image-y-path) $(flash-link) $(flash-list) FORCE
+images: $(image-y-path) $(flash-link) $(flash-list) $(symlink-y-path) FORCE
@echo "images built:"
@for i in $(image-y); do \
if [ -s $(obj)/$$i ]; then echo $$i; \
@@ -233,6 +236,7 @@ images: $(image-y-path) $(flash-link) $(flash-list) FORCE
$(if $(CONFIG_MISSING_FIRMWARE_ERROR), >&2 sed 's/^/\t/' <$(obj)/$${i}.missing-firmware; missing=1;) \
fi; done; if [ -n "$$missing" ]; then \
echo >&2 "Firmware missing in CONFIG_MISSING_FIRMWARE_ERROR=y build"; exit 1; fi
+ @for i in $(symlink-y); do echo $$i; done
__images_install: images
@for i in $(image-y-path); do if [ -s $$i ]; then install -t "$(INSTALL_PATH)" $$i; fi; done
@@ -245,6 +249,10 @@ $(flash-link): $(link-dest) FORCE
$(flash-list): $(image-y-path)
@for i in $^; do if [ -s $$i ]; then echo $$i; fi; done > $@
+.SECONDEXPANSION:
+$(symlink-y-path): $(obj)/$$(SYMLINK_TARGET_$$(@F)) FORCE
+ $(call if_changed,symlink_quiet)
+
clean-files := *.pbl *.pblb *.elf *.map start_*.imximg *.img barebox.z start_*.kwbimg \
start_*.kwbuartimg *.socfpgaimg *.mlo *.t20img *.t20img.cfg *.t30img \
*.t30img.cfg *.t124img *.t124img.cfg *.mlospi *.mlo *.mxsbs *.mxssd *.rkimg \
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index e960d62ce59e..e6f0e254960a 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -532,6 +532,8 @@ cmd_disasm = $(OBJDUMP) -d $< > $@
quiet_cmd_symlink = LN $@
cmd_symlink = mkdir -p $(dir $@) ; ln -fsn --relative $< $@
+cmd_symlink_quiet = mkdir -p $(dir $@) ; ln -fsn --relative $< $@
+
quiet_cmd_check_size = CHKSIZE $2
cmd_check_size = set -e; \
size=`printf "%d" $2`; \
--
2.39.5
More information about the barebox
mailing list