-
Notifications
You must be signed in to change notification settings - Fork 47
/
Makefile
65 lines (52 loc) · 1.55 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
CC = gcc
override CFLAGS += -O3 -Wall -fPIC
LDFLAGS =
OBJECTS = build/hash_ring.o build/sha1.o build/sort.o build/md5.o
TEST_OBJECTS = build/hash_ring_test.o
ifdef PREFIX
prefix=$(PREFIX)
else
prefix=/usr/local
endif
UNAME=$(shell uname)
TOP:=$(abspath $(dir $(lastword $(MAKEFILE_LIST))))
ERLANG_RELEASE=$(shell erl -eval 'erlang:display(erlang:system_info(otp_release)), halt().' -noshell)
ERLANG_RELEASE_VER=$(shell echo $(ERLANG_RELEASE) | sed -E "s/R([0-9]+).*/\1/")
ERLANG_R14_OR_HIGHER=$(shell expr $(ERLANG_RELEASE_VER) \>= 14)
ifeq ($(ERLANG_R14_OR_HIGHER), 1)
REBAR="./rebar"
else
REBAR="./rebar.r13"
endif
ifeq ($(UNAME), Darwin)
SHARED_LIB = build/libhashring.dylib
else
SHARED_LIB = build/libhashring.so
endif
lib: $(OBJECTS)
$(CC) $(CFLAGS) $(LDFLAGS) $(OBJECTS) -o $(SHARED_LIB) -shared
test : lib bindings $(TEST_OBJECTS)
mkdir -p bin
LD_LIBRARY_PATH="$(TOP)/build" $(REBAR) compile eunit
cd lib/java && LD_LIBRARY_PATH="$(TOP)/build" ./gradlew test
cd lib/python && LD_LIBRARY_PATH="$(TOP)/build" python tests.py
$(CC) $(CFLAGS) $(LDFLAGS) $(TEST_OBJECTS) -lhashring -L./build -o bin/hash_ring_test
bin/hash_ring_test
bindings: erl java python
erl:
$(REBAR) compile eunit
java:
cd lib/java && ./gradlew jar
python:
cd lib/python && ./setup.py bdist
build/%.o : %.c
$(CC) $(CFLAGS) -c $< -o $@
clean:
rm -rf $(OBJECTS) $(TEST_OBJECTS) $(SHARED_LIB)
$(REBAR) clean
cd lib/java && ./gradlew clean
install: lib
mkdir -p $(prefix)/lib
mkdir -p $(prefix)/include
cp -f $(SHARED_LIB) $(prefix)/lib/
cp hash_ring.h $(prefix)/include/