Skip to contentSkip to conversation

kbuild: Move U-Boot .incbin rules to Makefile.lib-u-boot

PATCH In review Simon Glass 3 participants 5 messages Apr 13 – Apr 22

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v4 1/2 kbuild: Move U-Boot .incbin rules to Makefile.lib-u-boot

The font, splash-screen and EFI .incbin wrapper rules are U-Boot additions that do not exist in the upstream Linux kbuild. Keeping them in scripts/Makefile.lib makes re-syncing with Linux harder than it needs to be, as every sync must manually preserve the U-Boot additions.

Move these rules into a new scripts/Makefile.lib-u-boot and include it from Makefile.build and Makefile.xpl, right after the existing Makefile.lib include.

This is a pure code-move with no functional change.

---

(no changes since v2)

Changes in v2:
- Split out of the relative-path patch as requested by Tom Rini

 scripts/Makefile.build      |  1 +
 scripts/Makefile.lib        | 94 ------------------------------------
 scripts/Makefile.lib-u-boot | 96 +++++++++++++++++++++++++++++++++++++
 scripts/Makefile.xpl        |  1 +
 4 files changed, 98 insertions(+), 94 deletions(-)
 create mode 100644 scripts/Makefile.lib-u-boot
scripts/Makefile.build +1 -0
index 8da9851d430..e625f99986e 100644
@@ -65,6 +65,7 @@ ccflags-y  += $(PLATFORM_CPPFLAGS)
 cppflags-y += $(PLATFORM_CPPFLAGS)
 
 include $(srctree)/scripts/Makefile.lib
+include $(srctree)/scripts/Makefile.lib-u-boot
 
 # Do not include hostprogs rules unless needed.
 # $(sort ...) is used here to remove duplicated words and excessive spaces.
scripts/Makefile.lib +0 -94

100 lines not on this page · raw message

scripts/Makefile.lib-u-boot new file +96 -0

96 lines not on this page · raw message

scripts/Makefile.xpl +1 -0
index c5ddf64c73f..862a8e6f231 100644
@@ -88,6 +88,7 @@ include $(srctree)/config.mk
 include $(srctree)/arch/$(ARCH)/Makefile
 
 include $(srctree)/scripts/Makefile.lib
+include $(srctree)/scripts/Makefile.lib-u-boot
 
 # Enable garbage collection of un-used sections for SPL
 KBUILD_CFLAGS += -ffunction-sections -fdata-sections

---
base-commit: e2fa3e570f83ab0f9ce667ddaec9dc738bcf05b9
branch: font-us4

Signature · 1 line
2.43.0
#1 lore raw

PATCH v4 2/2 kbuild: Use if_changed for font and splash .incbin rules

The generated .S files for fonts and splash screens use .incbin with the full prerequisite path. When building with O= this bakes an absolute path into the .S file. If the build directory is later used on a different machine (e.g. in a container), the assembler cannot find the source file.

Follow the existing DTB convention: rename the object targets to use compound suffixes (.ttf.o, .bmp.o), switch the pattern rules from direct $(call cmd,...) to FORCE + $(call if_changed,...), and register the new suffixes with intermediate_targets so that kbuild loads their .cmd files. This lets if_changed detect when the recorded command (including source paths) has changed and regenerate the .S file automatically.

The EFI rule is left unchanged since its prerequisite is a generated file in the build directory, like the DTB and DTBO rules.

The intermediate_targets entries stay in scripts/Makefile.build rather than moving to scripts/Makefile.lib-u-boot, because that file is included before intermediate_targets is defined and 'targets' is ':=', so a '$(call intermediate_targets, ...)' inside it would expand to empty and silently drop the entries. To keep the upstream block untouched, the U-Boot additions go in a separate 'targets +=' block immediately below.

---

Changes in v4:
- Add a separate 'targets +=' block for .ttf.o/.bmp.o per Rasmus

Changes in v3:
- Use if_changed with compound suffixes (.ttf.o, .bmp.o)

Changes in v2:
- Move U-Boot .incbin rules to Makefile.lib-u-boot first (previous patch)
- Drop the EFI .incbin change since .efi files are generated, not source
- Use per-file AFLAGS instead of modifying a_flags in Makefile.lib

 drivers/video/Makefile       |  2 +-
 drivers/video/fonts/Makefile | 10 +++++-----
 scripts/Makefile.build       |  4 ++++
 scripts/Makefile.lib-u-boot  |  8 ++++----
 4 files changed, 14 insertions(+), 10 deletions(-)
drivers/video/Makefile +1 -1
index 984768ea156..dbc3018d716 100644
@@ -24,7 +24,7 @@ obj-$(CONFIG_$(PHASE_)PANEL) += panel-uclass.o
 obj-$(CONFIG_PANEL_HX8238D) += hx8238d.o
 obj-$(CONFIG_$(PHASE_)SIMPLE_PANEL) += simple_panel.o
 
-obj-$(CONFIG_VIDEO_LOGO) += u_boot_logo.o
+obj-$(CONFIG_VIDEO_LOGO) += u_boot_logo.bmp.o
 obj-$(CONFIG_$(PHASE_)BMP) += bmp.o
 
 endif
drivers/video/fonts/Makefile +5 -5
index 1111f92a2c6..4d32fa43994 100644
@@ -3,8 +3,8 @@
 # (C) Copyright 2000-2007
 # Wolfgang Denk, DENX Software Engineering, [email protected].
 
-obj-$(CONFIG_CONSOLE_TRUETYPE_NIMBUS) += nimbus_sans_l_regular.o
-obj-$(CONFIG_CONSOLE_TRUETYPE_ANKACODER) += ankacoder_c75_r.o
-obj-$(CONFIG_CONSOLE_TRUETYPE_RUFSCRIPT) += rufscript010.o
-obj-$(CONFIG_CONSOLE_TRUETYPE_CANTORAONE) += cantoraone_regular.o
-obj-$(CONFIG_CONSOLE_TRUETYPE_DEJAVU) += dejavu_mono.o
+obj-$(CONFIG_CONSOLE_TRUETYPE_NIMBUS) += nimbus_sans_l_regular.ttf.o
+obj-$(CONFIG_CONSOLE_TRUETYPE_ANKACODER) += ankacoder_c75_r.ttf.o
+obj-$(CONFIG_CONSOLE_TRUETYPE_RUFSCRIPT) += rufscript010.ttf.o
+obj-$(CONFIG_CONSOLE_TRUETYPE_CANTORAONE) += cantoraone_regular.ttf.o
+obj-$(CONFIG_CONSOLE_TRUETYPE_DEJAVU) += dejavu_mono.ttf.o
scripts/Makefile.build +4 -0
index e625f99986e..73b6769ab90 100644
@@ -440,6 +440,10 @@ targets += $(call intermediate_targets, .asn1.o, .asn1.c .asn1.h) \
 	   $(call intermediate_targets, .lex.o, .lex.c) \
 	   $(call intermediate_targets, .tab.o, .tab.c .tab.h)
 
+# Added for U-Boot
+targets += $(call intermediate_targets, .ttf.o, .ttf.S) \
+	   $(call intermediate_targets, .bmp.o, .bmp.S)
+
 # Build
 # ---------------------------------------------------------------------------
 
scripts/Makefile.lib-u-boot +4 -4
index c55f8d8e0c3..4d60a8eee49 100644
@@ -20,8 +20,8 @@ cmd_S_ttf=						\
 	echo '.balign 16';				\
 ) > $@
 
-$(obj)/%.S: $(src)/%.ttf
-	$(call cmd,S_ttf)
+$(obj)/%.ttf.S: $(src)/%.ttf FORCE
+	$(call if_changed,S_ttf)
 
 # Splash logos
 # ---------------------------------------------------------------------------
@@ -40,8 +40,8 @@ cmd_S_splash=						\
 	echo '.balign 16';				\
 ) > $@
 
-$(obj)/%.S: $(src)/%.bmp
-	$(call cmd,S_splash)
+$(obj)/%.bmp.S: $(src)/%.bmp FORCE
+	$(call if_changed,S_splash)
 
 # EFI applications
 # A Makefile target *.efi is built as EFI application.

---
base-commit: e2fa3e570f83ab0f9ce667ddaec9dc738bcf05b9
branch: font-us4

Signature · 1 line
2.43.0
Reviewed-by on v4 2/2
#2 lore raw

Re: [PATCH v4 2/2] kbuild: Use if_changed for font and splash .incbin rules

Quoted 25 lines · Simon Glass

The generated .S files for fonts and splash screens use .incbin with the full prerequisite path. When building with O= this bakes an absolute path into the .S file. If the build directory is later used on a different machine (e.g. in a container), the assembler cannot find the source file.

Follow the existing DTB convention: rename the object targets to use compound suffixes (.ttf.o, .bmp.o), switch the pattern rules from direct $(call cmd,...) to FORCE + $(call if_changed,...), and register the new suffixes with intermediate_targets so that kbuild loads their .cmd files. This lets if_changed detect when the recorded command (including source paths) has changed and regenerate the .S file automatically.

The EFI rule is left unchanged since its prerequisite is a generated file in the build directory, like the DTB and DTBO rules.

The intermediate_targets entries stay in scripts/Makefile.build rather than moving to scripts/Makefile.lib-u-boot, because that file is included before intermediate_targets is defined and 'targets' is ':=', so a '$(call intermediate_targets, ...)' inside it would expand to empty and silently drop the entries. To keep the upstream block untouched, the U-Boot additions go in a separate 'targets +=' block immediately below.

Quoted 2 lines
Reviewed-by on v4 1/2
#3 lore raw
In reply to Simon Glass
Quoted 9 lines · Simon Glass

The font, splash-screen and EFI .incbin wrapper rules are U-Boot additions that do not exist in the upstream Linux kbuild. Keeping them in scripts/Makefile.lib makes re-syncing with Linux harder than it needs to be, as every sync must manually preserve the U-Boot additions.

Move these rules into a new scripts/Makefile.lib-u-boot and include it from Makefile.build and Makefile.xpl, right after the existing Makefile.lib include.

Quoted 5 lines

This is a pure code-move with no functional change.

#4 lore raw
In reply to Simon Glass
Quoted 10 lines · Simon Glass

The font, splash-screen and EFI .incbin wrapper rules are U-Boot additions that do not exist in the upstream Linux kbuild. Keeping them in scripts/Makefile.lib makes re-syncing with Linux harder than it needs to be, as every sync must manually preserve the U-Boot additions.

Move these rules into a new scripts/Makefile.lib-u-boot and include it from Makefile.build and Makefile.xpl, right after the existing Makefile.lib include.

[...]

Applied to u-boot/master, thanks!

[1/2] kbuild: Move U-Boot .incbin rules to Makefile.lib-u-boot

      commit: 24b99d293344d92d902cbc184e8d9665e6a437b2
[2/2] kbuild: Use if_changed for font and splash .incbin rules
      commit: 09297182ad79a4ea30fd6aa74d33646efc4eb12f
Signature · 1 line
Tom