forked from mmzeeman/esqlite
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
53 lines (41 loc) · 1.34 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
PROJECT = esqlite
DIALYZER = dialyzer
ERL ?= erl
REBAR3 := $(shell which rebar3 2>/dev/null || echo ./rebar3)
REBAR3_VERSION := 3.14.1
REBAR3_URL := https://github.com/erlang/rebar3/releases/download/$(REBAR3_VERSION)/rebar3
ifeq (,$(STATIC_ERLANG_NIF))
all: compile
else
all: priv/esqlite3_nif.a
ERTS_INCLUDE_DIR ?= $(shell erl -noshell -s init stop -eval "io:format(\"~s/erts-~s/include/\", [code:root_dir(), erlang:system_info(version)]).")
CFLAGS += -DSTATIC_ERLANG_NIF=1 -I"$(ERTS_INCLUDE_DIR)"
CFLAGS += -DSQLITE_THREADSAFE=1 -DSQLITE_USE_URI -DSQLITE_ENABLE_FTS3 -DSQLITE_ENABLE_FTS3_PARENTHESIS
OBJS = c_src/esqlite3_nif.c c_src/queue.c c_src/sqlite3/sqlite3.c
RANLIB ?= ranlib
ARFLAGS ?= rc
endif
priv/esqlite3_nif.a: $(OBJS:.c=.o)
mkdir -p $(dir $@)
$(AR) $(ARFLAGS) $@ $^
$(RANLIB) $@
$(REBAR3):
$(ERL) -noshell -s inets -s ssl \
-eval '{ok, saved_to_file} = httpc:request(get, {"$(REBAR3_URL)", []}, [], [{stream, "./rebar3"}])' \
-s init stop
chmod +x ./rebar3
compile: $(REBAR3)
$(REBAR3) compile
test: compile
$(REBAR3) eunit
clean: $(REBAR3)
$(REBAR3) clean
distclean:
rm $(REBAR3)
# dializer
build-plt:
@$(DIALYZER) --build_plt --output_plt .$(PROJECT).plt \
--apps kernel stdlib
dialyze:
@$(DIALYZER) --src src --plt .$(PROJECT).plt --no_native \
-Werror_handling -Wrace_conditions -Wunmatched_returns -Wunderspecs