-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
74 lines (55 loc) · 1.73 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
PREFIX = arm-none-eabi-
CXX = g++
CC = gcc
LD = gcc
OBJDUMP = objdump
OBJCOPY = objcopy
OBJS = $(patsubst system/%,build/system/%.o,$(shell find system/ -name '*.c' -or -name '*.cpp'))
OBJS += $(patsubst src/%,build/src/%.o,$(shell find src/ -name '*.c' -or -name '*.cpp'))
DEPS = $(OBJS:%.o=%.d)
DEFS += -DSTM32F746xx
DEFS += -DUSE_HAL_DRIVER
INCS += -Iinclude
INCS += -Isystem/include
INCS += -Isystem/include/stm32f7-hal
INCS += -Isystem/include/cmsis
INCS += -Isystem/include/arm
INCS += -Isystem/include/components
INCS += -Isystem/inclue/cortexm
INCS += -Isystem/include/bsp
ARCH_FLAGS = -mthumb -march=armv7e-m+fpv5
CXXFLAGS += -std=gnu++11
CFLAGS += -std=gnu11
CPPFLAGS += -ggdb3 -Wall -Wpedantic -MD $(DEFS) $(INCS) $(ARCH_FLAGS)
LDSCRIPT = system/stm32f746-disco.ld
LDFLAGS += -static -nostartfiles
LDFLAGS += $(ARCH_FLAGS)
LDLIBS += -Wl,-lc -Wl,-lgcc -Wl,-lnosys
MAKEFLAGS += --no-print-directory
.SILENT:
.SECONDARY:
.PHONY: clean all flash
all: build/firmware.elf build/firmware.bin
%.bin: %.elf
printf " OBJCOPY $(*).bin\n"
$(PREFIX)$(OBJCOPY) -Obinary $(*).elf $(*).bin
%.list: %.elf
printf " OBJDUMP $(*).list\n"
$(PREFIX)$(OBJDUMP) -S $(*).elf > $(*).list
build/firmware.elf: $(OBJS) $(LDSCRIPT)
printf " LD $(@)\n"
$(PREFIX)$(LD) $(LDFLAGS) -T$(LDSCRIPT) $(OBJS) $(LDLIBS) -o $@
build/%.c.o: %.c
@mkdir -p $(@D)
printf " CC $(*).c\n"
$(PREFIX)$(CC) $(CFLAGS) $(CPPFLAGS) -o $@ -c $<
build/%.cpp.o: %.cpp
@mkdir -p $(@D)
printf " CXX $(*).cpp\n"
$(PREFIX)$(CXX) $(CXXFLAGS) $(CPPFLAGS) -o $@ -c $<
flash: build/firmware.bin
$(PREFIX)gdb -ex "set confirm off" -ex "load" -ex "monitor reset run" -ex "quit"
clean:
printf " CLEAN\n"
$(RM) -r build/
-include $(DEPS)