-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
60 lines (41 loc) · 1.28 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
TARGET = blinklights
# Target type
MCU=attiny13
PROGRAMMER=avrmkii
F_CPU=1000000
SRC = blinkylights.c
SRC += $(DRIVERS)
OBJ = $(SRC:.c=.o)
CC = avr-gcc
# Compiler / Linker flags:
CFLAGS = -mmcu=$(MCU) -Wall -Os -std=gnu99 -D F_CPU=$(F_CPU) -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums
LDFLAGS = -mmcu=$(MCU) -Wl,-Map=$(TARGET).map
###################################
# Makerules:
.PHONY: compile flash clean
compile: $(TARGET).hex $(TARGET).eep $(TARGET).lss
flash: compile
avrdude -c $(PROGRAMMER) -P usb -p $(MCU) -U flash:w:$(TARGET).hex
# sleep 2
# avrdude -c $(PROGRAMMER) -P usb -p $(MCU) -U eeprom:w:$(TARGET).eep
clean:
rm -f $(OBJ) $(TARGET).{elf,hex,lss,map,eep}
###################################
# Psudorules:
%.eep: %.hex
@echo " OBJCOPY ${<}"
@avr-objcopy -j .eeprom --set-section-flags=.eeprom="alloc,load" --change-section-lma .eeprom=0 --no-change-warnings -O ihex $< $@
%.hex: %.elf
@echo " OBJCOPY ${<}"
@avr-objcopy -O ihex -R .eeprom -R .fuse -R .lock -R .signature $< $@
%.lss: %.elf
@echo " OBJDUMP ${<}"
@avr-objdump -h -S $< > $@
@echo " SIZE ${<}"
@avr-size -C --mcu=$(MCU) $(TARGET).elf
%.elf: $(OBJ)
@echo " LN ${@}"
@avr-gcc $^ $(LDFLAGS) -o $@
%.o : %.c
@echo " CC ${<}"
@avr-gcc $(CFLAGS) -c $< -o $@