blob: a30ec8829cdf4bffde291c8261a49992dff1ed6e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
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
|