-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
97 lines (69 loc) · 2.21 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
NAME=main
STMDIR=lib
SRCDIR=src
OBJDIR=obj
INCDIR=inc
LDDIR=$(INCDIR)
###################################################
CC=arm-none-eabi-gcc
LD=arm-none-eabi-gcc
CP=arm-none-eabi-objcopy
SF=st-flash
###################################################
INCDIR += $(STMDIR)/STM32F0xx_HAL_Driver/Inc
INCDIR += $(STMDIR)/CMSIS/Include
INCDIR += $(STMDIR)/CMSIS/Device/ST/STM32F0xx/Include
INCLUDE = $(addprefix -I,$(INCDIR))
###################################################
CFLAGS = -std=gnu99 -g -O2 -Wall -Wextra -Wduplicated-cond -Wduplicated-branches -Wlogical-op -TSTM32F072RB_FLASH.ld
CFLAGS += -mlittle-endian -mthumb -mthumb-interwork -mcpu=cortex-m0
CFLAGS += -fsingle-precision-constant -Wdouble-promotion
CFLAGS += -DSTM32F072xB
CFLAGS += --specs=nosys.specs
###################################################
SRCS = $(wildcard $(SRCDIR)/*.c)
SRCS += $(wildcard $(SRCDIR)/*.s)
###################################################
OBJS = $(addprefix $(OBJDIR)/,$(addsuffix .o,$(basename $(notdir $(SRCS)))))
#SRCS = main.c \
dwm1000.c \
stm32f0xx_it.c \
system_stm32f0xx.c \
stm32f0xx_hal_msp.c \
startup_stm32f072xb.s
#SRCS += stm32f0xx_hal.c \
stm32f0xx_hal_rcc.c \
stm32f0xx_hal_rcc_ex.c \
stm32f0xx_hal_cortex.c \
stm32f0xx_hal_gpio.c \
stm32f0xx_hal_spi.c \
stm32f0xx_hal_uart.c \
stm32f0xx_hal_dma.c \
stm32f0xx_hal_uart_ex.c \
###################################################
LDDIR += $(STMDIR)
LDFLAGS = $(addprefix -L, $(LDDIR))
LDFLAGS += -TSTM32F072RB_FLASH.ld
LDFLAGS += -mlittle-endian -mthumb -mthumb-interwork -mcpu=cortex-m0
LDFLAGS += -fsingle-precision-constant -Wdouble-promotion
LDFLAGS += -DSTM32F072xB
LDFLAGS += --specs=nosys.specs
###################################################
.PHONY: all lib proj clean flash
all: lib proj
proj: $(OBJDIR)/$(NAME).bin
lib:
$(MAKE) -C $(STMDIR)
%.bin: %.elf
$(CP) -O binary $< $@
$(OBJDIR)/$(NAME).elf: $(STMDIR)/libstm32f0.a $(OBJS)
$(CC) $(LDFLAGS) -o $@ $(OBJS) -lm -lstm32f0
$(OBJDIR)/%.o: $(SRCDIR)/%.c
$(CC) -MMD $(INCLUDE) $(CFLAGS) -c $< -o $@
$(OBJDIR)/%.o: $(SRCDIR)/%.s
$(CC) -MMD $(INCLUDE) $(CFLAGS) -c $< -o $@
clean:
rm -f $(OBJDIR)/*
flash: $(OBJDIR)/$(NAME).bin
$(SF) write $< 0x8000000
-include $(wildcard $(OBJDIR)/*.d)