-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
56 lines (45 loc) · 1.26 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
INST_PREFIX ?= /usr
INST_LIBDIR ?= $(INST_PREFIX)/lib/lua/5.1
INST_LUADIR ?= $(INST_PREFIX)/share/lua/5.1
INSTALL ?= install
RUST_LIB_PREFIX ?= ./prefix-trie
### lint: Lint Lua source code
.PHONY: lint
lint:
luacheck -q resty
### test: Run test suite. Use test=... for specific tests
.PHONY: test
test:
TEST_NGINX_LOG_LEVEL=info \
prove -I. -I../test-nginx/lib -r t/
### install: Install the library to runtime
.PHONY: install
install:
$(INSTALL) -d $(INST_LUADIR)/resty/
$(INSTALL) resty/*.lua $(INST_LUADIR)/resty/
PLATFORM := $(shell uname)
ifeq ($(PLATFORM), Linux)
C_SO_NAME := libipmatcher.so
else ifeq ($(PLATFORM), Darwin)
C_SO_NAME := libipmatcher.dylib
endif
### clean: Remove generated files
.PHONY: clean
clean:
rm -f $(C_SO_NAME)
cargo clean --manifest-path=$(RUST_LIB_PREFIX)/Cargo.toml
compile:
cargo build -r --manifest-path=$(RUST_LIB_PREFIX)/Cargo.toml
ifeq ($(PLATFORM), Linux)
cp $(RUST_LIB_PREFIX)/target/release/$(C_SO_NAME) .
else ifeq ($(PLATFORM), Darwin)
cp $(RUST_LIB_PREFIX)/target/release/$(C_SO_NAME) .
else
$(error Unsupported platform: $(PLATFORM))
endif
### help: Show Makefile rules
.PHONY: help
help:
@echo Makefile rules:
@echo
@grep -E '^### [-A-Za-z0-9_]+:' Makefile | sed 's/###/ /'