-
Notifications
You must be signed in to change notification settings - Fork 20
/
Makefile
528 lines (434 loc) · 17.1 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
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
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
#
# Aerospike Backup/Restore
#
# Copyright (c) 2008-2022 Aerospike, Inc. All rights reserved.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of
# this software and associated documentation files (the "Software"), to deal in
# the Software without restriction, including without limitation the rights to
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
# of the Software, and to permit persons to whom the Software is furnished to do
# so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#
# deprecated: support for explicit client repo
ifdef CLIENTREPO
$(warning Setting CLIENTREPO explicitly is deprecated, the c-client is now a submodule of asbackup)
DIR_C_CLIENT := $(CLIENTREPO)
endif
OS := $(shell uname -s)
ARCH := $(shell uname -m)
PLATFORM := $(OS)-$(ARCH)
VERSION := $(shell git describe 2>/dev/null; if [ $${?} != 0 ]; then echo 'unknown'; fi)
ROOT = $(CURDIR)
M1_HOME_BREW =
ifeq ($(OS),Darwin)
ifneq ($(wildcard /opt/homebrew),)
M1_HOME_BREW = true
endif
endif
# M1 macs brew install openssl under /opt/homebrew/opt/openssl
# set OPENSSL_PREFIX to the prefix for your openssl if it is installed elsewhere
OPENSSL_PREFIX ?= /usr/local/opt/openssl
ifdef M1_HOME_BREW
OPENSSL_PREFIX = /opt/homebrew/opt/openssl
endif
ifeq ($(OS),Darwin)
DYNAMIC_SUFFIX = dylib
DYNAMIC_FLAG = -dynamiclib
else
DYNAMIC_SUFFIX = so
DYNAMIC_FLAG = -shared
endif
DYNAMIC_OPTIONS =
CC ?= cc
DWARF := $(shell $(CC) -Wall -Wextra -O2 -o /tmp/asflags_$${$$} src/flags.c; \
/tmp/asflags_$${$$}; rm /tmp/asflags_$${$$})
CFLAGS += -std=gnu11 $(DWARF) -O2 -fno-common -fno-strict-aliasing \
-Wall -Wextra -Wconversion -Wsign-conversion -Wmissing-declarations \
-Wno-implicit-fallthrough -Wno-unused-result -Wno-typedef-redefinition \
-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_FORTIFY_SOURCE=2 -DMARCH_$(ARCH) \
-DTOOL_VERSION=\"$(VERSION)\"
CXXFLAGS := -std=c++14 $(DWARF) -O2 -fno-common -fno-strict-aliasing \
-Wall -Wextra -Wconversion -Wsign-conversion -Wmissing-declarations \
-Wno-implicit-fallthrough -Wno-unused-result \
-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_FORTIFY_SOURCE=2 -DMARCH_$(ARCH) \
-DTOOL_VERSION=\"$(VERSION)\"
LD := $(CC)
LDFLAGS += $(CXXFLAGS)
ifeq ($(OS), Linux)
LDFLAGS += -pthread
endif
TEST_CFLAGS := -std=gnu11 $(DWARF) -g -O2 -fno-common -fno-strict-aliasing \
-Wall -Wextra -Wconversion -Wsign-conversion -Wmissing-declarations \
-Wno-implicit-fallthrough -Wno-unused-result -Wno-typedef-redefinition \
-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_FORTIFY_SOURCE=2 -DMARCH_$(ARCH) \
-DTOOL_VERSION=\"$(VERSION)\"
TEST_CXXFLAGS := -std=c++14 $(DWARF) -g -O2 -fno-common -fno-strict-aliasing \
-Wall -Wextra -Wconversion -Wsign-conversion -Wmissing-declarations \
-Wno-implicit-fallthrough -Wno-unused-result \
-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_FORTIFY_SOURCE=2 -DMARCH_$(ARCH) \
-DTOOL_VERSION=\"$(VERSION)\"
TEST_LDFLAGS := $(LDFLAGS) -fprofile-arcs -lcheck
ifeq ($(EVENT_LIB),libev)
CFLAGS += -DAS_USE_LIBEV
CXXFLAGS += -DAS_USE_LIBEV
TEST_CFLAGS += -DAS_USE_LIBEV
TEST_CXXFLAGS += -DAS_USE_LIBEV
endif
ifeq ($(EVENT_LIB),libuv)
CFLAGS += -DAS_USE_LIBUV
CXXFLAGS += -DAS_USE_LIBUV
TEST_CFLAGS += -DAS_USE_LIBUV
TEST_CXXFLAGS += -DAS_USE_LIBUV
endif
ifeq ($(EVENT_LIB),libevent)
CFLAGS += -DAS_USE_LIBEVENT
CXXFLAGS += -DAS_USE_LIBEVENT
TEST_CFLAGS += -DAS_USE_LIBEVENT
TEST_CXXFLAGS += -DAS_USE_LIBEVENT
endif
DIR_INC := $(ROOT)/include
DIR_SRC := $(ROOT)/src
DIR_OBJ := $(ROOT)/obj
DIR_MODULES := $(ROOT)/modules
DIR_UNIT_TEST := $(ROOT)/test/unit
DIR_TEST_BIN := $(ROOT)/test_target
DIR_TEST_OBJ := $(DIR_TEST_BIN)/obj
DIR_INTEGRATION_TEST := $(ROOT)/test/integration
DIR_BIN := $(ROOT)/bin
DIR_LIB := $(ROOT)/lib
DIR_DOCS := $(ROOT)/docs
DIR_ENV := $(ROOT)/env
DIR_TOML := $(ROOT)/src/toml
DIR_C_CLIENT ?= $(DIR_MODULES)/c-client
C_CLIENT_LIB := $(DIR_C_CLIENT)/target/$(PLATFORM)/lib/libaerospike.a
DIR_SECRET_CLIENT ?= $(DIR_MODULES)/secret-agent-client
SECRET_CLIENT_LIB := $(DIR_SECRET_CLIENT)/target/$(PLATFORM)/lib/libsecret-agent-client-c.a
INCLUDES := -I$(DIR_INC)
INCLUDES += -I$(DIR_TOML)
INCLUDES += -I$(DIR_C_CLIENT)/src/include
INCLUDES += -I$(DIR_C_CLIENT)/modules/common/src/include
INCLUDES += -I$(OPENSSL_PREFIX)/include
INCLUDES += -I$(DIR_SECRET_CLIENT)/src/include
INCLUDES += -I/usr/local/include
LIBRARIES := $(C_CLIENT_LIB)
LIBRARIES += $(SECRET_CLIENT_LIB)
LIBRARIES += -L/usr/local/lib
ifdef M1_HOME_BREW
LIBRARIES += -L/opt/homebrew/lib
INCLUDES += -I/opt/homebrew/include
endif
ifeq ($(JANSSON_STATIC_PATH),)
LIBRARIES += -ljansson
else
LIBRARIES += $(JANSSON_STATIC_PATH)/libjansson.a
endif
ifeq ($(AWS_SDK_STATIC_PATH),)
# do not change the order of these
LIBRARIES += -laws-cpp-sdk-s3
LIBRARIES += -laws-cpp-sdk-core
LIBRARIES += -laws-crt-cpp
LIBRARIES += -laws-c-s3
LIBRARIES += -laws-c-auth
LIBRARIES += -laws-c-sdkutils
LIBRARIES += -laws-c-mqtt
LIBRARIES += -laws-c-http
LIBRARIES += -laws-c-event-stream
LIBRARIES += -laws-c-io
LIBRARIES += -laws-c-compression
LIBRARIES += -laws-checksums
LIBRARIES += -laws-c-cal
LIBRARIES += -laws-c-common
ifeq ($(CURL_STATIC_PATH),)
LIBRARIES += -lcurl
else
LIBRARIES += $(CURL_STATIC_PATH)/libcurl.a
endif
else
# do not change the order of these
LIBRARIES += $(AWS_SDK_STATIC_PATH)/libaws-cpp-sdk-s3.a
LIBRARIES += $(AWS_SDK_STATIC_PATH)/libaws-cpp-sdk-core.a
LIBRARIES += $(AWS_SDK_STATIC_PATH)/libaws-crt-cpp.a
LIBRARIES += $(AWS_SDK_STATIC_PATH)/libaws-c-s3.a
LIBRARIES += $(AWS_SDK_STATIC_PATH)/libaws-c-auth.a
LIBRARIES += $(AWS_SDK_STATIC_PATH)/libaws-c-sdkutils.a
LIBRARIES += $(AWS_SDK_STATIC_PATH)/libaws-c-mqtt.a
LIBRARIES += $(AWS_SDK_STATIC_PATH)/libaws-c-http.a
LIBRARIES += $(AWS_SDK_STATIC_PATH)/libaws-c-event-stream.a
LIBRARIES += $(AWS_SDK_STATIC_PATH)/libaws-c-io.a
LIBRARIES += $(AWS_SDK_STATIC_PATH)/libaws-c-compression.a
LIBRARIES += $(AWS_SDK_STATIC_PATH)/libaws-checksums.a
LIBRARIES += $(AWS_SDK_STATIC_PATH)/libaws-c-cal.a
ifeq ($(OS),Linux)
LIBRARIES += $(AWS_SDK_STATIC_PATH)/libs2n.a
endif
LIBRARIES += $(AWS_SDK_STATIC_PATH)/libaws-c-common.a
ifeq ($(OS),Darwin)
LIBRARIES += -framework CoreFoundation -framework Security
endif
ifeq ($(CURL_STATIC_PATH),)
LIBRARIES += -lcurl
else
LIBRARIES += $(CURL_STATIC_PATH)/libcurl.a
endif
ifeq ($(OS),Darwin)
LIBRARIES += -framework SystemConfiguration
ifeq ($(LIBSSH2_STATIC_PATH),)
LIBRARIES += -lssh2
else
LIBRARIES += $(LIBSSH2_STATIC_PATH)/libssh2.a
endif
endif
endif
ifeq ($(OPENSSL_STATIC_PATH),)
LIBRARIES += -L$(OPENSSL_PREFIX)/lib
LIBRARIES += -lssl
LIBRARIES += -lcrypto
else
LIBRARIES += $(OPENSSL_STATIC_PATH)/libssl.a
LIBRARIES += $(OPENSSL_STATIC_PATH)/libcrypto.a
endif
LIBRARIES += -lpthread
LIBRARIES += -lm
ifeq ($(ZLIB_STATIC_PATH),)
LIBRARIES += -lz
else
LIBRARIES += $(ZLIB_STATIC_PATH)/libz.a
endif
ifeq ($(ZSTD_STATIC_PATH),)
LIBRARIES += -lzstd
else
LIBRARIES += $(ZSTD_STATIC_PATH)/libzstd.a
endif
ifeq ($(EVENT_LIB),libev)
ifeq ($(LIBEV_STATIC_PATH),)
LIBRARIES += -lev
else
LIBRARIES += $(LIBEV_STATIC_PATH)/libev.a
endif
endif
ifeq ($(EVENT_LIB),libuv)
ifeq ($(LIBUV_STATIC_PATH),)
LIBRARIES += -luv
else
LIBRARIES += $(LIBUV_STATIC_PATH)/libuv.a
endif
endif
ifeq ($(EVENT_LIB),libevent)
ifeq ($(LIBEVENT_STATIC_PATH),)
LIBRARIES += -levent_core -levent_pthreads
else
LIBRARIES += $(LIBEVENT_STATIC_PATH)/libevent_core.a $(LIBEVENT_STATIC_PATH)/libevent_pthreads.a
endif
endif
ifeq ($(OS), Linux)
LIBRARIES += -ldl -lrt
LIBRARIES += -L$(DIR_TOML) -Wl,-l,:libtoml.a
else
LIBRARIES += $(DIR_TOML)/libtoml.a
endif
# if this is an m1 mac using homebrew
# add the new homebrew lib and include path
# incase dependencies are installed there
# NOTE: /usr/local/include will be checked first
ifdef M1_HOME_BREW
LIBRARIES += -L/opt/homebrew/lib
INCLUDES += -I/opt/homebrew/include
endif
src_to_obj = $(filter $(DIR_OBJ)/%.o,$(1:$(DIR_SRC)/%.c=$(DIR_OBJ)/%_c.o) $(1:$(DIR_SRC)/%.cc=$(DIR_OBJ)/%_cc.o))
obj_to_dep = $(1:%.o=%.d)
src_to_lib =
BACKUP_SRC_MAIN := $(DIR_SRC)/backup_main.c
RESTORE_SRC_MAIN := $(DIR_SRC)/restore_main.c
FLAGS_SRC_MAIN := $(DIR_SRC)/flags.c
TOML_SRC_MAIN := $(DIR_SRC)/toml/toml.c
HELPER_SRCS := $(filter-out $(BACKUP_SRC_MAIN) $(RESTORE_SRC_MAIN) \
$(FLAGS_SRC_MAIN) $(TOML_SRC_MAIN),\
$(shell find $(DIR_SRC) -name '*.c' -type f))
HELPER_CXX_SRCS := $(filter-out $(BACKUP_SRC_MAIN) $(RESTORE_SRC_MAIN) \
$(FLAGS_SRC_MAIN) $(TOML_SRC_MAIN),\
$(shell find $(DIR_SRC) -name '*.cc' -type f))
BACKUP_SRC := $(BACKUP_SRC_MAIN) $(HELPER_SRCS) $(HELPER_CXX_SRCS)
BACKUP_OBJ := $(call src_to_obj, $(BACKUP_SRC))
BACKUP_DEP := $(call obj_to_dep, $(BACKUP_OBJ))
RESTORE_SRC := $(RESTORE_SRC_MAIN) $(HELPER_SRCS) $(HELPER_CXX_SRCS)
RESTORE_OBJ := $(call src_to_obj, $(RESTORE_SRC))
RESTORE_DEP := $(call obj_to_dep, $(RESTORE_OBJ))
BACKUP := $(DIR_BIN)/asbackup
RESTORE := $(DIR_BIN)/asrestore
TOML := $(DIR_TOML)/libtoml.a
BACKUP_DYNAMIC := $(DIR_BIN)/asbackup.$(DYNAMIC_SUFFIX)
RESTORE_DYNAMIC := $(DIR_BIN)/asrestore.$(DYNAMIC_SUFFIX)
SRCS := $(BACKUP_SRC) $(RESTORE_SRC)
OBJS := $(BACKUP_OBJ) $(RESTORE_OBJ)
DEPS := $(BACKUP_DEP) $(RESTORE_DEP)
BINS := $(TOML) $(BACKUP) $(RESTORE)
# sort removes duplicates
SRCS := $(sort $(SRCS))
OBJS := $(sort $(OBJS))
DEPS := $(sort $(DEPS))
# test target
test_src_to_obj = $(filter $(DIR_TEST_OBJ)/src/%.o,$(1:$(DIR_SRC)/%.c=$(DIR_TEST_OBJ)/src/%_c.o) $(1:$(DIR_SRC)/%.cc=$(DIR_TEST_OBJ)/src/%_cc.o))
HELPER_OBJS := $(call test_src_to_obj, $(HELPER_SRCS) $(HELPER_CXX_SRCS))
TEST_SRC := $(shell find $(DIR_UNIT_TEST) -name '*.c' -type f)
TEST_OBJ := $(HELPER_OBJS) $(patsubst $(DIR_UNIT_TEST)/%.c,$(DIR_TEST_OBJ)/unit/%.o,$(TEST_SRC))
TEST_DEP := $(patsubst $(DIR_TEST_OBJ)/%.o,$(DIR_TEST_OBJ)/%.d,$(TEST_OBJ))
TEST_INTEGRATION_TESTS := $(patsubst $(DIR_INTEGRATION_TEST)/%.py,run_%,$(shell find $(DIR_INTEGRATION_TEST) -name 'test_*.py' -type f))
TEST_BACKUP_SRC := $(BACKUP_SRC_MAIN) $(HELPER_SRCS) $(HELPER_CXX_SRCS)
TEST_BACKUP_OBJ := $(call test_src_to_obj, $(TEST_BACKUP_SRC))
TEST_BACKUP_DEP := $(call obj_to_dep, $(TEST_BACKUP_OBJ))
TEST_RESTORE_SRC := $(RESTORE_SRC_MAIN) $(HELPER_SRCS) $(HELPER_CXX_SRCS)
TEST_RESTORE_OBJ := $(call test_src_to_obj, $(TEST_RESTORE_SRC))
TEST_RESTORE_DEP := $(call obj_to_dep, $(TEST_RESTORE_OBJ))
TEST_BACKUP := $(DIR_TEST_BIN)/asbackup
TEST_RESTORE := $(DIR_TEST_BIN)/asrestore
TEST_BINS := $(TEST_BACKUP) $(TEST_RESTORE)
TEST_OBJS := $(TEST_OBJ) $(TEST_BACKUP_OBJ) $(TEST_RESTORE_OBJ)
TEST_DEPS := $(TEST_DEP) $(TEST_BACKUP_DEP) $(TEST_RESTORE_DEP)
TEST_OBJS := $(sort $(TEST_OBJS))
TEST_DEPS := $(sort $(TEST_DEPS))
.PHONY: all
all: $(BINS)
# used as a pre-requisite for make shared
# this rule is not meant for manual use by a user
.PHONY: _set_dynamic_options
_set_dynamic_options:
$(eval CFLAGS += -DASB_SHARED_LIB)
$(eval DYNAMIC_OPTIONS = -fPIC)
# builds asbackup and asrestore as shared libraries
# asbackup is designed as a standalone exe, use at your own risk
# run this with the same options you would use in a normal build
.PHONY: shared
shared: _set_dynamic_options $(TOML) $(BACKUP_DYNAMIC) $(RESTORE_DYNAMIC)
$(eval DYNAMIC_OPTIONS =)
.PHONY: clean
clean:
$(MAKE) -C $(DIR_TOML) clean
$(MAKE) -C $(DIR_C_CLIENT) clean
$(MAKE) -C $(DIR_SECRET_CLIENT) clean
rm -f $(DEPS) $(OBJS) $(BINS) $(TEST_OBJS) $(TEST_DEPS) $(TEST_BINS) $(BACKUP_DYNAMIC) $(RESTORE_DYNAMIC)
if [ -d $(DIR_OBJ) ]; then rmdir $(DIR_OBJ); fi
if [ -d $(DIR_BIN) ]; then rmdir $(DIR_BIN); fi
if [ -d $(DIR_TEST_OBJ) ]; then rm -r $(DIR_TEST_OBJ); fi
if [ -d $(DIR_TEST_BIN) ]; then rm -r $(DIR_TEST_BIN); fi
if [ -d $(DIR_DOCS) ]; then rm -r $(DIR_DOCS); fi
if [ -d $(DIR_ENV) ]; then rm -rf $(DIR_ENV); fi
.PHONY: info
info:
@echo
@echo " ROOT: " $(ROOT)
@echo " OS: " $(OS)
@echo " ARCH: " $(ARCH)
@echo " CLIENTREPO: " $(DIR_C_CLIENT)
@echo " WD: " $(shell pwd)
@echo " EVENT_LIB: " $(EVENT_LIB)
@echo
@echo " PATHS:"
@echo " source: " $(DIR_SRC)
@echo " target: " $(DIR_BIN)
@echo " includes: " $(DIR_INC)
@echo " libraries: " $(DIR_LIB)
@echo
@echo " COMPILER:"
@echo " command: " $(CC)
@echo " flags: " $(CFLAGS)
@echo
@echo " LINKER:"
@echo " command: " $(LD)
@echo " flags: " $(LDFLAGS)
@echo
$(DIR_DOCS): $(OBJS) $(SRCS) README.md
if [ ! -d $(DIR_DOCS) ]; then mkdir $(DIR_DOCS); fi
doxygen doxyfile
$(DIR_OBJ):
mkdir $(DIR_OBJ)
$(DIR_BIN):
mkdir $(DIR_BIN)
$(DIR_OBJ)/%_c.o: $(DIR_SRC)/%.c | $(DIR_OBJ)
$(CC) $(DYNAMIC_OPTIONS) $(CFLAGS) -MMD -o $@ -c $(INCLUDES) $<
$(DIR_OBJ)/%_cc.o: $(DIR_SRC)/%.cc | $(DIR_OBJ)
$(CXX) $(DYNAMIC_OPTIONS) $(CXXFLAGS) -MMD -o $@ -c $(INCLUDES) $<
$(BACKUP): $(BACKUP_OBJ) $(TOML) $(C_CLIENT_LIB) $(SECRET_CLIENT_LIB) | $(DIR_BIN)
$(CXX) $(LDFLAGS) -o $(BACKUP) $(BACKUP_OBJ) $(LIBRARIES)
$(RESTORE): $(RESTORE_OBJ) $(TOML) $(C_CLIENT_LIB) $(SECRET_CLIENT_LIB) | $(DIR_BIN)
$(CXX) $(LDFLAGS) -o $(RESTORE) $(RESTORE_OBJ) $(LIBRARIES)
$(BACKUP_DYNAMIC): $(BACKUP_OBJ) $(TOML) $(C_CLIENT_LIB) $(SECRET_CLIENT_LIB) | $(DIR_BIN)
$(CXX) $(DYNAMIC_FLAG) $(LDFLAGS) -o $(BACKUP_DYNAMIC) $(BACKUP_OBJ) $(LIBRARIES)
$(RESTORE_DYNAMIC): $(RESTORE_OBJ) $(TOML) $(C_CLIENT_LIB) $(SECRET_CLIENT_LIB) | $(DIR_BIN)
$(CXX) $(DYNAMIC_FLAG) $(LDFLAGS) -o $(RESTORE_DYNAMIC) $(RESTORE_OBJ) $(LIBRARIES)
$(TOML):
$(MAKE) -C $(DIR_TOML) CFLAGS=$(DYNAMIC_OPTIONS)
$(C_CLIENT_LIB):
$(MAKE) -C $(DIR_C_CLIENT) EVENT_LIB=$(EVENT_LIB)
$(SECRET_CLIENT_LIB):
$(MAKE) -C $(DIR_SECRET_CLIENT)
-include $(BACKUP_DEP)
-include $(RESTORE_DEP)
.PHONY: test
test: unit integration
.PHONY: unit
unit: $(DIR_TEST_BIN)/test
@$<
@#CK_FORK=no valgrind --tool=memcheck --leak-check=full --track-origins=yes --show-leak-kinds=all $<
.PHONY: integration
integration: $(TEST_INTEGRATION_TESTS)
run_%: $(TEST_BINS) FORCE | coverage-init
@./tests.sh $(DIR_ENV) $(patsubst run_%,$(DIR_INTEGRATION_TEST)/%.py,$@)
FORCE:
$(DIR_TEST_BIN):
mkdir $@
$(DIR_TEST_OBJ): | $(DIR_TEST_BIN)
mkdir $@
$(DIR_TEST_OBJ)/unit: | $(DIR_TEST_OBJ)
mkdir $@
$(DIR_TEST_OBJ)/src: | $(DIR_TEST_OBJ)
mkdir $@
$(DIR_TEST_OBJ)/unit/%.o: test/unit/%.c | $(DIR_TEST_OBJ)/unit
$(CC) $(TEST_CFLAGS) -MMD $(INCLUDES) -o $@ -c $<
$(DIR_TEST_OBJ)/src/%_c.o: src/%.c | $(DIR_TEST_OBJ)/src
$(CC) $(TEST_CFLAGS) -MMD $(INCLUDES) -fprofile-arcs -ftest-coverage -o $@ -c $<
$(DIR_TEST_OBJ)/src/%_cc.o: src/%.cc | $(DIR_TEST_OBJ)/src
$(CXX) $(TEST_CXXFLAGS) -MMD $(INCLUDES) -fprofile-arcs -ftest-coverage -o $@ -c $<
$(DIR_TEST_BIN)/test: $(TEST_OBJ) $(DIR_C_CLIENT)/target/$(PLATFORM)/lib/libaerospike.a $(TOML) | $(DIR_TEST_BIN)
$(CXX) -o $@ $(TEST_OBJ) $(DIR_C_CLIENT)/target/$(PLATFORM)/lib/libaerospike.a $(TEST_LDFLAGS) $(LIBRARIES)
$(TEST_BACKUP): shared $(TEST_BACKUP_OBJ) $(TOML) $(C_CLIENT_LIB) $(SECRET_CLIENT_LIB) | $(DIR_TEST_BIN)
$(CXX) $(TEST_LDFLAGS) -o $(TEST_BACKUP) $(TEST_BACKUP_OBJ) $(LIBRARIES)
$(TEST_RESTORE): shared $(TEST_RESTORE_OBJ) $(TOML) $(C_CLIENT_LIB) $(SECRET_CLIENT_LIB) | $(DIR_TEST_BIN)
$(CXX) $(TEST_LDFLAGS) -o $(TEST_RESTORE) $(TEST_RESTORE_OBJ) $(LIBRARIES)
-include $(TEST_DEPS)
# Requires the lcov tool to be installed
$(DIR_TEST_BIN)/aerospike-tools-backup.info: FORCE
lcov -o $(DIR_TEST_BIN)/aerospike-tools-backup-test.info --capture --directory $(DIR_TEST_BIN)
lcov -o $(DIR_TEST_BIN)/aerospike-tools-backup-test.info --quiet --extract $(DIR_TEST_BIN)/aerospike-tools-backup-test.info '$(DIR_SRC)/*' '$(DIR_INC)/*'
lcov -o $(DIR_TEST_BIN)/aerospike-tools-backup.info --quiet -a $(DIR_TEST_BIN)/aerospike-tools-backup-baseline.info -a $(DIR_TEST_BIN)/aerospike-tools-backup-test.info
.PHONY: coverage
coverage: | $(DIR_TEST_BIN)/aerospike-tools-backup.info
@lcov --summary $(DIR_TEST_BIN)/aerospike-tools-backup.info
.PHONY: coverage-init
coverage-init: $(TEST_BINS)
@lcov --zerocounters --directory $(DIR_TEST_BIN)
@lcov -o $(DIR_TEST_BIN)/aerospike-tools-backup-baseline.info --directory $(DIR_TEST_BIN) --capture --initial
@lcov -o $(DIR_TEST_BIN)/aerospike-tools-backup-baseline.info --quiet --extract $(DIR_TEST_BIN)/aerospike-tools-backup-baseline.info '$(DIR_SRC)/*' '$(DIR_INC)/*'
.PHONY: do-test
do-test: | coverage-init
@$(MAKE) -C . unit
.PHONY: report
report: | $(DIR_TEST_BIN)/aerospike-tools-backup.info
@lcov -l $(DIR_TEST_BIN)/aerospike-tools-backup.info
.PHONY: report-display
report-display: | $(DIR_TEST_BIN)/aerospike-tools-backup.info
@echo
@rm -rf $(DIR_TEST_BIN)/html
@mkdir -p $(DIR_TEST_BIN)/html
@genhtml --prefix $(DIR_TEST_BIN)/html --ignore-errors source $(DIR_TEST_BIN)/aerospike-tools-backup.info --legend --title "test lcov" --output-directory $(DIR_TEST_BIN)/html