-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
45 lines (33 loc) · 947 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
# Makefile
# Toolchain definitions
CC = arm-none-eabi-gcc
OBJCOPY = arm-none-eabi-objcopy
SIZE = arm-none-eabi-size
# Project name
PROJECT = autonomous_drone
# Directories
SRC_DIR = .
INC_DIR = .
BUILD_DIR = build
# Source files
SRC_FILES = $(wildcard $(SRC_DIR)/*.c)
OBJ_FILES = $(patsubst $(SRC_DIR)/%.c,$(BUILD_DIR)/%.o,$(SRC_FILES))
# Compiler flags
CFLAGS = -mcpu=cortex-m7 -mthumb -mfloat-abi=hard -mfpu=fpv5-d16
CFLAGS += -O2 -Wall -fdata-sections -ffunction-sections
CFLAGS += -I$(INC_DIR) -DSTM32H743xx
# Linker flags
LDFLAGS = -Wl,--gc-sections -Tlink.ld
# Targets
.PHONY: all clean
all: $(BUILD_DIR)/$(PROJECT).elf $(BUILD_DIR)/$(PROJECT).hex
$(BUILD_DIR)/%.o: $(SRC_DIR)/%.c
@mkdir -p $(@D)
$(CC) $(CFLAGS) -c $< -o $@
$(BUILD_DIR)/$(PROJECT).elf: $(OBJ_FILES)
$(CC) $(CFLAGS) $(LDFLAGS) $^ -o $@
$(SIZE) $@
$(BUILD_DIR)/$(PROJECT).hex: $(BUILD_DIR)/$(PROJECT).elf
$(OBJCOPY) -O ihex $< $@
clean:
rm -rf $(BUILD_DIR)