summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile21
1 files changed, 15 insertions, 6 deletions
diff --git a/Makefile b/Makefile
index 9dc7daa..b3e7d33 100644
--- a/Makefile
+++ b/Makefile
@@ -1,21 +1,30 @@
.PHONY: flash love
-TARGET=lightctrl
+TARGETS=door lightctrl
+
CFLAGS_OPT=-Os \
-fpredictive-commoning -fmerge-all-constants -fmodulo-sched -fmodulo-sched-allow-regmoves \
-fgcse-sm -fgcse-las -fgcse-after-reload -fconserve-stack \
-fwhole-program
CFLAGS_WARN=-std=gnu99 -Wall -Wextra -Wno-unused -pedantic
CFLAGS_LD=-Wl,-T,avr4-signature.x
-CFLAGS=-mmcu=atmega48 ${CFLAGS_WARN} ${CFLAGS_OPT} ${CFLAGS_LD}
+CFLAGS=${CFLAGS_WARN} ${CFLAGS_OPT} ${CFLAGS_LD}
+MCU_door=48
+MCU_lightctrl=88
-love: ${TARGET}.elf
+love: $(foreach target,$(TARGETS),$(target).elf)
+ avr-size $^
+ifdef TARGET
flash: ${TARGET}.flash
- avrdude -p m48 -c stk500v2 -P avrdoper -y -U flash:w:$<
+ avrdude -p m$(MCU_$(basename $<)) -c stk500v2 -P avrdoper -y -U flash:w:$<
+else
+flash:
+ @echo the flash target is available only with TARGET set to something. use e.g. \"make flash TARGET=door\" >&2
+ @false
+endif
%.flash: %.elf Makefile
avr-objcopy -j .text -j .data -O ihex $< $@
%.elf: %.c *.c *.x Makefile
- avr-gcc ${CFLAGS} -o $@ $<
- avr-size $@
+ avr-gcc -mmcu=atmega$(MCU_$(basename $@)) ${CFLAGS} -o $@ $<