forked from fagci/uvk5-fagci-reborn
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
79 lines (59 loc) · 2.34 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
SRC_DIR := src
OBJ_DIR := obj
BIN_DIR := bin
TARGET = $(BIN_DIR)/firmware
SRC = $(wildcard $(SRC_DIR)/driver/*.c)
SRC += $(wildcard $(SRC_DIR)/external/mcufont/fonts/freesans.c)
SRC += $(wildcard $(SRC_DIR)/external/mcufont/decoder/*.c)
SRC += $(wildcard $(SRC_DIR)/helper/*.c)
SRC += $(wildcard $(SRC_DIR)/ui/*.c)
SRC += $(wildcard $(SRC_DIR)/apps/*.c)
SRC += $(wildcard $(SRC_DIR)/*.c)
OBJS = $(OBJ_DIR)/start.o
OBJS += $(OBJ_DIR)/init.o
OBJS += $(OBJ_DIR)/external/printf/printf.o
OBJS += $(SRC:$(SRC_DIR)/%.c=$(OBJ_DIR)/%.o)
BSP_DEFINITIONS := $(wildcard hardware/*/*.def)
BSP_HEADERS := $(patsubst hardware/%,inc/%,$(BSP_DEFINITIONS))
BSP_HEADERS := $(patsubst %.def,%.h,$(BSP_HEADERS))
AS = arm-none-eabi-gcc
CC = arm-none-eabi-gcc
LD = arm-none-eabi-gcc
OBJCOPY = arm-none-eabi-objcopy
SIZE = arm-none-eabi-size
GIT_HASH := $(shell git rev-parse --short HEAD)
ASFLAGS = -c -mcpu=cortex-m0
# CFLAGS = -Os -Wall -Wno-error -mcpu=cortex-m0 -fno-delete-null-pointer-checks -std=c11 -MMD -ffunction-sections -fdata-sections
CFLAGS = -Os -Wall -Wno-error -mcpu=cortex-m0 -fno-builtin -fshort-enums -fno-delete-null-pointer-checks -std=c2x -MMD -flto=auto -Wextra
# CFLAGS = -Os -Wall -Wno-error -mcpu=cortex-m0 -fno-builtin -fshort-enums -fno-delete-null-pointer-checks -std=c2x -MMD -ffunction-sections -fdata-sections -Wextra
CFLAGS += -DPRINTF_INCLUDE_CONFIG_H
CFLAGS += -DGIT_HASH=\"$(GIT_HASH)\"
LDFLAGS = -mcpu=cortex-m0 -nostartfiles -Wl,-T,firmware.ld
INC =
INC += -I ./src
INC += -I ./src/external/CMSIS_5/CMSIS/Core/Include/
INC += -I ./src/external/CMSIS_5/Device/ARM/ARMCM0/Include
INC += -I ./src/external/mcufont/decoder/
INC += -I ./src/external/mcufont/fonts/
DEPS = $(OBJS:.o=.d)
.PHONY: all clean
all: $(TARGET)
$(OBJCOPY) -O binary $< $<.bin
-python fw-pack.py $<.bin $(GIT_HASH) $<.packed.bin
-python3 fw-pack.py $<.bin $(GIT_HASH) $<.packed.bin
$(SIZE) $<
version.o: .FORCE
$(TARGET): $(OBJS) | $(BIN_DIR)
$(LD) $(LDFLAGS) $^ -o $@
inc/dp32g030/%.h: hardware/dp32g030/%.def
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c | $(BSP_HEADERS) $(OBJ_DIR)
mkdir -p $(@D)
$(CC) $(CFLAGS) $(INC) -c $< -o $@
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.S | $(OBJ_DIR)
$(AS) $(ASFLAGS) $< -o $@
$(BIN_DIR) $(OBJ_DIR) $(BIN_DIR):
mkdir -p $@
.FORCE:
-include $(DEPS)
clean:
rm -f $(TARGET).bin $(TARGET).packed.bin $(TARGET) $(OBJ_DIR)/*.o $(OBJ_DIR)/*.d $(OBJ_DIR)/**/*.o $(OBJ_DIR)/**/*.d