[PATCH master] kbuild: delete images with missing firmware instead of truncating

Ahmad Fatoum a.fatoum at pengutronix.de
Mon Jul 3 02:56:08 PDT 2023


It may be confusing to users to be left with a 0-byte image, so let's
delete it instead. This means that every build with missing firmware will
attempt the final make targets, only to delete them at the end.

At the flip-side, there is no risk of broken images to be used later on.

Suggested-by: Rouven Czerwinski <r.czerwinski at pengutronix.de>
Suggested-by: Michael Olbrich <mol at pengutronix.de>
Suggested-by: Enrico Jörns <e.joerns at pengutronix.de>
Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
 images/Makefile      | 4 ++--
 scripts/Makefile.lib | 3 +++
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/images/Makefile b/images/Makefile
index e26880de50b4..c1cb56f5b189 100644
--- a/images/Makefile
+++ b/images/Makefile
@@ -136,7 +136,7 @@ missing_fw = $(strip $(wildcard $(obj)/$(FILE_$(@F)).missing-firmware $(basename
 $(obj)/%.img: $(obj)/$$(FILE_$$(@F))
 	$(Q)if [ -z $(FILE_$(@F)) ]; then echo "FILE_$(@F) empty!"; false; fi
 	$(Q)$(if $(missing_fw),cat $(missing_fw) >$@.missing-firmware,rm -f $@.missing-firmware)
-	$(call if_changed,$(if $(missing_fw),0size,shipped))
+	$(call if_changed,$(if $(missing_fw),delete,shipped))
 
 board = $(srctree)/arch/$(SRCARCH)/boards
 objboard = $(objtree)/arch/$(SRCARCH)/boards
@@ -202,7 +202,7 @@ images: $(image-y-path) $(flash-link) $(flash-list) FORCE
 	@echo "images built:"
 	@for i in $(image-y); do \
 	  if [ -s $(obj)/$$i ]; then echo $$i; \
-	  else >&2 echo "** firmware missing for $$i **"; \
+	  else >&2 echo "** $$i skipped due to missing firmware **"; \
 	  $(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
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index b8fb2684421e..f04c09f9e280 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -239,6 +239,9 @@ endef
 quiet_cmd_0size = 0SIZE $@
 cmd_0size = : > $@
 
+quiet_cmd_delete = DELETE  $@
+      cmd_delete = rm -f $@
+
 quiet_cmd_shipped = SHIPPED $@
 cmd_shipped = cat $< > $@
 
-- 
2.39.2




More information about the barebox mailing list