diff options
Diffstat (limited to 'software/Makefile')
-rw-r--r-- | software/Makefile | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/software/Makefile b/software/Makefile new file mode 100644 index 0000000..a30ec88 --- /dev/null +++ b/software/Makefile @@ -0,0 +1,55 @@ +PROG = traffic-light +OBJS = main.o +MCU_TARGET = attiny9 +OPTIMIZE = -Os -fshort-enums + +# You should not have to change anything below here. +CC = avr-gcc + +# Override is only needed by avr-lib build system. +override CFLAGS = -MMD -g -Wall -Wextra $(OPTIMIZE) -mmcu=$(MCU_TARGET) +override LDFLAGS = -Wl,-Map,$(PROG).map,--relax -fwhole-program + +OBJCOPY = avr-objcopy +OBJDUMP = avr-objdump +SIZE = avr-size + +# Main rule +all: $(PROG).elf lst text size + +.PHONY: all + +# Rules for maintenance +clean: + rm -rf *.o *.d $(PROG).elf *.bak + rm -rf *.lst *.map *.hex *.bin $(EXTRA_CLEAN_FILES) + +.PHONY: clean + +# Rules for building objects +-include *.d + +$(PROG).elf: $(OBJS) + $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(OBJS) + +size: $(PROG).elf + @avr-size -C --mcu=$(MCU_TARGET) $^ + +# Rules for building the list file +lst: $(PROG).lst + +%.lst: %.elf + $(OBJDUMP) -h -S $< > $@ + +# Rules for building the .text rom images + +text: hex + +hex: $(PROG).hex + +%.hex: %.elf + $(OBJCOPY) -j .text -j .data -j .rodata -O ihex $< $@ + +# Rules for flashing +flash: hex + avrdude -c avrispmkII -p t9 -U flash:w:$(PROG).hex |