-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
121 lines (95 loc) · 3.33 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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
########################################################################################################################
# Cherry Tomato
########################################################################################################################
#
# The target to compile for:
# - ttgo-twatch-2020-v2
# - pinetime
# - um
#
TARGET ?= pinetime
#
# Do we have debug code enabled
# y/n
#
DEBUG ?= y
#-----------------------------------------------------------------------------------------------------------------------
# Build flags
#-----------------------------------------------------------------------------------------------------------------------
OUT_DIR := out
# The compiler flags
CFLAGS := -Os -g3 -fno-tree-vectorize -flto
CFLAGS += -Wall -Werror
CFLAGS += -Wno-unused-label -Wno-unused-function
CFLAGS += -Isrc
CFLAGS += -DPRINTF_SUPPORT_DECIMAL_SPECIFIERS=0
CFLAGS += -DPRINTF_SUPPORT_EXPONENTIAL_SPECIFIERS=0
CFLAGS += -DSUPPORT_MSVC_STYLE_INTEGER_SPECIFIERS=0
CFLAGS += -DPRINTF_SUPPORT_WRITEBACK_SPECIFIER=0
# The linker script flags
LDFLAGS :=
# The common source code
SRCS :=
SRCS += src/apps/entry.c
SRCS += src/task/lock.c
SRCS += src/task/event.c
SRCS += src/task/timer.c
SRCS += src/task/tpl.c
SRCS += src/util/alloc.c
SRCS += src/util/printf.c
#-----------------------------------------------------------------------------------------------------------------------
# Target configurations
#-----------------------------------------------------------------------------------------------------------------------
default: all
COMPILER_NAME := gcc
OUT_FILE_EXTENSION := elf
# Include the target
TARGET_DIR := src/target/$(TARGET)
BIN_DIR := $(OUT_DIR)/bin/$(TARGET)
BUILD_DIR := $(OUT_DIR)/build/$(TARGET)
include $(TARGET_DIR)/target.mk
# Include platform stuff
PLATFORM_DIR := src/platform/$(PLATFORM)
CFLAGS += -I$(PLATFORM_DIR)
include $(PLATFORM_DIR)/platform.mk
# Include arch stuff
ARCH_DIR := src/arch/$(ARCH)
CFLAGS += -I$(ARCH_DIR)
include $(ARCH_DIR)/arch.mk
# If the target/platform provide a console then set it
ifneq ($(HAS_CONSOLE),0)
CFLAGS += -D__HAS_CONSOLE__
endif
ifeq ($(DEBUG),y)
CFLAGS += -D__DEBUG__
else
CFLAGS += -DNDEBUG
endif
#-----------------------------------------------------------------------------------------------------------------------
# Binaries
#-----------------------------------------------------------------------------------------------------------------------
CC := $(CROSS_COMPILER)$(COMPILER_NAME)
OBJCOPY := $(CROSS_COMPILER)objcopy
#-----------------------------------------------------------------------------------------------------------------------
# Generic Targets
#-----------------------------------------------------------------------------------------------------------------------
OBJS := $(SRCS:%=$(BUILD_DIR)/%.o)
DEPS := $(OBJS:%.o=%.d)
BINS ?=
-include $(DEPS)
# The elf output, this is not always the last step, so put it in the build dir instead
$(BUILD_DIR)/firmware.$(OUT_FILE_EXTENSION): $(OBJS)
@echo LD $@
@mkdir -p $(@D)
$(CC) $(CFLAGS) $^ $(LDFLAGS) -o $@
# Compile c/asm files
$(BUILD_DIR)/%.c.o: %.c
@echo CC $@
@mkdir -p $(@D)
$(CC) -Wall $(CFLAGS) -MMD -c $< -o $@
$(BUILD_DIR)/%.S.o: %.S
@echo CC $@
@mkdir -p $(@D)
$(CC) -Wall $(CFLAGS) -MMD -c $< -o $@
clean:
rm -rf $(BIN_DIR) $(BUILD_DIR)