kbuild: unify cmd_dt_S_dtb and cmd_dt_S_dtbo
PATCH 1/1 kbuild: unify cmd_dt_S_dtb and cmd_dt_S_dtbo
cmd_dt_S_dtb and cmd_dt_S_dtbo are almost the same; the only differnce is the prefix of the bein/end symbols. (__dtb vs __dtbo)
---
scripts/Makefile.lib | 45 +++++++++++++++----------------------------- 1 file changed, 15 insertions(+), 30 deletions(-)
scripts/Makefile.lib +15 -30
@@ -368,40 +368,25 @@ DTC_FLAGS += $(DTC_FLAGS_$(basetarget)) DTC_FLAGS += $(if $(filter $(patsubst $(obj)/%,%,$@), $(base-dtb-y)), -@) # Generate an assembly file to wrap the output of the device tree compiler -quiet_cmd_dt_S_dtb= DTBS $@ -cmd_dt_S_dtb= \ -{ \ - echo '\#include <asm-generic/vmlinux.lds.h>'; \ - echo '.section .dtb.init.rodata,"a"'; \ - echo '.balign STRUCT_ALIGNMENT'; \ - echo '.global __dtb_$(subst -,_,$(*F))_begin'; \ - echo '__dtb_$(subst -,_,$(*F))_begin:'; \ - echo '.incbin "$<" '; \ - echo '__dtb_$(subst -,_,$(*F))_end:'; \ - echo '.global __dtb_$(subst -,_,$(*F))_end'; \ - echo '.balign STRUCT_ALIGNMENT'; \ -} > $@ +quiet_cmd_wrap_S_dtb = WRAP $@ + cmd_wrap_S_dtb = { \ + symbase=__$(patsubst .%,%,$(suffix $<))_$(subst -,_,$(notdir $*)); \ + echo '\#include <asm-generic/vmlinux.lds.h>'; \ + echo '.section .dtb.init.rodata,"a"'; \ + echo '.balign STRUCT_ALIGNMENT'; \ + echo ".global $${symbase}_begin"; \ + echo "$${symbase}_begin:"; \ + echo '.incbin "$<" '; \ + echo ".global $${symbase}_end"; \ + echo "$${symbase}_end:"; \ + echo '.balign STRUCT_ALIGNMENT'; \ + } > $@ $(obj)/%.dtb.S: $(obj)/%.dtb FORCE - $(call if_changed,dt_S_dtb) - -# Generate an assembly file to wrap the output of the device tree compiler -quiet_cmd_dt_S_dtbo= DTBOS $@ -cmd_dt_S_dtbo= \ -{ \ - echo '\#include <asm-generic/vmlinux.lds.h>'; \ - echo '.section .dtb.init.rodata,"a"'; \ - echo '.balign STRUCT_ALIGNMENT'; \ - echo '.global __dtbo_$(subst -,_,$(*F))_begin'; \ - echo '__dtbo_$(subst -,_,$(*F))_begin:'; \ - echo '.incbin "$<" '; \ - echo '__dtbo_$(subst -,_,$(*F))_end:'; \ - echo '.global __dtbo_$(subst -,_,$(*F))_end'; \ - echo '.balign STRUCT_ALIGNMENT'; \ -} > $@ + $(call if_changed,wrap_S_dtb) $(obj)/%.dtbo.S: $(obj)/%.dtbo FORCE - $(call if_changed,dt_S_dtbo) + $(call if_changed,wrap_S_dtb) quiet_cmd_dtc = DTC $@ cmd_dtc = $(HOSTCC) -E $(dtc_cpp_flags) -x assembler-with-cpp -o $(dtc-tmp) $< ; \
Signature · 1 line
2.34.1
Quoted 2 lines · On Fri, Dec 30, 2022 at 03:46:50AM +0900 Masahiro Yamada wrote:
cmd_dt_S_dtbandcmd_dt_S_dtboare almost the same; the only differnce is the prefix of the bein/end symbols. (__dtbvs__dtbo)
Two letters got lost: differ_e_nce, be_g_in.
Quoted 21 lines
Signed-off-by Masahiro Yamada <[email protected]>---
scripts/Makefile.lib | 45 +++++++++++++++----------------------------- 1 file changed, 15 insertions(+), 30 deletions(-)scripts/Makefile.lib +0
-6@@ -368,40 +368,25 @@ DTC_FLAGS += $(DTC_FLAGS_$(basetarget)) DTC_FLAGS += $(if $(filter $(patsubst $(obj)/%,%,$@), $(base-dtb-y)), -@) # Generate an assembly file to wrap the output of the device tree compiler -quiet_cmd_dt_S_dtb= DTBS $@ -cmd_dt_S_dtb= \ -{ \ - echo '\#include <asm-generic/vmlinux.lds.h>'; \ - echo '.section .dtb.init.rodata,"a"'; \ - echo '.balign STRUCT_ALIGNMENT'; \
scripts/Makefile.lib DTC_FLAGS += $(DTC_FLAGS_$(basetarget)) · line 373
Quoted 10 lines
scripts/Makefile.lib +3
-7- echo '.global __dtb_$(subst -,_,$(*F))_begin'; \ - echo '__dtb_$(subst -,_,$(*F))_begin:'; \ - echo '.incbin "$<" '; \ - echo '__dtb_$(subst -,_,$(*F))_end:'; \ - echo '.global __dtb_$(subst -,_,$(*F))_end'; \ - echo '.balign STRUCT_ALIGNMENT'; \ -} > $@ +quiet_cmd_wrap_S_dtb = WRAP $@ + cmd_wrap_S_dtb = { \ + symbase=__$(patsubst .%,%,$(suffix $<))_$(subst -,_,$(notdir $*)); \
As long as I know, '$(notdir $*)' should be equivalent to '$(*F)'. Is it just personal preference or is there some other reason for choosing one or the other?
Nevertheless, with the typos fixed, it looks good to me:
Quoted 6 lines · Nicolas Schier
Quoted 2 lines · On Fri, Dec 30, 2022 at 03:46:50AM +0900 Masahiro Yamada wrote:
cmd_dt_S_dtbandcmd_dt_S_dtboare almost the same; the only differnce is the prefix of the bein/end symbols. (__dtbvs__dtbo)Two letters got lost:
differ_e_nce,be_g_in.
Ah, thanks. I will fix it.
Quoted 28 lines
Quoted 28 lines
Signed-off-by Masahiro Yamada <[email protected]>---
scripts/Makefile.lib | 45 +++++++++++++++----------------------------- 1 file changed, 15 insertions(+), 30 deletions(-)scripts/Makefile.lib +0
-12@@ -368,40 +368,25 @@ DTC_FLAGS += $(DTC_FLAGS_$(basetarget)) DTC_FLAGS += $(if $(filter $(patsubst $(obj)/%,%,$@), $(base-dtb-y)), -@) # Generate an assembly file to wrap the output of the device tree compiler -quiet_cmd_dt_S_dtb= DTBS $@ -cmd_dt_S_dtb= \ -{ \ - echo '\#include <asm-generic/vmlinux.lds.h>'; \ - echo '.section .dtb.init.rodata,"a"'; \ - echo '.balign STRUCT_ALIGNMENT'; \ - echo '.global __dtb_$(subst -,_,$(*F))_begin'; \ - echo '__dtb_$(subst -,_,$(*F))_begin:'; \ - echo '.incbin "$<" '; \ - echo '__dtb_$(subst -,_,$(*F))_end:'; \ - echo '.global __dtb_$(subst -,_,$(*F))_end'; \ - echo '.balign STRUCT_ALIGNMENT'; \
Quoted 8 lines
scripts/Makefile.lib DTC_FLAGS += $(DTC_FLAGS_$(basetarget)) · line 373
Quoted 4 lines
scripts/Makefile.lib +3
-1-} > $@ +quiet_cmd_wrap_S_dtb = WRAP $@ + cmd_wrap_S_dtb = { \ + symbase=__$(patsubst .%,%,$(suffix $<))_$(subst -,_,$(notdir $*)); \As long as I know, '$(notdir $*)' should be equivalent to '$(*F)'. Is it just personal preference or is there some other reason for choosing one or the other?
Your understanding is correct.
Automatic variables can have 'D' / 'F', as explained in the manual.
https://www.gnu.org/software/make/manual/html_node/Automatic-Variables.html
Yes, it is just my personal preference.
Perhaps, I did not need to change it, though.
Quoted 3 lines
Nevertheless, with the typos fixed, it looks good to me:
Reviewed-by Nicolas Schier <[email protected]>
Signature · 2 lines
Best Regards Masahiro Yamada