diff --git a/core/arch/arm/kernel/link.mk b/core/arch/arm/kernel/link.mk index d1d52722442..11fe79d982c 100644 --- a/core/arch/arm/kernel/link.mk +++ b/core/arch/arm/kernel/link.mk @@ -140,39 +140,6 @@ $(link-script-pp): $(link-script) $(link-script-extra-deps) $(q)$(CPPcore) -P -MT $@ -MD -MF $(link-script-dep) \ $(link-script-cppflags) $< -o $@ -define update-buildcount - @$(cmd-echo-silent) ' UPD $(1)' - $(q)if [ ! -f $(1) ]; then \ - mkdir -p $(dir $(1)); \ - echo 1 >$(1); \ - else \ - expr 0`cat $(1)` + 1 >$(1); \ - fi -endef - -# filter-out to workaround objdump warning -version-o-cflags = $(filter-out -g3,$(CFLAGS) $(core-platform-cflags) \ - $(platform-cflags) $(cflagscore)) -# SOURCE_DATE_EPOCH defined for reproducible builds -ifneq ($(SOURCE_DATE_EPOCH),) -date-opts = -d @$(SOURCE_DATE_EPOCH) -endif -DATE_STR = `LC_ALL=C date -u $(date-opts)` -BUILD_COUNT_STR = `cat $(link-out-dir)/.buildcount` -CORE_CC_VERSION = `$(CCcore) -v 2>&1 | grep "version " | sed 's/ *$$//'` -define gen-version-o - $(call update-buildcount,$(link-out-dir)/.buildcount) - @$(cmd-echo-silent) ' GEN $(link-out-dir)/version.o' - $(q)cd $(link-out-dir) && \ - echo -e "const char core_v_str[] =" \ - "\"$(TEE_IMPL_VERSION) \"" \ - "\"($(CORE_CC_VERSION)) \"" \ - "\"#$(BUILD_COUNT_STR) \"" \ - "\"$(DATE_STR) \"" \ - "\"$(CFG_KERN_LINKER_ARCH)\";\n" \ - | $(CCcore) $(version-o-cflags) \ - -xc - -c -o version.o -endef $(link-out-dir)/version.o: $(call gen-version-o) diff --git a/core/arch/riscv/kernel/link.mk b/core/arch/riscv/kernel/link.mk index 6511586e2a5..d7b676cbf43 100644 --- a/core/arch/riscv/kernel/link.mk +++ b/core/arch/riscv/kernel/link.mk @@ -51,40 +51,6 @@ $(link-script-pp): $(link-script) $(link-script-extra-deps) $(q)$(CPPcore) -P -MT $@ -MD -MF $(link-script-dep) \ $(link-script-cppflags) $< -o $@ -define update-buildcount - @$(cmd-echo-silent) ' UPD $(1)' - $(q)if [ ! -f $(1) ]; then \ - mkdir -p $(dir $(1)); \ - echo 1 >$(1); \ - else \ - expr 0`cat $(1)` + 1 >$(1); \ - fi -endef - -# filter-out to workaround objdump warning -version-o-cflags = $(filter-out -g3,$(CFLAGS) $(core-platform-cflags) \ - $(platform-cflags) $(cflagscore)) -# SOURCE_DATE_EPOCH defined for reproducible builds -ifneq ($(SOURCE_DATE_EPOCH),) -date-opts = -d @$(SOURCE_DATE_EPOCH) -endif -DATE_STR = `LC_ALL=C date -u $(date-opts)` -BUILD_COUNT_STR = `cat $(link-out-dir)/.buildcount` -CORE_CC_VERSION = `$(CCcore) -v 2>&1 | grep "version " | sed 's/ *$$//'` -define gen-version-o - $(call update-buildcount,$(link-out-dir)/.buildcount) - @$(cmd-echo-silent) ' GEN $(link-out-dir)/version.o' - $(q)cd $(link-out-dir) && \ - echo -e "const char core_v_str[] =" \ - "\"$(TEE_IMPL_VERSION) \"" \ - "\"($(CORE_CC_VERSION)) \"" \ - "\"#$(BUILD_COUNT_STR) \"" \ - "\"$(DATE_STR) \"" \ - "\"$(CFG_KERN_LINKER_ARCH)\";\n" \ - | $(CCcore) $(version-o-cflags) \ - -xc - -c -o version.o -endef - $(link-out-dir)/version.o: $(call gen-version-o) diff --git a/mk/macros.mk b/mk/macros.mk index 277ecf2212c..93d13fb22b2 100644 --- a/mk/macros.mk +++ b/mk/macros.mk @@ -7,3 +7,37 @@ define mv-if-changed mv $1 $2; \ fi endef + +define update-buildcount + @$(cmd-echo-silent) ' UPD $(1)' + $(q)if [ ! -f $(1) ]; then \ + mkdir -p $(dir $(1)); \ + echo 1 >$(1); \ + else \ + expr 0`cat $(1)` + 1 >$(1); \ + fi +endef + +# filter-out to workaround objdump warning +version-o-cflags = $(filter-out -g3,$(CFLAGS) $(core-platform-cflags) \ + $(platform-cflags) $(cflagscore)) +# SOURCE_DATE_EPOCH defined for reproducible builds +ifneq ($(SOURCE_DATE_EPOCH),) +date-opts = -d @$(SOURCE_DATE_EPOCH) +endif +DATE_STR = `LC_ALL=C date -u $(date-opts)` +CORE_CC_VERSION = `$(CCcore) -v 2>&1 | grep "version " | sed 's/ *$$//'` +define gen-version-o + $(call update-buildcount,$(link-out-dir)/.buildcount) + @$(cmd-echo-silent) ' GEN $(link-out-dir)/version.o' + $(q)cd $(link-out-dir) && \ + BUILD_COUNT_STR=`cat .buildcount` && \ + echo -e "const char core_v_str[] =" \ + "\"$(TEE_IMPL_VERSION) \"" \ + "\"($(CORE_CC_VERSION)) \"" \ + "\"#$${BUILD_COUNT_STR} \"" \ + "\"$(DATE_STR) \"" \ + "\"$(CFG_KERN_LINKER_ARCH)\";\n" \ + | $(CCcore) $(version-o-cflags) \ + -xc - -c -o version.o +endef