aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Phillips <david@yeah.nah.nz>2021-02-08 19:18:27 +1300
committerDavid Phillips <david@yeah.nah.nz>2021-02-08 19:18:27 +1300
commit8b7171966d8589afe7fb802f84204b059602ae3c (patch)
treee31931847db51e1133b0db7c1979e0007aabd4b3
parent01bb1bffb603461cf39ecf630f8817cfe1645263 (diff)
downloadaltimeter-8b7171966d8589afe7fb802f84204b059602ae3c.tar.xz
Print cross ELF section size on make
-rw-r--r--Makefile13
1 files 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