2019-05-31 21:06:55 +08:00
|
|
|
INST_PREFIX ?= /usr
|
|
|
|
INST_LIBDIR ?= $(INST_PREFIX)/lib64/lua/5.1
|
|
|
|
INST_LUADIR ?= $(INST_PREFIX)/share/lua/5.1
|
2019-06-03 11:48:46 +08:00
|
|
|
INST_BINDIR ?= /usr/bin
|
2019-05-31 21:06:55 +08:00
|
|
|
INSTALL ?= install
|
2019-07-05 19:01:20 +08:00
|
|
|
UNAME ?= $(shell uname)
|
2019-07-10 11:32:16 +08:00
|
|
|
OR_EXEC ?= $(shell which openresty)
|
|
|
|
LUA_JIT_DIR ?= $(shell TMP='./v_tmp' && $(OR_EXEC) -V &>$${TMP} && cat $${TMP} | grep prefix | grep -Eo 'prefix=(.*?)/nginx' | grep -Eo '/.*/' && rm $${TMP})luajit
|
2019-07-11 07:41:42 +08:00
|
|
|
LUAROCKS_VER ?= $(shell luarocks --version | grep -E -o "luarocks [0-9]+.")
|
2019-05-06 18:17:29 +08:00
|
|
|
|
2019-06-11 12:21:49 +08:00
|
|
|
|
|
|
|
.PHONY: default
|
|
|
|
default:
|
|
|
|
|
|
|
|
|
2019-06-03 11:48:46 +08:00
|
|
|
### help: Show Makefile rules.
|
2019-05-06 18:17:29 +08:00
|
|
|
.PHONY: help
|
|
|
|
help:
|
|
|
|
@echo Makefile rules:
|
|
|
|
@echo
|
|
|
|
@grep -E '^### [-A-Za-z0-9_]+:' Makefile | sed 's/###/ /'
|
|
|
|
|
|
|
|
|
2019-06-15 11:22:48 +08:00
|
|
|
### dev: Create a development ENV
|
|
|
|
.PHONY: dev
|
|
|
|
dev:
|
2019-07-05 19:01:20 +08:00
|
|
|
ifeq ($(UNAME),Darwin)
|
2019-07-26 12:50:42 +08:00
|
|
|
luarocks install --lua-dir=$(LUA_JIT_DIR) rockspec/apisix-dev-1.0-0.rockspec --tree=deps --only-deps --local
|
2019-07-11 07:41:42 +08:00
|
|
|
else ifneq ($(LUAROCKS_VER),'luarocks 3.')
|
2019-07-26 12:50:42 +08:00
|
|
|
luarocks install rockspec/apisix-dev-1.0-0.rockspec --tree=deps --only-deps --local
|
2019-07-05 19:01:20 +08:00
|
|
|
else
|
2019-07-26 12:50:42 +08:00
|
|
|
luarocks install --lua-dir=/usr/local/openresty/luajit rockspec/apisix-dev-1.0-0.rockspec --tree=deps --only-deps --local
|
2019-07-05 19:01:20 +08:00
|
|
|
endif
|
2019-06-15 11:22:48 +08:00
|
|
|
|
|
|
|
|
2019-07-11 14:41:13 +08:00
|
|
|
### check: Check Lua source code
|
2019-06-16 07:32:25 +08:00
|
|
|
.PHONY: check
|
|
|
|
check:
|
|
|
|
luacheck -q lua
|
|
|
|
./utils/lj-releng lua/*.lua lua/apisix/*.lua \
|
|
|
|
lua/apisix/admin/*.lua \
|
|
|
|
lua/apisix/core/*.lua \
|
2019-07-12 20:26:36 +08:00
|
|
|
lua/apisix/http/*.lua \
|
2019-06-16 07:32:25 +08:00
|
|
|
lua/apisix/plugins/*.lua > \
|
|
|
|
/tmp/check.log 2>&1 || (cat /tmp/check.log && exit 1)
|
|
|
|
|
|
|
|
|
2019-07-05 19:01:20 +08:00
|
|
|
### init: Initialize the runtime environment
|
|
|
|
.PHONY: init
|
|
|
|
init:
|
|
|
|
./bin/apisix init
|
|
|
|
./bin/apisix init_etcd
|
|
|
|
|
|
|
|
|
2019-06-03 11:48:46 +08:00
|
|
|
### run: Start the apisix server
|
2019-05-06 18:17:29 +08:00
|
|
|
.PHONY: run
|
|
|
|
run:
|
|
|
|
mkdir -p logs
|
2019-08-01 15:12:45 +08:00
|
|
|
mkdir -p /tmp/apisix_cores/
|
2019-07-10 11:32:16 +08:00
|
|
|
$(OR_EXEC) -p $$PWD/ -c $$PWD/conf/nginx.conf
|
2019-05-06 18:17:29 +08:00
|
|
|
|
|
|
|
|
2019-06-03 11:48:46 +08:00
|
|
|
### stop: Stop the apisix server
|
2019-05-06 18:17:29 +08:00
|
|
|
.PHONY: stop
|
|
|
|
stop:
|
2019-07-10 11:32:16 +08:00
|
|
|
$(OR_EXEC) -p $$PWD/ -c $$PWD/conf/nginx.conf -s stop
|
2019-05-06 18:17:29 +08:00
|
|
|
|
|
|
|
|
2019-06-03 11:48:46 +08:00
|
|
|
### clean: Remove generated files
|
2019-05-06 18:17:29 +08:00
|
|
|
.PHONY: clean
|
|
|
|
clean:
|
|
|
|
rm -rf logs/
|
|
|
|
|
|
|
|
|
2019-06-03 11:48:46 +08:00
|
|
|
### reload: Reload the apisix server
|
2019-05-06 18:17:29 +08:00
|
|
|
.PHONY: reload
|
|
|
|
reload:
|
2019-07-10 11:32:16 +08:00
|
|
|
$(OR_EXEC) -p $$PWD/ -c $$PWD/conf/nginx.conf -s reload
|
2019-05-31 21:06:55 +08:00
|
|
|
|
|
|
|
|
2019-06-04 10:32:14 +08:00
|
|
|
### install: Install the apisix
|
2019-05-31 21:06:55 +08:00
|
|
|
.PHONY: install
|
|
|
|
install:
|
2019-06-05 15:06:28 +08:00
|
|
|
$(INSTALL) -d /usr/local/apisix/logs/
|
2019-06-22 10:44:07 +08:00
|
|
|
$(INSTALL) -d /usr/local/apisix/conf/cert
|
2019-06-05 15:06:28 +08:00
|
|
|
$(INSTALL) conf/mime.types /usr/local/apisix/conf/mime.types
|
2019-06-04 21:16:23 +08:00
|
|
|
$(INSTALL) conf/config.yaml /usr/local/apisix/conf/config.yaml
|
2019-06-22 10:44:07 +08:00
|
|
|
$(INSTALL) conf/cert/apisix.* /usr/local/apisix/conf/cert/
|
2019-06-04 20:53:58 +08:00
|
|
|
|
2019-06-05 15:06:28 +08:00
|
|
|
$(INSTALL) -d $(INST_LUADIR)/apisix/lua/apisix/core
|
|
|
|
$(INSTALL) lua/*.lua $(INST_LUADIR)/apisix/lua/
|
|
|
|
$(INSTALL) lua/apisix/core/*.lua $(INST_LUADIR)/apisix/lua/apisix/core/
|
|
|
|
$(INSTALL) lua/apisix/*.lua $(INST_LUADIR)/apisix/lua/apisix/
|
|
|
|
|
2019-07-12 20:26:36 +08:00
|
|
|
$(INSTALL) -d $(INST_LUADIR)/apisix/lua/apisix/http
|
|
|
|
$(INSTALL) lua/apisix/http/*.lua $(INST_LUADIR)/apisix/lua/apisix/http/
|
|
|
|
|
2019-06-05 15:06:28 +08:00
|
|
|
$(INSTALL) -d $(INST_LUADIR)/apisix/lua/apisix/plugins/prometheus/
|
|
|
|
$(INSTALL) lua/apisix/plugins/prometheus/*.lua $(INST_LUADIR)/apisix/lua/apisix/plugins/prometheus/
|
|
|
|
|
|
|
|
$(INSTALL) -d $(INST_LUADIR)/apisix/lua/apisix/plugins
|
|
|
|
$(INSTALL) lua/apisix/plugins/*.lua $(INST_LUADIR)/apisix/lua/apisix/plugins/
|
2019-06-04 20:53:58 +08:00
|
|
|
|
2019-06-17 15:57:02 +08:00
|
|
|
$(INSTALL) -d $(INST_LUADIR)/apisix/lua/apisix/admin
|
|
|
|
$(INSTALL) lua/apisix/admin/*.lua $(INST_LUADIR)/apisix/lua/apisix/admin/
|
|
|
|
|
2019-06-04 10:40:45 +08:00
|
|
|
$(INSTALL) COPYRIGHT $(INST_CONFDIR)/COPYRIGHT
|
|
|
|
$(INSTALL) README.md $(INST_CONFDIR)/README.md
|
2019-06-04 10:32:14 +08:00
|
|
|
$(INSTALL) bin/apisix $(INST_BINDIR)/apisix
|
2019-06-03 16:24:38 +08:00
|
|
|
|
2019-07-15 08:46:10 +08:00
|
|
|
|
|
|
|
### test: Run the test case
|
2019-06-03 16:24:38 +08:00
|
|
|
test:
|
2019-07-10 11:32:16 +08:00
|
|
|
ifeq ($(UNAME),Darwin)
|
|
|
|
prove -I../test-nginx/lib -I./ -r -s t/
|
|
|
|
else
|
2019-06-03 16:24:38 +08:00
|
|
|
prove -I../test-nginx/lib -r -s t/
|
2019-07-10 11:32:16 +08:00
|
|
|
endif
|