-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
42 lines (30 loc) · 851 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
MCU=atmega328p
F_CPU=8000000
CC=avr-gcc
OBJCOPY=avr-objcopy
CFLAGS=-Wall -g -Wl,-u,vfprintf -lprintf_flt -lm -Os -mmcu=${MCU} -DF_CPU=${F_CPU} -I.
AVRDUDE_FLAGS=-B 2
PORT=COM13
PROGRAMMER=usbasp
TARGET=main
SRC_DIRS=.
BUILD_DIR=./build
SRCS= $(shell find $(SRC_DIRS) -name '*.c')
OBJS := $(SRCS:%=$(BUILD_DIR)/%.o)
$(BUILD_DIR)/${TARGET}: $(OBJS)
${CC} ${CFLAGS} ${OBJS} -o $@.bin
${OBJCOPY} -j .text -j .data -O ihex $@.bin $@.hex
avr-size --mcu=${MCU} -C $@.bin
$(BUILD_DIR)/%.c.o: %.c
mkdir -p $(dir $@)
${CC} ${CFLAGS} -c $< -o $@
docs:
rm -rf html/ latex/
doxygen Doxyfile
flash:
avrdude -p ${MCU} ${AVRDUDE_FLAGS} -c ${PROGRAMMER} -U flash:w:${BUILD_DIR}/${TARGET}.hex:i -P ${PORT}
reset:
avrdude -p ${MCU} ${AVRDUDE_FLAGS} -c ${PROGRAMMER} -P ${PORT}
.PHONY: clean
clean:
rm -rf *.bin *.hex *.o ${BUILD_DIR} html/ latex/