forked from poseidonos/poseidonos
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
307 lines (243 loc) · 8.12 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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
POS_ROOT_DIR := $(abspath $(CURDIR))
SPDK_ROOT_DIR := $(abspath $(CURDIR)/lib/spdk)
SPDLOG_SOURCE := spdlog-1.4.2
SPDLOG_ROOT_DIR := $(abspath $(CURDIR)/lib/$(SPDLOG_SOURCE))
OTEL_ROOT_DIR := $(abspath $(POS_ROOT_DIR)/lib/opentelemetry-cpp)
TOP = $(POS_ROOT_DIR)
PROTO_DIR = $(TOP)/proto
PROTO_CPP_GENERATED_DIR = $(PROTO_DIR)/generated/cpp
DPDK_ROOT_DIR := $(abspath $(CURDIR)/lib/dpdk)
POS_EVENT_DOCUMENATION_TOOL_DIR := $(abspath $(CURDIR)/tool/document_tool)
include $(SPDK_ROOT_DIR)/mk/spdk.common.mk
include $(SPDK_ROOT_DIR)/mk/spdk.modules.mk
include $(SPDK_ROOT_DIR)/mk/spdk.app_vars.mk
include $(POS_ROOT_DIR)/mk/ibof_config.mk
TARGET_SRC_DIR = src fluidos
#################################################
# bin directories / obj files
BINDIR = $(TOP)/bin
#################################################
# docs directories / doc files
DOCDIR = $(TOP)/doc
#################################################
# nvme driver : unvme, libaio
POS_VERSION = v0.12.0-rc9
DEFINE += -DPOS_VERSION=\"$(POS_VERSION)\"
DEFINE += -DUNVME_BUILD
DEFINE += -DSPDLOG_COMPILED_LIB
#################################################
# spdk libraries
# SPDK_LIB_LIST to be included in SPDK_LIB_FILES
SPDK_LIB_LIST = $(ALL_MODULES_LIST)
ifeq ($(OS),Linux)
ifeq ($(CONFIG_VHOST),y)
SPDK_LIB_LIST += vhost event_vhost
ifeq ($(CONFIG_VHOST_INTERNAL_LIB),y)
SPDK_LIB_LIST += rte_vhost
endif
endif
endif
SPDK_LIB_LIST += accel event_bdev event_iscsi event_scsi event_nvmf event_vmd event_accel event_sock event
SPDK_LIB_LIST += nvmf trace log conf thread util bdev iscsi scsi rpc jsonrpc json
SPDK_LIB_LIST += sock notify
ifeq ($(OS),Linux)
SPDK_LIB_LIST += event_nbd nbd
endif
LIBS += $(SPDK_LIB_LINKER_ARGS)
ifeq ($(CONFIG_FC),y)
ifneq ($(strip $(CONFIG_FC_PATH)),)
SYS_LIBS += -L$(CONFIG_FC_PATH)
endif
SYS_LIBS += -lufc
endif
# LINK_CXX includes LIBS
#LIBS += $(BLOCKDEV_MODULES_LINKER_ARGS) \
# $(COPY_MODULES_LINKER_ARGS) \
# $(SOCK_MODULES_LINKER_ARGS) \
# $(SPDK_LIB_LINKER_ARGS) $(ENV_LINKER_ARGS)
#################################################
ifeq ($(CONFIG_LIBRARY_BUILD), y)
APP = $(BINDIR)/ibofos_library
else
APP = $(BINDIR)/poseidonos
endif
# PoseidonOS CLI
CLI_APP_NAME = poseidonos-cli
CPPFLAGS = -g -Wall -O2 -std=c++14 -Werror
ifeq ($(CONFIG_LIBRARY_BUILD), y)
CPPFLAGS += -fPIC
endif
ifeq ($(CONFIG_FPIC), y)
CPPFLAGS += -fPIC
endif
ifeq ($(CONFIG_GCOV),y)
CPPFLAGS += --coverage
LDFLAGS += -Wl,--dynamic-list-data
endif
# Warning exceptions only for external libraries (dpdk, rapidjson ...)
W_NO = -Wno-register -Wno-class-memaccess
CPPFLAGS += $(W_NO)
KERNEL_VER=$(shell uname -r)
VM_KERNEL_VER=5.3.0-19-generic
ifeq ($(KERNEL_VER), $(VM_KERNEL_VER))
FIO_SOURCE = fio-fio-3.12
else
FIO_SOURCE = fio-fio-3.1
endif
INCLUDE = -I$(TOP) -I$(SPDK_ROOT_DIR)/include -I$(SPDK_ROOT_DIR)/module -I$(TOP)/lib \
-I$(TOP)/src/ibofos/network/ -I$(TOP)/src/logger/
export MFS_TOP_DIR=$(TOP)/src/metafs
include $(MFS_TOP_DIR)/mfs_include.mk
INCLUDE += $(MFS_INCLUDE_PATH)
INCLUDE += -I$(DPDK_ROOT_DIR)/include/dpdk
INCLUDE += -I$(TOP)/lib/air -I$(TOP)/lib/air/src/api
LDFLAGS += -L/usr/local/lib -lair
DEFINE += -DAIR_CFG=$(TOP)/config/air.cfg
INCLUDE += -I$(SPDLOG_ROOT_DIR)/include -I$(SPDLOG_ROOT_DIR)/include/spdlog
LDFLAGS += -L./lib/$(SPDLOG_SOURCE)/lib -lspdlog
INCLUDE += -I$(OTEL_ROOT_DIR)/include
LDFLAGS += -L$(OTEL_ROOT_DIR)/lib \
-lopentelemetry_trace \
-lopentelemetry_exporter_otlp_http \
-lopentelemetry_exporter_otlp_http_client \
-lopentelemetry_otlp_recordable \
-lopentelemetry_proto \
-lopentelemetry_resources \
-lopentelemetry_common \
-lopentelemetry_http_client_curl \
-lpthread -lcurl
DEFINE += -DHAVE_ABSEIL
CXXFLAGS += $(INCLUDE)
LDFLAGS += -ljsoncpp -ljsonrpccpp-common -ljsonrpccpp-client
LDFLAGS += -no-pie -laio
LDFLAGS += -lnuma
LDFLAGS += -lyaml-cpp
LDFLAGS += -ltbb
LDFLAGS += -lrocksdb
LDFLAGS += -lstdc++fs
LDFLAGS += -lisal
ifeq ($(CONFIG_ASAN), y)
CPPFLAGS += -fno-omit-frame-pointer -fsanitize=address
LDFLAGS += -fno-omit-frame-pointer -fsanitize=address
else
LDFLAGS += -ltcmalloc
endif
CLI_CERT_DIR = /etc/pos/cert
CLI_DIR = $(TOP)/tool/cli
CLI_CERT_FILES = $(CLI_DIR)/cert/cert.key $(CLI_DIR)/cert/cert.crt
# for grpc
LDFLAGS += `pkg-config --libs protobuf grpc++`\
-lgrpc++_reflection -ldl
LDFLAGS += -lssl -lcrypto
# for callstack symbols
LDEXTRAFLAGS = -rdynamic
CONFIG_DIR = /etc/pos/
CONFIG_FILE = $(CONFIG_DIR)/pos.conf
TELEMETRY_CONFIG_FILE = $(CONFIG_DIR)/telemetry_default.yaml
PUBLICATION_LIST_FILE = $(CONFIG_DIR)/publication_list_default.yaml
POS_EVENT_FILE = $(CONFIG_DIR)/pos_event.yaml
ifeq ($(CONFIG_LIBRARY_BUILD), y)
LDEXTRAFLAGS += -shared -Wl,-z,nodelete
endif
INSTALL_DIR = /usr/local/bin
UDEV_DIR = /etc/udev/rules.d
UDEV_FILE = $(UDEV_DIR)/99-custom-nvme.rules
################################################
all : gen_proto $(APP) pos-exporter gen_doc
@:
install:
@echo "make config dir"
@if test -d ${CONFIG_DIR}; then \
echo "exist dir"; \
else \
echo "not exist dir"; \
mkdir -p ${CONFIG_DIR};\
fi
@echo "copy default config file"
@if test -e ${CONFIG_FILE}; then \
echo "exist file"; \
echo "if you want to change default config file, remove file first"; \
else \
echo "not exist file"; \
echo "copy default config file"; \
cp ./config/pos.conf ${CONFIG_FILE}; \
fi
@echo "copy default telemetry config file"
@cp ./config/telemetry_default.yaml ${TELEMETRY_CONFIG_FILE};
@echo "copy default telemetry publication list"
@cp ./config/publication_list_default.yaml ${PUBLICATION_LIST_FILE};
@echo "copy event table"
@cp ./src/event/pos_event.yaml ${POS_EVENT_FILE};
# @echo "make cert dir" \
@if test -d ${CLI_CERT_DIR}; then \
echo "exist dir"; \
else \
echo "not exist dir"; \
mkdir -p ${CLI_CERT_DIR};\
cp ${CLI_CERT_FILES} ${CLI_CERT_DIR}; \
fi
@install -m 755 $(APP) $(INSTALL_DIR)
@install -m 755 $(BINDIR)/${CLI_APP_NAME} $(INSTALL_DIR)
# Register CLI man page
gzip --force $(CLI_DIR)/docs/manpage/*
mv $(CLI_DIR)/docs/manpage/* /usr/share/man/man3/
makewhatis
udev_install:
@echo "Try to copy udev bind rule file"
@if test -e ${UDEV_FILE}; then \
echo "The rule file exists"; \
echo "Updating udev rule file"; \
else \
echo "The rule file does not exist"; \
echo "Copying udev rule file"; \
fi
$(POS_ROOT_DIR)/tool/udev/generate_udev_rule.sh; \
cp $(POS_ROOT_DIR)/tool/udev/99-custom-nvme.rules ${UDEV_FILE}; \
udevadm control --reload-rules && udevadm trigger; \
udev_uninstall:
@echo "Try to remove udev bind rule file"
@if test -e ${UDEV_FILE}; then \
echo "The rule file exists"; \
rm ${UDEV_FILE};\
udevadm control --reload-rules && udevadm trigger; \
echo "The rule file removed"; \
else \
echo "The file does not exist"; \
echo "No need to remove"; \
fi
gen_proto:
@echo Build protobuf
@`[ -d $(PROTO_CPP_GENERATED_DIR) ] || mkdir -p $(PROTO_CPP_GENERATED_DIR)`
protoc --cpp_out=$(PROTO_CPP_GENERATED_DIR) --grpc_out=$(PROTO_CPP_GENERATED_DIR) --plugin=protoc-gen-grpc=/usr/local/bin/grpc_cpp_plugin --proto_path=$(PROTO_DIR) $(PROTO_DIR)/*.proto
gen_doc:
python3 $(POS_EVENT_DOCUMENATION_TOOL_DIR)/events_to_markdown_table.py
pos-exporter:
@echo Build Telemetry Collector
$(MAKE) -C tool/pos-exporter
mv tool/pos-exporter/pos-exporter $(BINDIR)
@cd $(TOP)
sam: makedir
@echo SAM Build
$(MAKE) -C src sam
$(APP) : $(SPDK_LIB_FILES) poseidonos
$(LINK_CXX) $(shell find src/ -name *.o -and ! -name *_test.o -and ! -name *_fake.o -and ! -name *_stub.o -and ! -name *_mock.o -and ! -name *_fixture.o) $(PROTO_CPP_GENERATED_DIR)/*.o $(LDFLAGS) $(LDEXTRAFLAGS)
rm bin/ibofos -rf
ln -s $(shell pwd -P)/bin/poseidonos bin/ibofos
poseidonos: makedir
$(MAKE) -C proto
$(MAKE) -C src
$(CLI_DIR)/script/build_cli.sh
mv -f $(CLI_DIR)/bin/${CLI_APP_NAME} $(BINDIR)/${CLI_APP_NAME}
mv -f $(CLI_DIR)/docs/markdown/* $(DOCDIR)/guides/cli/
makedir:
@`[ -d $(BINDIR) ] || mkdir -p $(BINDIR)`
package: $(APP) pos-exporter
@$(MAKE) -C package
clean :
@$(MAKE) -C src clean
@$(MAKE) -C proto clean
@$(MAKE) -C package clean
@rm -rf $(BINDIR)
.PHONY: all install clean udev_install udev_uninstall makedir package
include $(SPDK_ROOT_DIR)/mk/spdk.deps.mk
export INCLUDE SRCS CPPFLAGS DEFINE