public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [PATCH] Makefile: Fix u-boot-nodtb.bin target
@ 2020-10-07 13:39 Pali Rohár
  2020-10-12  3:34 ` Simon Glass
  2020-10-24 14:51 ` Tom Rini
  0 siblings, 2 replies; 7+ messages in thread
From: Pali Rohár @ 2020-10-07 13:39 UTC (permalink / raw)
  To: u-boot

This change fixes two issues when building u-boot-nodtb.bin target:

* Remove intermediate binary u-boot-nodtb.bin from disk when static_rela
  call (which modifies u-boot-nodtb.bin binary) failed. It is required
  because previous objcopy call creates binary and static_rela finish it.

* Do not call static_rela cmd when u-boot-nodtb.bin binary was not
  created/updated by previous objcopy call.

Second fix would ensure that u-boot-nodtb.bin binary is not updated when
all prerequisites were up-to-date. And therefore final binary u-boot.bin
is not updated in case all prerequisites were not modified and were
up-to-date.

Now running 'make SOURCE_DATE_EPOCH=0 u-boot.bin' second time now does not
touch u-boot.bin binary in case nothing was modified, so GNU make can
correctly detect that everything is up-to-date.

Signed-off-by: Pali Roh?r <pali@kernel.org>
---
 Makefile | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/Makefile b/Makefile
index d4736bb501..91b6d2c2b3 100644
--- a/Makefile
+++ b/Makefile
@@ -884,7 +884,7 @@ cmd_static_rela = \
 	tools/relocate-rela $(3) $(4) $$start $$end
 else
 quiet_cmd_static_rela =
-cmd_static_rela =
+cmd_static_rela = true
 endif
 
 # Always append INPUTS so that arch config.mk's can add custom ones
@@ -1317,9 +1317,13 @@ init_sp_bss_offset_check: u-boot.dtb FORCE
 	fi
 endif
 
+shell_cmd = { $(echo-cmd) $(cmd_$(1)); }
+
+quiet_cmd_objcopy_uboot = OBJCOPY $@
+cmd_objcopy_uboot = $(cmd_objcopy) && $(call shell_cmd,static_rela,$<,$@,$(CONFIG_SYS_TEXT_BASE)) || rm -f $@
+
 u-boot-nodtb.bin: u-boot FORCE
-	$(call if_changed,objcopy)
-	$(call cmd,static_rela,$<,$@,$(CONFIG_SYS_TEXT_BASE))
+	$(call if_changed,objcopy_uboot)
 	$(BOARD_SIZE_CHECK)
 
 u-boot.ldr:	u-boot
-- 
2.20.1

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2020-11-04  9:32 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-10-07 13:39 [PATCH] Makefile: Fix u-boot-nodtb.bin target Pali Rohár
2020-10-12  3:34 ` Simon Glass
2020-10-24 14:51 ` Tom Rini
2020-11-02 13:25   ` Patrick DELAUNAY
2020-11-02 14:15     ` Pali Rohár
2020-11-04  8:53       ` Patrick DELAUNAY
2020-11-04  9:32         ` Pali Rohár

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox