forked from RedisBloom/RedisBloom
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
105 lines (82 loc) · 2.57 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
DEBUGFLAGS = -g -ggdb -O2
ifeq ($(DEBUG), 1)
DEBUGFLAGS = -g -ggdb -O0 -pedantic
endif
# find the OS
uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not')
CPPFLAGS = -Wall -Wno-unused-function $(DEBUGFLAGS) -fPIC -std=gnu99 -D_GNU_SOURCE
# CC:=$(shell sh -c 'type $(CC) >/dev/null 2>/dev/null && echo $(CC) || echo gcc')
# Compile flags for linux / osx
ifeq ($(uname_S),Linux)
CC=gcc
LD=gcc
SHOBJ_CFLAGS ?= -fno-common -g -ggdb
SHOBJ_LDFLAGS ?= -shared -Wl,-Bsymbolic,-Bsymbolic-functions
else
CC=clang
CFLAGS += -mmacosx-version-min=10.6
SHOBJ_CFLAGS ?= -dynamic -fno-common -g -ggdb
SHOBJ_LDFLAGS ?= -dylib -exported_symbol _RedisModule_OnLoad -macosx_version_min 10.6
endif
ROOT=$(shell pwd)
# Flags for preprocessor
LDFLAGS = -lm -lc
CPPFLAGS += -I$(ROOT) -I$(ROOT)/contrib
SRCDIR := $(ROOT)/src
MODULE_OBJ = $(SRCDIR)/rebloom.o
MODULE_SO = $(ROOT)/redisbloom.so
DEPS = $(ROOT)/contrib/MurmurHash2.o \
$(ROOT)/rmutil/util.o \
$(SRCDIR)/sb.o \
$(SRCDIR)/cf.o \
$(SRCDIR)/rm_topk.o \
$(SRCDIR)/topk.o \
$(SRCDIR)/rm_cms.o \
$(SRCDIR)/cms.o
export
ifeq ($(COV),1)
CFLAGS += -fprofile-arcs -ftest-coverage
LDFLAGS += -fprofile-arcs
endif
all: $(MODULE_SO)
$(MODULE_SO): $(MODULE_OBJ) $(DEPS)
$(LD) $^ -o $@ $(SHOBJ_LDFLAGS) $(LDFLAGS)
build: all
$(MAKE) -C tests build-test
test: $(MODULE_SO)
$(MAKE) -C tests test
build-test: $(MODULE_SO)
$(MAKE) -C tests build-test
perf:
$(MAKE) -C tests perf
package: $(MODULE_SO)
mkdir -p $(ROOT)/build
ramp-packer -vvv -m ramp.yml -o "$(ROOT)/build/rebloom.{os}-{architecture}.latest.zip" "$(MODULE_SO)"
clean:
$(RM) $(MODULE_OBJ) $(MODULE_SO) $(DEPS)
$(RM) -f print_version
$(RM) -rf build
$(RM) -rf tmp
find . -name '*.gcov' -delete
find . -name '*.gcda' -delete
find . -name '*.gcno' -delete
$(MAKE) -C tests clean
distclean: clean
docker:
docker build -t redislabs/rebloom .
docker_push: docker
docker push redislabs/rebloom:latest
# Compile an executable that prints the current version
print_version: $(SRCDIR)/version.h $(SRCDIR)/print_version.c
@$(CC) -o $@ -DPRINT_VERSION_TARGET $(SRCDIR)/[email protected]
# $(MAKE) CFLAGS="-fprofile-arcs -ftest-coverage" LDFLAGS="-fprofile-arcs"
COV_DIR=tmp/lcov
cov coverage:
@$(MAKE) clean
@$(MAKE) test COV=1
mkdir -p $(COV_DIR)
gcov -c -b $(SRCDIR)/* > /dev/null 2>&1
lcov -d . -c -o $(COV_DIR)/gcov.info --no-external > /dev/null 2>&1
lcov -r $(COV_DIR)/gcov.info "*test*" "*contrib*" "*redismodule.h" "*util.c*" -o $(COV_DIR)/gcov.info > /dev/null 2>&1
lcov -l $(COV_DIR)/gcov.info
genhtml --legend -o $(COV_DIR)/report $(COV_DIR)/gcov.info > /dev/null 2>&1