-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
53 lines (40 loc) · 943 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
44
45
46
47
48
49
50
51
52
53
CC=avr-gcc
LD=avr-ld
OBJCOPY=avr-objcopy
OBJDUMP=avr-objdump
AVRSIZE=avr-size
MCU=atmega328p
CFLAGS=-Os -Werror -std=gnu99 -DF_CPU=16000000UL -mmcu=${MCU}
LDFLAGS=-mmcu=$(MCU)
PORT=/dev/ttyACM0
BIN=lab05
OUT=${BIN}.elf ${BIN}.hex ${BIN}.lss
SOURCES = \
main.c \
serial.c \
gpio.c \
adc.c \
timer.c \
i2c.c \
util.c
OBJS = $(SOURCES:.c=.o)
all: $(OUT)
$(OBJS): Makefile
#-include $(OBJS:.o=,P)
%.o:%.c
$(COMPILE.c) -MD -o $@ $<
@cp $*.d $*.P; \
sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \
-e '/^$$/ d' -e 's/$$/ :/' < $*.d >> $*.P; \
rm -f $*.d
%.lss: %.elf
$(OBJDUMP) -h -S -s $< > $@
%.elf: $(OBJS)
$(CC) -Wl,-Map=$(@:.elf=.map) $(LDFLAGS) -o $@ $^
$(AVRSIZE) $@
%.hex: %.elf
$(OBJCOPY) -O ihex -R .fuse -R .lock -R .user_signatures -R .comment $< $@
flash: ${BIN}.hex
avrdude -F -V -c arduino -p ${MCU} -P ${PORT} -b 115200 -U flash:w:$<
clean:
rm -f $(OUT) $(OBJS) *.map *.P