-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
71 lines (47 loc) · 1.1 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
65
66
67
68
TARGET=ShakeYourHead
CSRCS=$(shell find . -name "*.c")
ASMSRCS=$(shell find . -name "*.S")
CFLAGS+=-Wall
CFLAGS+=-mcpu=cortex-m4
CFLAGS+=-mthumb
CFLAGS+=-g
CFLAGS+=-I./Lib/
CFLAGS+=-DSTM32F40_41xxx
CFLAGS+=-DUSE_STDPERIPH_DRIVER
LDFLAGS+=-TSTM32_flash.ld
LDFLAGS+=-nostartfiles
LDFLAGS+=-mcpu=cortex-m4
LDFLAGS+=-mthumb
LDFLAGS+=-g
LDFLAGS+=-lm
DEPFLAGS+=-MT $@ -MMD -MP -MF $*.d
STFLASH=st-flash
ifeq ($(CC),cc)
CC=gcc
endif
SIZE?=size
OBJCOPY?=objcopy
CROSS?=arm-none-eabi-
OBJS=$(CSRCS:.c=.o)
OBJS+=$(ASMSRCS:.S=.o)
all: executable binary info
executable: $(OBJS) Makefile
$(CROSS)$(CC) $(OBJS) $(LDFLAGS) -o $(TARGET).elf
binary: executable Makefile
$(CROSS)$(OBJCOPY) -O binary $(TARGET).elf $(TARGET).bin
info: binary
$(CROSS)$(SIZE) -A $(TARGET).elf
flash: binary
$(STFLASH) write $(TARGET).bin 0x08000000
%.o : %.c %.d Makefile
$(CROSS)$(CC) $(CFLAGS) $(DEPFLAGS) -c $< -o $@
%.o : %.S Makefile
$(CROSS)$(CC) $(CFLAGS) -c $< -o $@
clean:
rm -f $(OBJS)
rm -f $(CSRCS:.c=.d)
rm -f $(TARGET).elf
rm -f $(TARGET).bin
%.d: ;
.PRECIOUS: %.d
-include $(patsubst %,%.d,$(basename $(CSRCS)))