diff --git a/mk/elf.mk b/mk/elf.mk index 974faac9..b607c62d 100644 --- a/mk/elf.mk +++ b/mk/elf.mk @@ -22,18 +22,16 @@ LD_SUPPLEMENT := $(addprefix $(OUT)/,$(LD_SUPPLEMENT:.ld.sx=.ld)) elf: $(ELF) -$(ELF): $(DEP_LIBS) $(DEP_OBJS) $(LD_SCRIPT) $(LD_SUPPLEMENT) +.SECONDEXPANSION: +$(ELF): $(SIZE) $(DEP_LIBS) $(DEP_OBJS) $(LD_SCRIPT) $(LD_SUPPLEMENT) | $$(SIZE) @echo "Elf: Generating $(@F) ..." $(LD) -dT $(LD_SCRIPT) $(addprefix -T , $(LD_SUPPLEMENT)) $(LD_FLAGS) -Map=$(@:.elf=.map) -o $@ $(filter %.o, $^) $(DEP_LIB_PATH) $(DEP_LIBS_ARG) -L $(TL) -lgcc $(OD) -Dx -h --wide $@ > $(@:.elf=.lst) $(OC) -O binary $@ $(@:.elf=.bin) $(OC) -O ihex $@ $(@:.elf=.hex) - @echo "==================================================" - @echo "Size of Executable:" @cd $(@D); $(SIZE) $(@F) @echo "" -.SECONDEXPANSION: $(OUT)/%.ld: %.ld.sx mkdir -p $(@D) @echo "Elf: Preprocessing $(@F) ..." diff --git a/mk/tc.mk b/mk/tc.mk index ace7b061..7abd3e42 100644 --- a/mk/tc.mk +++ b/mk/tc.mk @@ -39,7 +39,6 @@ OD := $(TC)-objdump OC := $(TC)-objcopy STRIP := $(TC)-strip A2L := $(TC)-addr2line -SIZE := $(TC)-size endif ifeq ($(realpath $(TI)),) diff --git a/mk/tc_get.mk b/mk/tc_get.mk index 285bc78b..cfc1868f 100644 --- a/mk/tc_get.mk +++ b/mk/tc_get.mk @@ -14,6 +14,7 @@ T_ALLOWLIST += get_all_tc get_avr_tc get_arm_tc get_riscv_tc # GIT REPO RECOMMENDED # Provide git repo path for toolchains for better experience +ESIZE_REPO := https://github.com/VisorFolks/cc_elf_size.git AVR_TC_REPO ?= RISC_V_TC_REPO ?= ARM_TC_REPO ?= @@ -23,6 +24,13 @@ get_all_tc: --tc_clear get_avr_tc get_arm_tc get_riscv_tc --tc_clear: rm -rf $(TOOLS_ROOT) +SIZE := $(TOOLS_ROOT)/cc_elf_size/size +$(SIZE): + $(info < ! > Fetching ELF-Size utility ...) + cd $(TOOLS_ROOT); git clone $(ESIZE_REPO); + make -C $(@D) + echo "< / > Done !" + get_arm_tc: $(TOOLS_ROOT)/arm-toolchain/bin/arm-none-eabi-gcc $(TOOLS_ROOT)/arm-toolchain/bin/arm-none-eabi-gcc: ifeq ($(ARM_TC_REPO),)