-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
41 lines (29 loc) · 961 Bytes
/
Makefile
File metadata and controls
41 lines (29 loc) · 961 Bytes
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
MMCU=atmega328p
F_CPU=12000000UL
CFLAGS=-g -Wall -mmcu=${MMCU} -DF_CPU=${F_CPU} -Os -mcall-prologues -std=c99
# CFLAGS=-g -Wall -mmcu=${MMCU} -DF_CPU=${F_CPU} -Os -mcall-prologues -DDEBUG -std=c99
TARGET = main
SRC = $(wildcard src/*.c) $(wildcard src/controller/*.c) $(wildcard src/drivers/*.c) $(wildcard src/interfaces/*.c) $(wildcard src/graphics/*.c)
OBJ = $(SRC:%.c=%.o)
# use a different port depending on OS
PORT=/dev/tty.usbmodem*
ifeq ($(OS), Windows_NT)
PORT=COM5
endif
flash: build
avrdude -p ${MMCU} -c arduino -P $(PORT) -vv -U flash:w:$(TARGET).hex
build: $(TARGET).hex size
%.hex: $(TARGET).elf
avr-objcopy -O ihex $< $@
%.elf: $(OBJ)
avr-gcc ${CFLAGS} $^ -o $@
%.o: %.c
avr-gcc -c ${CFLAGS} $< -o $@
clean:
rm -f $(TARGET).elf $(OBJ) $(TARGET).hex
size: $(TARGET).elf
avr-size --format=avr --mcu=$(MMCU) $^
size-o:$(OBJ)
avr-size --format=berkeley --mcu=$(MMCU) -d $^
.PHONY: flash build clean size
.DEFAULT_GOAL := build