forked from chrismoos/hash-ring
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
59 lines (46 loc) · 1.25 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
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)
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 $(TEST_OBJECTS)
mkdir -p bin
$(CC) $(CFLAGS) $(LDFLAGS) $(TEST_OBJECTS) -lhashring -L./build -o bin/hash_ring_test
bin/hash_ring_test
bindings: erl java python
erl:
$(REBAR) compile
java:
cd lib/java && gradle jar
python:
cd lib/python && ./setup.py bdist
build/%.o : %.c
$(CC) $(CFLAGS) -c $< -o $@
clean:
rm -rf $(OBJECTS) $(TEST_OBJECTS) $(SHARED_LIB)
install: lib
mkdir -p $(prefix)/lib
mkdir -p $(prefix)/include
cp -f $(SHARED_LIB) $(prefix)/lib/
cp hash_ring.h $(prefix)/include/