-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
139 lines (110 loc) · 5.27 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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
CC := gcc
BIN := posix_demo
BUILD_DIR := ./build
BUILD_DIR_ABS := $(abspath $(BUILD_DIR))
FREERTOS_DIR_REL := $(FREERTOS_DIR_ENV)/FreeRTOS
FREERTOS_DIR := $(abspath ${FREERTOS_DIR_REL})
FREERTOS_PLUS_DIR_REL := $(FREERTOS_DIR_ENV)/FreeRTOS-Plus
FREERTOS_PLUS_DIR := $(abspath ${FREERTOS_PLUS_DIR_REL})
KERNEL_DIR := $(FREERTOS_KERNEL_DIR_ENV)
PROJ_SRC_DIR_REL := ./source
PROJ_SRC_DIR := $(abspath ${PROJ_SRC_DIR_REL})
CLI_DIR := ${PROJ_SRC_DIR}/CLI
INCLUDE_DIRS += -I.
INCLUDE_DIRS += -I./include
INCLUDE_DIRS += -I${CLI_DIR}
INCLUDE_DIRS += -I${KERNEL_DIR}/include
INCLUDE_DIRS += -I${KERNEL_DIR}/portable/ThirdParty/GCC/Posix
INCLUDE_DIRS += -I${KERNEL_DIR}/portable/ThirdParty/GCC/Posix/utils
INCLUDE_DIRS += -I${FREERTOS_DIR}/Demo/Common/include
INCLUDE_DIRS += -I${FREERTOS_PLUS_DIR}/Source/FreeRTOS-Plus-Trace/Include
SOURCE_FILES := $(wildcard ${PROJ_SRC_DIR}/*.c)
SOURCE_FILES += $(wildcard ${KERNEL_DIR}/*.c)
SOURCE_FILES += $(wildcard ${CLI_DIR}/*.c)
# Memory manager (use malloc() / free() )
SOURCE_FILES += ${KERNEL_DIR}/portable/MemMang/heap_3.c
# posix port
SOURCE_FILES += ${KERNEL_DIR}/portable/ThirdParty/GCC/Posix/utils/wait_for_event.c
SOURCE_FILES += ${KERNEL_DIR}/portable/ThirdParty/GCC/Posix/port.c
# Demo library.
SOURCE_FILES += ${FREERTOS_DIR}/Demo/Common/Minimal/AbortDelay.c
SOURCE_FILES += ${FREERTOS_DIR}/Demo/Common/Minimal/BlockQ.c
SOURCE_FILES += ${FREERTOS_DIR}/Demo/Common/Minimal/blocktim.c
SOURCE_FILES += ${FREERTOS_DIR}/Demo/Common/Minimal/countsem.c
SOURCE_FILES += ${FREERTOS_DIR}/Demo/Common/Minimal/death.c
SOURCE_FILES += ${FREERTOS_DIR}/Demo/Common/Minimal/dynamic.c
SOURCE_FILES += ${FREERTOS_DIR}/Demo/Common/Minimal/EventGroupsDemo.c
SOURCE_FILES += ${FREERTOS_DIR}/Demo/Common/Minimal/flop.c
SOURCE_FILES += ${FREERTOS_DIR}/Demo/Common/Minimal/GenQTest.c
SOURCE_FILES += ${FREERTOS_DIR}/Demo/Common/Minimal/integer.c
SOURCE_FILES += ${FREERTOS_DIR}/Demo/Common/Minimal/IntSemTest.c
SOURCE_FILES += ${FREERTOS_DIR}/Demo/Common/Minimal/MessageBufferAMP.c
SOURCE_FILES += ${FREERTOS_DIR}/Demo/Common/Minimal/MessageBufferDemo.c
SOURCE_FILES += ${FREERTOS_DIR}/Demo/Common/Minimal/PollQ.c
SOURCE_FILES += ${FREERTOS_DIR}/Demo/Common/Minimal/QPeek.c
SOURCE_FILES += ${FREERTOS_DIR}/Demo/Common/Minimal/QueueOverwrite.c
SOURCE_FILES += ${FREERTOS_DIR}/Demo/Common/Minimal/QueueSet.c
SOURCE_FILES += ${FREERTOS_DIR}/Demo/Common/Minimal/QueueSetPolling.c
SOURCE_FILES += ${FREERTOS_DIR}/Demo/Common/Minimal/recmutex.c
SOURCE_FILES += ${FREERTOS_DIR}/Demo/Common/Minimal/semtest.c
SOURCE_FILES += ${FREERTOS_DIR}/Demo/Common/Minimal/StaticAllocation.c
SOURCE_FILES += ${FREERTOS_DIR}/Demo/Common/Minimal/StreamBufferDemo.c
SOURCE_FILES += ${FREERTOS_DIR}/Demo/Common/Minimal/StreamBufferInterrupt.c
SOURCE_FILES += ${FREERTOS_DIR}/Demo/Common/Minimal/TaskNotify.c
SOURCE_FILES += ${FREERTOS_DIR}/Demo/Common/Minimal/TimerDemo.c
CFLAGS := -ggdb3
LDFLAGS := -ggdb3 -pthread
CPPFLAGS := $(INCLUDE_DIRS) -DBUILD_DIR=\"$(BUILD_DIR_ABS)\"
CPPFLAGS += -D_WINDOWS_
ifeq ($(TRACE_ON_ENTER),1)
CPPFLAGS += -DTRACE_ON_ENTER=1
else
CPPFLAGS += -DTRACE_ON_ENTER=0
endif
ifeq ($(COVERAGE_TEST),1)
CPPFLAGS += -DprojCOVERAGE_TEST=1
else
CPPFLAGS += -DprojCOVERAGE_TEST=0
# Trace library.
SOURCE_FILES += ${FREERTOS_PLUS_DIR}/Source/FreeRTOS-Plus-Trace/trcKernelPort.c
SOURCE_FILES += ${FREERTOS_PLUS_DIR}/Source/FreeRTOS-Plus-Trace/trcSnapshotRecorder.c
SOURCE_FILES += ${FREERTOS_PLUS_DIR}/Source/FreeRTOS-Plus-Trace/trcStreamingRecorder.c
SOURCE_FILES += ${FREERTOS_PLUS_DIR}/Source/FreeRTOS-Plus-Trace/streamports/File/trcStreamingPort.c
endif
ifdef PROFILE
CFLAGS += -pg -O0
LDFLAGS += -pg -O0
else
CFLAGS += -O3
LDFLAGS += -O3
endif
ifdef SANITIZE_ADDRESS
CFLAGS += -fsanitize=address -fsanitize=alignment
LDFLAGS += -fsanitize=address -fsanitize=alignment
endif
ifdef SANITIZE_LEAK
LDFLAGS += -fsanitize=leak
endif
ifeq ($(USER_DEMO),BLINKY_DEMO)
CPPFLAGS += -DUSER_DEMO=0
endif
ifeq ($(USER_DEMO),FULL_DEMO)
CPPFLAGS += -DUSER_DEMO=1
endif
OBJ_FILES = $(SOURCE_FILES:%.c=$(BUILD_DIR)/%.o)
DEP_FILE = $(OBJ_FILES:%.o=%.d)
${BIN} : $(BUILD_DIR)/$(BIN)
${BUILD_DIR}/${BIN} : ${OBJ_FILES}
-mkdir -p ${@D}
$(CC) $^ ${LDFLAGS} -o $@
-include ${DEP_FILE}
${BUILD_DIR}/%.o : %.c Makefile
-mkdir -p $(@D)
$(CC) $(CPPFLAGS) $(CFLAGS) -MMD -c $< -o $@
.PHONY: clean
clean:
-rm -rf $(BUILD_DIR)
GPROF_OPTIONS := --directory-path=$(INCLUDE_DIRS)
profile:
gprof -a -p --all-lines $(GPROF_OPTIONS) $(BUILD_DIR)/$(BIN) $(BUILD_DIR)/gmon.out > $(BUILD_DIR)/prof_flat.txt
gprof -a --graph $(GPROF_OPTIONS) $(BUILD_DIR)/$(BIN) $(BUILD_DIR)/gmon.out > $(BUILD_DIR)/prof_call_graph.txt