From 8b7171966d8589afe7fb802f84204b059602ae3c Mon Sep 17 00:00:00 2001 From: David Phillips Date: Mon, 8 Feb 2021 19:18:27 +1300 Subject: Print cross ELF section size on make --- Makefile | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 7b2f59b..7f8886e 100644 --- a/Makefile +++ b/Makefile @@ -2,11 +2,14 @@ include config.mk CC ?= gcc AVR_CC ?= avr-gcc +AVR_SIZE ?= avr-size GDB ?= avr-gdb OBJCOPY ?= avr-objcopy AVRDUDE ?= avrdude QEMU ?= qemu-system-avr +REAL_ELF = build/altimeter.elf + # options for native (i.e. unit test) UNITY_SRC ?= unity/src UNITY_O = $(UNITY_SRC)/unity.o @@ -29,7 +32,7 @@ SIM_LDFLAGS += $(AVR_COMMON_LDFLAGS) -mmcu=$(SIM_MCU) $(shell mkdir -p build/{real,sim,native}) -all: build/altimeter_sim.elf build/altimeter.hex test +all: build/altimeter_sim.elf build/altimeter.hex test size # Run the sim build software in qemu, halted ready for `make gdb` to attach and # continue. Note that sim build mocks out some hardware components @@ -62,6 +65,9 @@ build/altimeter.elf: \ build/real/util.o $(AVR_CC) $(AVR_LDFLAGS) -o $@ $^ +size: + [ -f "$(REAL_ELF)" ] && $(AVR_SIZE) "$(REAL_ELF)" + # ELF for simulator/emu. Note that whever I/O is required, the *_sim.{o,c} # versions of each component will provide a mocked interface. This allows for # operation in QEMU (see `emu` recipe) without requring SPI, I²C and @@ -85,7 +91,4 @@ build/native/%.o: %.c build/%.hex: build/%.elf $(OBJCOPY) -O ihex -R .eeprom $< $@ -build/%.elf: - $(AVR_CC) $(AVR_CFLAGS) -o $@ $^ - -.PHONY: all emu gdb flash clean test +.PHONY: all emu gdb flash clean test size -- cgit v1.1