-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
62 lines (49 loc) · 1.53 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
MIX=mix
CC=clang
LIBEJDB_PATH=deps/libejdb
LIBEJDB_INSTALL=$(LIBEJDB_PATH)/install_prefix
CFLAGS = -std=c11 -pedantic -Wall
ifeq ($(COVERAGE),true)
# LLVM
# CFLAGS += -fprofile-instr-generate -fcoverage-mapping
# GCOV
CFLAGS += -fprofile-arcs -ftest-coverage -g -O0
else
CFLAGS += -O3
endif
ERLANG_PATH = $(shell erl -eval 'io:format("~s", [lists:concat([code:root_dir(), "/erts-", erlang:system_info(version), "/include"])])' -s init stop -noshell)
CFLAGS += -I$(ERLANG_PATH) -I$(LIBEJDB_INSTALL)/include
OBJDIR = priv
SRCDIR = src
C_SRCS = nif.c ejdb.c utils.c ejcoll.c
H_DEPS = ejdb.h utils.h ejcoll.h
SRCS = $(addprefix $(SRCDIR)/,$(C_SRCS))
OBJS = $(addprefix $(OBJDIR)/,$(C_SRCS:.c=.o))
DEPS = $(addprefix $(SRCDIR)/,$(H_DEPS))
ifneq ($(OS),Windows_NT)
CFLAGS += -fPIC
ifeq ($(shell uname),Darwin)
LDFLAGS += -dynamiclib -undefined dynamic_lookup
endif
endif
.PHONY: libejdb clean_coverage clean_priv clean
clean_coverage:
rm -f *.gcov priv/*.gcda priv/*.gcno
clean_priv: clean_coverage
rm -r priv/*.o
rm -rf priv/ejdb.so
clean: clean_priv
$(MIX) clean
make -C $(LIBEJDB_PATH)/build clean
rm -rf $(LIBEJDB_INSTALL)
libejdb:
cd $(LIBEJDB_PATH) && \
mkdir -p build && \
cd build && \
cmake -DBUILD_SAMPLES=OFF -DBUILD_SHARED_LIBS=OFF -DCMAKE_INSTALL_PREFIX=$(CURDIR)/$(LIBEJDB_INSTALL) -DCMAKE_BUILD_TYPE=Release ../ && \
make && \
make install
$(OBJDIR)/%.o: $(SRCDIR)/%.c $(DEPS)
$(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $<
priv/ejdb.so: $(OBJS)
$(CC) $(CFLAGS) -shared $(LDFLAGS) -o $@ $^ $(LIBEJDB_INSTALL)/lib/libejdb-1.a