-
Notifications
You must be signed in to change notification settings - Fork 4
/
Makefile
70 lines (59 loc) · 1.4 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
CC := $(COMPILER_DIRS)arm-none-eabi-gcc
CXX := $(COMPILER_DIRS)arm-none-eabi-g++
TARGET_EXEC ?= app.elf
BUILD_DIR ?= ./build
SRC_DIRS := src
LDPATH := $(MKDIR)MDR32F9Qx.ld
SRCS := $(shell find $(SRC_DIRS) -name *.cpp -or -name *.c -or -name *.S)
OBJS := $(SRCS:%=$(BUILD_DIR)/%.o)
DEPS := $(OBJS:.o=.d)
INC_DIRS := $(shell find $(SRC_DIRS) -type d)
INC_FLAGS := $(addprefix -I,$(INC_DIRS))
CPPFLAGS := -mcpu=cortex-m3 \
-mthumb \
-O0 \
-ggdb3 \
-ffunction-sections \
-fdata-sections \
-Wall \
-Wextra \
-Wshadow \
-Wredundant-decls \
-Wno-missing-field-initializers \
-Wconversion \
-Wno-packed-bitfield-compat \
-pipe \
-Wl,--print-memory-usage \
-Wcpp \
$(INC_FLAGS) \
--specs=nosys.specs \
--specs=nano.specs \
-Wl,--gc-sections \
-ffreestanding \
-fno-rtti \
-fno-exceptions \
-fno-threadsafe-statics \
-DUSE_MDR1986VE9x \
-D__STARTUP_CLEAR_BSS \
-MMD \
-MP
$(BUILD_DIR)/$(TARGET_EXEC): $(OBJS)
@echo "start linking"
$(CXX) -T $(LDPATH) $(CPPFLAGS) $(OBJS) -o $@ $(LDFLAGS)
# assembly
$(BUILD_DIR)/%.S.o: %.S
$(MKDIR_P) $(dir $@)
$(CXX) $(CPPFLAGS) -c $< -o $@
# c source
$(BUILD_DIR)/%.c.o: %.c
$(MKDIR_P) $(dir $@)
$(CC) $(CPPFLAGS)-c $< -o $@
# c++ source
$(BUILD_DIR)/%.cpp.o: %.cpp
$(MKDIR_P) $(dir $@)
$(CXX) $(CPPFLAGS) -c $< -o $@
.PHONY: clean
clean:
$(RM) -r $(BUILD_DIR)
-include $(DEPS)
MKDIR_P ?= mkdir -p