forked from api7/lua-resty-radixtree
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
77 lines (57 loc) · 1.9 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
66
67
68
69
70
71
72
73
74
75
76
77
INST_PREFIX ?= /usr
INST_LIBDIR ?= $(INST_PREFIX)/lib/lua/5.1
INST_LUADIR ?= $(INST_PREFIX)/share/lua/5.1
INSTALL ?= install
UNAME ?= $(shell uname)
CFLAGS := -O2 -g -Wall -fpic -std=c99 -Wno-pointer-to-int-cast -Wno-int-to-pointer-cast
C_SO_NAME := librestyradixtree.so
LDFLAGS := -shared
# on Mac OS X, one should set instead:
# for Mac OS X environment, use one of options
ifeq ($(UNAME),Darwin)
LDFLAGS := -bundle -undefined dynamic_lookup
C_SO_NAME := librestyradixtree.dylib
endif
MY_CFLAGS := $(CFLAGS) -DBUILDING_SO
MY_LDFLAGS := $(LDFLAGS) -fvisibility=hidden
OBJS := src/rax.o src/easy_rax.o
.PHONY: default
default: compile
### test: Run test suite. Use test=... for specific tests
.PHONY: test
test: compile
TEST_NGINX_LOG_LEVEL=info \
prove -I../test-nginx/lib -r -s t/
### clean: Remove generated files
.PHONY: clean
clean:
rm -f $(C_SO_NAME) $(OBJS) ${R3_CONGIGURE}
### compile: Compile library
.PHONY: compile
compile: ${R3_FOLDER} ${R3_CONGIGURE} ${R3_STATIC_LIB} $(C_SO_NAME)
${OBJS} : %.o : %.c
$(CC) $(MY_CFLAGS) -c $< -o $@
${C_SO_NAME} : ${OBJS}
$(CC) $(MY_LDFLAGS) $(OBJS) -o $@
### install: Install the library to runtime
.PHONY: install
install:
$(INSTALL) -d $(INST_LUADIR)/resty/
$(INSTALL) lib/resty/*.lua $(INST_LUADIR)/resty/
$(INSTALL) $(C_SO_NAME) $(INST_LIBDIR)/
### dev: Create a development ENV
.PHONY: dev
dev:
ifeq ($(UNAME),Darwin)
luarocks install --lua-dir=$(LUA_JIT_DIR) rockspec/lua-resty-radixtree-master-1.0-0.rockspec --only-deps
else ifneq ($(LUAROCKS_VER),'luarocks 3.')
luarocks install rockspec/lua-resty-radixtree-master-1.0-0.rockspec --only-deps
else
luarocks install --lua-dir=/usr/local/openresty/luajit rockspec/lua-resty-radixtree-master-1.0-0.rockspec --only-deps
endif
### help: Show Makefile rules
.PHONY: help
help:
@echo Makefile rules:
@echo
@grep -E '^### [-A-Za-z0-9_]+:' Makefile | sed 's/###/ /'