forked from zaherm/lua-rocksdb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
62 lines (45 loc) · 1.48 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
UNAME := $(shell uname)
all-tests := $(basename $(wildcard test/*.lua))
######################################
# Variabes that can be setted:
# LUA_VERSION Example: LUA_VERSION="5.3"
# LUA_INC Example: LUA_INC="-I/usr/local/include/lua"
# LUA_LIB Example: LUA_LIB="-L/usr/local/lib/lua"
# ROCKSDB_INC Example: ROCKSDB_INC="-I/usr/local/include/rocksdb"
# ROCKSDB_LIB Example: ROCKSDB_LIB="-L/usr/local/lib/rocksdb"
######################################
LUA_LIB_DEF=
LUA_INC_DEF= -I/usr/include/lua${LUA_VERSION}
ROCKSDB_LIB_DEF=
ROCKSDB_INC_DEF=
EXTRACFLAGS= -std=c99 -undefined -fPIC
LUA_INC := $(if $(LUA_INC),$(LUA_INC), $(LUA_INC_DEF))
LUA_LIB := $(if $(LUA_LIB),$(LUA_LIB), $(LUA_LIB_DEF))
ROCKSDB_INC := $(if $(ROCKSDB_INC),$(ROCKSDB_INC), $(ROCKSDB_INC_DEF))
ROCKSDB_LIB := $(if $(ROCKSDB_LIB),$(ROCKSDB_LIB), $(ROCKSDB_LIB_DEF))
INC= -I/usr/include $(LUA_INC) $(ROCKSDB_INC)
LIB= -L/usr/lib $(LUA_LIB) $(ROCKSDB_LIB)
WARN= -Wall
CFLAGS= -O2 $(WARN) $(INC)
MYNAME= rocksdb
MYLIB= $(MYNAME)
T= $(MYLIB).so
OBJS= src/l$(MYLIB).o \
src/l$(MYLIB)_helpers.o \
src/l$(MYLIB)_options.o \
src/l$(MYLIB)_backup_engine.o \
src/l$(MYLIB)_writebatch.o \
src/l$(MYLIB)_iter.o
all: $T
print-% : ; @echo $* = $($*)
%.o: %.c
$(CC) $(CFLAGS) -fPIC -c -o $@ $<
$T: $(OBJS)
$(CC) $(CFLAGS) $(LIB) $(EXTRACFLAGS) -o $@ -shared $(OBJS)
clean:
rm -f $T $(OBJS)
tests: $(all-tests)
test/test_%: $T
test: clean all tests
install: $(TARGET)