-
Notifications
You must be signed in to change notification settings - Fork 15
/
Makefile
56 lines (48 loc) · 1.31 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
CC=gcc
CXX=g++
CFLAGS=-Wall -fPIC -shared
CXXFLAGS=-Wall -fPIC -shared
VPATH=src
LDLIBS=-lleveldb -lsnappy -lpthread
CDEPS=src/*.h
CXXDEPS=src/*.hpp
OBJS=src/lua.o src/batch.o src/db.o src/iter.o src/opt.o src/utils.o src/lua-leveldb.o
RM=rm -f
TARGET=lualeveldb.so
# Add a custom version below (5.1/5.2/5.3)
LUA_VERSION?=5.3
LUA_PREFIX_DIR?=/usr
LUA_LIBDIR=$(LUA_PREFIX_DIR)/lib/lua/$(LUA_VERSION)
LUA_INCDIR=$(LUA_PREFIX_DIR)/include/lua$(LUA_VERSION)
LUA_SHAREDIR=$(LUA_PREFIX_DIR)/share/lua/$(LUA_VERSION)
$(TARGET): $(OBJS)
@echo -e '\033[0;36mBuilding target $@\033[0m'
ifneq ($(wildcard $(LUA_LIBDIR)),)
$(CXX) $(CXXFLAGS) -o $(TARGET) -L$(LUA_LIBDIR) $(OBJS) $(LDLIBS)
else
$(CXX) $(CXXFLAGS) -o $(TARGET) $(OBJS) $(LDLIBS)
endif
%.o: %.c $(CDEPS)
ifneq ($(wildcard $(LUA_INCDIR)),)
$(CC) -c -o $@ $< $(CFLAGS) -I$(LUA_INCDIR)
else
$(CC) -c -o $@ $< $(CFLAGS)
endif
%.o: %.cc $(CXXDEPS)
ifneq ($(wildcard $(LUA_INCDIR)),)
$(CXX) -c -o $@ $< $(CXXFLAGS) -I$(LUA_INCDIR)
else
$(CXX) -c -o $@ $< $(CXXFLAGS)
endif
liblualeveldb.o: lua.h batch.hpp db.hpp iter.hpp opt.hpp utils.hpp lua-leveldb.hpp
ifneq ($(wildcard $(LUA_INCDIR)),)
$(CXX) $(CXXFLAGS) -o -I$(LUA_INCDIR)
else
$(CXX) $(CXXFLAGS) -o
endif
.PHONY: clean
clean:
$(RM) $(OBJS)
$(RM) $(TARGET)
install:
@echo -e '\033[0;32mInstalling with luarocks\033[0m'