-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
64 lines (48 loc) · 1.19 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
CC = avr-gcc
OBJCOPY = avr-objcopy
OBJDUMP = avr-objdump
AVRDUDE = avrdude
STTY = stty
ARDUINO_HEADERS = .
NAME = riis
MCU = atmega328p
F_CPU = 16000000UL
FORMAT = ihex
## Duemilanove
#PORT = /dev/ttyUSB0
#BAUD_RATE = 57600
## Uno
PORT = /dev/ttyACM0
BAUD_RATE = 115200
PROGRAMMER = arduino
CFLAGS = -O2 -g -mmcu=$(MCU) -DF_CPU=$(F_CPU) \
-funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums \
-Wall -Wextra -pedantic -I$(ARDUINO_HEADERS)
.PHONY: all list stty
.PRECIOUS: %.o %.elf
all: $(NAME).hex
%.o: %.c %.h
@echo ' CC $@'
@$(CC) $(CFLAGS) -c $< -o $@
%.o: %.c
@echo ' CC $@'
@$(CC) $(CFLAGS) -c $< -o $@
%.elf: %.o
@echo ' LD $@'
@$(CC) $(CFLAGS) $(LDFLAGS) $^ -o $@
%.hex: %.elf
@echo ' OBJCOPY $@'
@$(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@ && \
stat --format=' %s bytes' $@
# Create extended listing file from ELF output file.
%.lss: %.elf
@echo ' OBJDUMP $@'
@$(OBJDUMP) -h -S $< > $@
upload: $(NAME).hex
@$(AVRDUDE) -vD -c$(PROGRAMMER) -b$(BAUD_RATE) -p$(MCU) -P$(PORT) -Uflash:w:$<:i
list: $(NAME).lss
tty:
@echo ' STTY -F$(PORT) cs8 parenb raw -echo 57600'
@$(STTY) -F$(PORT) cs8 parenb raw -echo 57600
clean:
rm -f *.o *.elf *.hex *.lss