-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
43 lines (30 loc) · 828 Bytes
/
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
TARGET=bbq
MCU=attiny2313
F_CPU=4000000UL
SOURCES=main.c
PROGRAMMER=avrispmkII
OBJECTS=$(SOURCES:.c=.o)
CFLAGS=-c -Os -DF_CPU=$(F_CPU) --std=gnu99 -Wall -g
LDFLAGS=
all: hex eeprom size
hex: $(TARGET).hex
eeprom: $(TARGET)_eeprom.hex
$(TARGET).hex: $(TARGET).elf
avr-objcopy -O ihex -j .data -j .text $(TARGET).elf $(TARGET).hex
$(TARGET)_eeprom.hex: $(TARGET).elf
avr-objcopy -O ihex -j .eeprom --change-section-lma .eeprom=1 $(TARGET).elf $(TARGET)_eeprom.hex
$(TARGET).elf: $(OBJECTS)
avr-gcc $(LDFLAGS) -mmcu=$(MCU) $(OBJECTS) -o $(TARGET).elf
.c.o:
avr-gcc $(CFLAGS) -mmcu=$(MCU) $< -o $@
size:
avr-size --mcu=$(MCU) -C $(TARGET).elf
program: hex eeprom size
avrdude -p $(MCU) -c $(PROGRAMMER) -Uflash:w:$(TARGET).hex:a
clean_tmp:
rm -rf *.o
rm -rf *.elf
clean:
rm -rf *.o
rm -rf *.elf
rm -rf *.hex