-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathMakefile.am
381 lines (320 loc) · 11.1 KB
/
Makefile.am
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
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
# SPDX-License-Identifier: GPL-2.0/BSD
.SILENT:
VERSION=@VERSION@
RELEASE=0
DEM_EXE=dem
MON_EXE=dem-dm
CLI_EXE=dem-cli
AC_EXE=dem-ac
EM_EXE=dem-em
BIN_DIR=.bin
COMMON_DIR=src/common
INCL_DIR=src/incl
DEM_DIR=src/dem
MON_DIR=src/monitor
CLI_DIR=src/cli
EM_DIR=src/endpoint
AC_DIR=src/auto_connect
prefix ?= /usr
bindir ?= ${prefix}/bin
sysconfdir ?= /etc
mandir ?= ${prefix}/share/man
sysddir ?= ${prefix}/lib/systemd/system
libexecdir ?= ${prefix}/libexec
if LOCAL_PREFIX
sharedir ?= ${prefix}/share
else
sharedir ?= ${prefix}/local/share
endif
DEM_CFLAGS = -DMG_ENABLE_THREADS -DMG_ENABLE_HTTP_WEBSOCKET=0
if NVMEOF_TRACING
DEM_CFLAGS += -DDEBUG_COMMANDS
endif
GCC = ${KWWRAP}gcc
CFLAGS = -W -Wall -Wno-unused-function
CFLAGS += -Imongoose -Ijansson/src -I${INCL_DIR}
if EXTRA_SECURITY_CFLAGS
LDFLAGS += -z noexecstack -z relro -z now -pie
CFLAGS += -fstack-protector-strong
CFLAGS += -fPIE -fPIC
CFLAGS += -Wformat
CFLAGS += -D_FORTIFY_SOURCE=2
CFLAGS += -Wformat-security
CFLAGS += -Wno-unused-result
GDB_OPTS = -O2
else
CFLAGS += -Werror
if DEBUG
GDB_OPTS = -g -O0 -DCONFIG_DEBUG
else
GDB_OPTS = -O2
endif
endif
if PICKY_COMPILER_FOPEN
CFLAGS += -Wno-unused-result
endif
if PICKY_COMPILER_SPRINTF
CFLAGS += -Wno-format-overflow
CFLAGS += -Wno-format-truncation
endif
# ALT_CFLAGS used for sparse since mongoose has too many errors
# a modified version of mongoose.h can be created and stored in /files
# for sparse testing but is not valid for executable
ALT_CFLAGS = -W -Wall -Werror -Wno-unused-function
ALT_CFLAGS += -Ifiles -Ijansson/src -I${INCL_DIR} -I${DEM_DIR}
SPARSE_OPTS = ${DEM_CFLAGS} ${ALT_CFLAGS} -DCS_PLATFORM=0
VALGRIND_OPTS = --leak-check=full --show-leak-kinds=all -v --track-origins=yes
VALGRIND_OPTS += --suppressions=files/valgrind_suppress
DEM_LIBS = -lpthread -lrdmacm -libverbs -lcurl jansson/libjansson.a
EM_LIBS = -lpthread -lrdmacm -libverbs jansson/libjansson.a
AC_LIBS = -lpthread -lrdmacm -libverbs jansson/libjansson.a
MON_LIBS = -lpthread -lrdmacm -libverbs jansson/libjansson.a
CLI_LIBS = -lcurl jansson/libjansson.a
LINUX_INCL = ${INCL_DIR}/nvme.h ${INCL_DIR}/utils.h
CLI_SRC = ${CLI_DIR}/cli.c ${COMMON_DIR}/curl.c ${CLI_DIR}/show.c
CLI_INC = ${INCL_DIR}/dem.h ${INCL_DIR}/curl.h ${CLI_DIR}/show.h \
${INCL_DIR}/tags.h
MG_DIR ?= mongoose
if SPDK
CFLAGS += -DCONFIG_SPDK
EM_LIBS += -lspdk -lspdk_env_dpdk -ldpdk -ldl -lnuma -lpciaccess
EM_SPDK_CFG = ${EM_DIR}/spdk_config.c
endif
if CONFIGFS
CFLAGS += -DCONFIG_CONFIGFS
EM_CFGFS_CFG = ${EM_DIR}/configfs.c
endif
AC_SRC = ${AC_DIR}/daemon.c ${COMMON_DIR}/nvmeof.c ${COMMON_DIR}/rdma.c \
${COMMON_DIR}/logpages.c ${COMMON_DIR}/parse.c ${COMMON_DIR}/tcp.c
AC_INC = ${INCL_DIR}/dem.h ${AC_DIR}/common.h ${INCL_DIR}/ops.h ${LINUX_INCL}
MON_SRC = ${MON_DIR}/daemon.c ${COMMON_DIR}/nvmeof.c ${COMMON_DIR}/rdma.c \
${COMMON_DIR}/logpages.c ${COMMON_DIR}/parse.c ${COMMON_DIR}/tcp.c
MON_INC = ${INCL_DIR}/dem.h ${MON_DIR}/common.h ${INCL_DIR}/ops.h ${LINUX_INCL}
DEM_SRC = ${DEM_DIR}/daemon.c ${DEM_DIR}/config.c ${DEM_DIR}/restful.c \
${DEM_DIR}/interfaces.c ${DEM_DIR}/pseudo_target.c \
${COMMON_DIR}/nvmeof.c ${COMMON_DIR}/curl.c ${COMMON_DIR}/rdma.c \
${COMMON_DIR}/logpages.c ${DEM_DIR}/logpages.c ${COMMON_DIR}/tcp.c \
${DEM_DIR}/json.c ${COMMON_DIR}/parse.c ${MG_DIR}/mongoose.c
DEM_INC = ${INCL_DIR}/dem.h ${DEM_DIR}/json.h ${DEM_DIR}/common.h \
${INCL_DIR}/ops.h ${INCL_DIR}/curl.h ${INCL_DIR}/tags.h \
mongoose/mongoose.h ${LINUX_INCL}
EM_SRC = ${EM_DIR}/daemon.c ${EM_DIR}/restful.c ${EM_DIR}/etc_config.c \
${EM_DIR}/pseudo_target.c ${COMMON_DIR}/rdma.c ${COMMON_DIR}/tcp.c \
${COMMON_DIR}/nvmeof.c ${COMMON_DIR}/parse.c ${MG_DIR}/mongoose.c \
${EM_CFGFS_CFG} ${EM_SPDK_CFG}
EM_INC = ${INCL_DIR}/dem.h ${EM_DIR}/common.h ${INCL_DIR}/tags.h \
${INCL_DIR}/ops.h mongoose/mongoose.h ${LINUX_INCL}
all: ${BIN_DIR} mongoose/mongoose.h jansson/libjansson.a \
${BIN_DIR}/${DEM_EXE} ${BIN_DIR}/${CLI_EXE} ${BIN_DIR}/${EM_EXE} \
${BIN_DIR}/${MON_EXE} ${BIN_DIR}/${AC_EXE}
echo Done.
${BIN_DIR}:
mkdir ${BIN_DIR}
${DEM_EXE}: ${BIN_DIR}/${DEM_EXE}
${CLI_EXE}: ${BIN_DIR}/${CLI_EXE}
${MON_EXE}: ${BIN_DIR}/${MON_EXE}
${AC_EXE}: ${BIN_DIR}/${AC_EXE}
${EM_EXE}: ${BIN_DIR}/${EM_EXE}
${BIN_DIR}/${CLI_EXE}: ${CLI_SRC} ${CLI_INC} Makefile jansson/libjansson.a
echo CC ${CLI_EXE}
${GCC} ${CLI_SRC} -o $@ ${CFLAGS} ${GDB_OPTS} ${CLI_LIBS} \
-I${CLI_DIR} -DDEM_CLI
${BIN_DIR}/${AC_EXE}: ${AC_SRC} ${AC_INC} Makefile
echo CC ${AC_EXE}
${GCC} ${AC_SRC} -o $@ ${DEM_CFLAGS} ${CFLAGS} ${GDB_OPTS} \
${AC_LIBS} -I${AC_DIR}
${BIN_DIR}/${MON_EXE}: ${MON_SRC} ${MON_INC} Makefile
echo CC ${MON_EXE}
${GCC} ${MON_SRC} -o $@ ${DEM_CFLAGS} ${CFLAGS} ${GDB_OPTS} \
${MON_LIBS} -I${MON_DIR} -DDEBUG_LOG_PAGES
${BIN_DIR}/${DEM_EXE}: ${DEM_SRC} ${DEM_INC} Makefile jansson/libjansson.a
echo CC ${DEM_EXE}
${GCC} ${DEM_SRC} -o $@ ${DEM_CFLAGS} ${CFLAGS} ${GDB_OPTS} \
${DEM_LIBS} -I${DEM_DIR}
${BIN_DIR}/${EM_EXE}: ${EM_SRC} ${EM_INC} Makefile jansson/libjansson.a
echo CC ${EM_EXE}
${GCC} ${EM_SRC} -o $@ ${DEM_CFLAGS} ${CFLAGS} ${GDB_OPTS} \
${EM_LIBS} -I${EM_DIR}
clean:
rm -rf ${BIN_DIR}/ config.json *.vglog .k* kw.cfg
echo Done.
rpm_prep:
rm -f ~/rpmbuild/SOURCES/nvme-dem-${VERSION}.tar.gz
rm -rf ~/rpmbuild/BUILD*/nvme-dem*
[ -d ~/rpmbuild/SOURCES ] || mkdir -p ~/rpmbuild/SOURCES
cd mongoose ; git clean -xfdq
cd jansson ; git clean -xfdq
cd .. ; \
[ -d nvme-dem-${VERSION} ] \
&& rm -rf nvme-dem-${VERSION}/* \
|| mkdir nvme-dem-${VERSION} ; \
cp -r nvme-dem/* nvme-dem-${VERSION} ; \
tar cz -f ~/rpmbuild/SOURCES/nvme-dem-${VERSION}.tar.gz \
nvme-dem-${VERSION} ; \
rm -rf nvme-dem-${VERSION}
rpm: rpm_prep
rpmbuild -bb nvme-dem.spec --define "_version ${VERSION}" --define "_release ${RELEASE}"
srpm: rpm_prep
rpmbuild -bs nvme-dem.spec --define "_version ${VERSION}" --define "_release ${RELEASE}"
echo nvme-dem-${VERSION}.tar.gz > ~/rpmbuild/SOURCES/latest.txt
echo remember to upload ~/rpmbuild/SOURCES/latest.txt ~/rpmbuild/SOURCES/nvme-dem-${VERSION}.tar.gz
install: all
[ -e ${bindir} ] || mkdir -p ${bindir}
[ -e ${libexecdir} ] || mkdir -p ${libexecdir}
[ -e ${sharedir}/bash_completion.d ] || mkdir -p ${sharedir}/bash_completion.d
[ -e ${sysconfdir}/nvme/nvmeof-dem ] || mkdir -p ${sysconfdir}/nvme/nvmeof-dem
[ -e ${sysddir} ] || mkdir -p ${sysddir}
[ -e ${mandir}/man1 ] || mkdir -p ${mandir}/man1
[ -e ${mandir}/man8 ] || mkdir ${mandir}/man8
[ -L ${bindir}/dem ] || cp ${BIN_DIR}/* ${bindir}
cp usr/nvmeof.conf ${sysconfdir}/nvme
[ ! -d ${libexecdir} ] || cp usr/nvmeof ${libexecdir}/
cp usr/nvmeof.service ${sysddir}/nvmeof.service
cp usr/bash_completion.d/* ${sharedir}/bash_completion.d/
cp usr/man/*.1 ${mandir}/man1/
cp usr/man/*.8 ${mandir}/man8/
uninstall:
rm -f ${bindir}/${CLI_EXE} ${bindir}/${AC_EXE} ${bindir}/${MON_EXE}
rm -f ${bindir}/${DEM_EXE} ${bindir}/${EM_EXE}
rm -f ${sharedir}/bash_completion.d/${CLI_EXE}
rm -f ${sysconfdir}/nvme/nvmeof.conf
rm -rf ${sysconfdir}/nvme/nvmeof-dem
rm -f ${libexecdir}/nvmeof
rm -f ${sysddir}/nvmeof.service
rm -f ${mandir}/man1/${CLI_EXE}.1* ${mandir}/man1/${MON_EXE}.1*
rm -f ${mandir}/man8/${EM_EXE}.8* ${mandir}/man8/${AC_EXE}.8*
rm -f ${mandir}/man8/${DEM_EXE}.8*
echo Done.
mongoose/.git:
echo cloning github.com/cesanta/mongoose.git
echo NOTE: if no access to github, use scp to copy mongoose/.git
git clone https://github.com/cesanta/mongoose.git >/dev/null
touch $@
mongoose/mongoose.h: mongoose/.git
cd mongoose ; git reset -q --hard HEAD
touch $@
jansson/.git:
echo cloning github.com/akheron/jansson.git
echo NOTE: if no access to github, use scp to copy jansson/.git
git clone https://github.com/akheron/jansson.git >/dev/null
touch $@
jansson/Makefile.am: jansson/.git
cd jansson ; git reset -q --hard HEAD
touch $@
jansson/configure: jansson/Makefile.am
echo configuring jansson
cd jansson ; autoreconf -i >/dev/null 2>&1
touch $@
jansson/Makefile: jansson/configure
cd jansson ; ./configure >/dev/null
touch $@
jansson/src/.libs/libjansson.a: jansson/Makefile
echo building libjansson
cd jansson/src ; make libjansson.la >/dev/null
jansson/libjansson.a: jansson/src/.libs/libjansson.a
cp jansson/src/.libs/libjansson.a jansson
archive: clean
[ -d archive ] || mkdir archive
tar cz -f archive/`date +"%y%m%d_%H%M"`.tgz .gitignore .git/config \
files/ html/ Makefile src/ usr/
test_cli: ${CLI_EXE}
${CLI_EXE} config
${CLI_EXE} list ctrl
${CLI_EXE} set ctrl ctrl1
${CLI_EXE} set portid 1 rdma ipv4 1.1.1.2 2332
${CLI_EXE} show ctrl ctrl1
${CLI_EXE} rename ctrl ctrl1 ctrl2
${CLI_EXE} add ss ctrl2 ss21 ss22
${CLI_EXE} delete ss ctrl2 ss21
${CLI_EXE} delete ctrl ctrl2
${CLI_EXE} list host
${CLI_EXE} set host host01
${CLI_EXE} rename host host01 host02
${CLI_EXE} add acl host01 ss11 ss21
${CLI_EXE} show host host01
${CLI_EXE} delete acl host02 ss21
${CLI_EXE} delete host host02
${CLI_EXE} shutdown
# show format for raw: fmt=-r make show_hosts
# show format for pretty json: fmt=-j make show_hosts
show_hosts:
for i in `${CLI_EXE} lis h|grep -v ^http:|grep -v "^No .* defined"`; \
do ${CLI_EXE} $$fmt get h $$i ; done
show_targets:
for i in `${CLI_EXE} lis t|grep -v ^http:|grep -v "^No .* defined"`; \
do ${CLI_EXE} $$fmt get t $$i ; done
del_hosts:
for i in `${CLI_EXE} lis h|grep -v ^http:|grep -v "^No .* defined"`; \
do ${CLI_EXE} -f del h $$i ; done
del_targets:
for i in `${CLI_EXE} lis t|grep -v ^http:|grep -v "^No .* defined"`; \
do ${CLI_EXE} -f del t $$i ; done
put:
echo PUT Commands
curl -X PUT -d '' http://127.0.0.1:22345/host/host01
echo
curl -X PUT -d '' http://127.0.0.1:22345/host/host02
echo
curl -X PUT -d '' http://127.0.0.1:22345/target/ctrl1
echo
curl -X PUT -d '' http://127.0.0.1:22345/target/ctrl2
echo
curl -X PUT -d '' http://127.0.0.1:22345/target/ctrl1/subsys/subsys1
echo
echo
get:
echo GET Commands
curl http://127.0.0.1:22345/target
echo
curl http://127.0.0.1:22345/target/ctrl1
echo
curl http://127.0.0.1:22345/host
echo
curl http://127.0.0.1:22345/host/host01
echo
echo
del: delhost01 delhost02 delctrl1 delctrl2
echo
delctrl2:
curl -X DELETE http://127.0.0.1:22345/target/ctrl2
echo
delctrl1:
curl -X DELETE http://127.0.0.1:22345/target/ctrl1
echo
delhost01:
echo DELETE Commands
curl -X DELETE http://127.0.0.1:22345/host/host01
echo
delhost02:
curl -X DELETE http://127.0.0.1:22345/host/host02
echo
post:
echo POST Commands
curl -d '{"HOSTNQN":"host02"}' http://127.0.0.1:22345/host/host01
echo
echo
get16:
for i in `seq 1 16` ; do make get ; done
test: put get16 post get del
memcheck: ${DEM_EXE}
reset
valgrind ${VALGRIND_OPTS} --log-file=dem.vglog ${DEM_EXE}
echo "valgrind output in 'dem.vglog'"
sparse:
echo running sparse of each .c file with options
echo "${SPARSE_OPTS}"
for i in src/*/*.c ; do sparse $$i ${SPARSE_OPTS} ; done
echo Done.
kw.cfg:
rm -rf .kw*
echo creating klocwork project
~/klocwork/kw-client/bin/kwcheck create
echo rebuilding for klocwork
MG_DIR=files \
KWWRAP="~/klocwork/kw-client/bin/kwwrap -o /tmp/klocwork.out " make
~/klocwork/kw-client/bin/kwinject -t /tmp/klocwork.out -o kw.cfg
rm /tmp//klocwork.out
klocwork: kw.cfg
echo generating klocwork report
~/klocwork/kw-client/bin/kwcheck run -b kw.cfg > klocwork.out
echo klocwork output in klocwork.out