-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
66 lines (48 loc) · 1.11 KB
/
Makefile
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
56
57
58
59
60
61
62
63
64
65
SOURCES = \
main.c \
twi.c
TARGET = firmware
OBJECTS = $(SOURCES:%.c=%.o)
CFLAGS = -mmcu=attiny85 \
-DF_CPU=8000000UL \
-Os \
-funsigned-char \
-funsigned-bitfields \
-fpack-struct \
-fshort-enums \
-fno-unit-at-a-time \
-Wall \
-Wextra \
-Werror \
-std=gnu11
LDFLAGS = -Wl,-Map=$(TARGET).map,--cref
AVRDUDE_PROGRAMMER = stk500v2
AVRDUDE_PORT = /dev/ttyACM0
CC = avr-gcc
OBJCOPY = avr-objcopy
OBJDUMP = avr-objdump
SIZE = avr-size
NM = avr-nm
AVRDUDE = avrdude
all: $(TARGET).hex $(TARGET).lss $(TARGET).sym size
flash: all
$(AVRDUDE) -p attiny85 -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER) -U flash:w:$(TARGET).hex -U lfuse:w:0xE2:m -U hfuse:w:0xDF:m -U efuse:w:0xFF:m
%.hex: %.elf
$(OBJCOPY) -O ihex -j .data -j .text $< $@
%.lss: %.elf
$(OBJDUMP) -h -S $< > $@
%.sym: %.elf
$(NM) -n $< > $@
%.elf: $(OBJECTS)
$(CC) $(CFLAGS) $^ -o $@ $(LDFLAGS)
%.o : %.c
$(CC) -c $(CFLAGS) $< -o $@
size: $(TARGET).elf
avr-size --mcu=attiny85 -C $(TARGET).elf
clean:
$(RM) $(TARGET).elf
$(RM) $(TARGET).hex
$(RM) $(TARGET).lss
$(RM) $(TARGET).sym
$(RM) $(OBJECTS)
.PHONY: all flash size clean