2019-10-31 09:27:28 +08:00
|
|
|
#
|
|
|
|
# Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
# contributor license agreements. See the NOTICE file distributed with
|
|
|
|
# this work for additional information regarding copyright ownership.
|
|
|
|
# The ASF licenses this file to You under the Apache License, Version 2.0
|
|
|
|
# (the "License"); you may not use this file except in compliance with
|
|
|
|
# the License. You may obtain a copy of the License at
|
|
|
|
#
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
#
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
# See the License for the specific language governing permissions and
|
|
|
|
# limitations under the License.
|
|
|
|
#
|
|
|
|
|
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)
|
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-11-25 13:09:32 +08:00
|
|
|
ifeq ($(OR_EXEC), )
|
2019-11-26 21:24:45 +08:00
|
|
|
ifeq ("$(wildcard /usr/local/openresty-debug/bin/openresty)", "")
|
|
|
|
@echo "ERROR: OpenResty not found. You have to install OpenResty and add the binary file to PATH before install Apache APISIX."
|
2019-11-25 13:09:32 +08:00
|
|
|
exit 1
|
|
|
|
endif
|
2019-11-26 21:24:45 +08:00
|
|
|
endif
|
2019-06-11 12:21:49 +08:00
|
|
|
|
2020-03-17 22:24:03 +08:00
|
|
|
LUAJIT_DIR ?= $(shell ${OR_EXEC} -V 2>&1 | grep prefix | grep -Eo 'prefix=(.*)/nginx\s+--' | grep -Eo '/.*/')luajit
|
2019-06-11 12:21:49 +08:00
|
|
|
|
2020-07-29 19:23:49 +08:00
|
|
|
### help: Show Makefile rules
|
2019-05-06 18:17:29 +08:00
|
|
|
.PHONY: help
|
2019-11-26 21:24:45 +08:00
|
|
|
help: default
|
2019-05-06 18:17:29 +08:00
|
|
|
@echo Makefile rules:
|
|
|
|
@echo
|
|
|
|
@grep -E '^### [-A-Za-z0-9_]+:' Makefile | sed 's/###/ /'
|
|
|
|
|
|
|
|
|
2019-11-21 09:23:16 +08:00
|
|
|
### deps: Installation dependencies
|
2019-11-12 16:38:23 +08:00
|
|
|
.PHONY: deps
|
2019-11-25 13:09:32 +08:00
|
|
|
deps: default
|
2020-03-10 15:16:14 +08:00
|
|
|
ifeq ($(LUAROCKS_VER),luarocks 3.)
|
2020-02-27 08:45:34 +08:00
|
|
|
luarocks install --lua-dir=$(LUAJIT_DIR) rockspec/apisix-master-0.rockspec --tree=deps --only-deps --local
|
2019-07-05 19:01:20 +08:00
|
|
|
else
|
2020-02-27 08:45:34 +08:00
|
|
|
luarocks install rockspec/apisix-master-0.rockspec --tree=deps --only-deps --local
|
2019-07-05 19:01:20 +08:00
|
|
|
endif
|
2019-11-12 16:38:23 +08:00
|
|
|
|
|
|
|
|
2020-01-07 20:17:47 +08:00
|
|
|
### utils: Installation tools
|
2019-11-12 16:38:23 +08:00
|
|
|
.PHONY: utils
|
|
|
|
utils:
|
2019-11-21 09:23:16 +08:00
|
|
|
ifeq ("$(wildcard utils/lj-releng)", "")
|
2020-02-18 15:54:30 +08:00
|
|
|
wget -O utils/lj-releng https://raw.githubusercontent.com/iresty/openresty-devel-utils/master/lj-releng
|
2019-09-23 05:54:37 +08:00
|
|
|
chmod a+x utils/lj-releng
|
2019-09-23 11:14:49 +08:00
|
|
|
endif
|
2019-06-15 11:22:48 +08:00
|
|
|
|
|
|
|
|
2019-11-21 09:23:16 +08:00
|
|
|
### lint: Lint Lua source code
|
|
|
|
.PHONY: lint
|
|
|
|
lint: utils
|
2020-02-18 15:54:30 +08:00
|
|
|
./utils/check-lua-code-style.sh
|
2019-06-16 07:32:25 +08:00
|
|
|
|
|
|
|
|
2019-11-21 09:23:16 +08:00
|
|
|
### init: Initialize the runtime environment
|
2019-07-05 19:01:20 +08:00
|
|
|
.PHONY: init
|
2019-11-25 13:09:32 +08:00
|
|
|
init: default
|
2019-07-05 19:01:20 +08:00
|
|
|
./bin/apisix init
|
|
|
|
./bin/apisix init_etcd
|
|
|
|
|
|
|
|
|
2019-11-21 09:23:16 +08:00
|
|
|
### run: Start the apisix server
|
2019-05-06 18:17:29 +08:00
|
|
|
.PHONY: run
|
2019-11-25 13:09:32 +08:00
|
|
|
run: default
|
2020-06-11 13:00:04 +08:00
|
|
|
ifeq ("$(wildcard logs/nginx.pid)", "")
|
2019-05-06 18:17:29 +08:00
|
|
|
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
|
2020-06-11 13:00:04 +08:00
|
|
|
else
|
|
|
|
@echo "APISIX is running..."
|
|
|
|
endif
|
2019-05-06 18:17:29 +08:00
|
|
|
|
|
|
|
|
2019-11-21 09:23:16 +08:00
|
|
|
### stop: Stop the apisix server
|
2019-05-06 18:17:29 +08:00
|
|
|
.PHONY: stop
|
2019-11-25 13:09:32 +08:00
|
|
|
stop: default
|
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
|
|
|
|
|
|
|
|
2020-02-09 20:43:30 +08:00
|
|
|
### verify: Verify the configuration of apisix server
|
|
|
|
.PHONY: verify
|
|
|
|
verify: default
|
|
|
|
$(OR_EXEC) -p $$PWD/ -c $$PWD/conf/nginx.conf -t
|
|
|
|
|
|
|
|
|
2019-11-21 09:23:16 +08:00
|
|
|
### clean: Remove generated files
|
2019-05-06 18:17:29 +08:00
|
|
|
.PHONY: clean
|
|
|
|
clean:
|
|
|
|
rm -rf logs/
|
|
|
|
|
|
|
|
|
2019-11-21 09:23:16 +08:00
|
|
|
### reload: Reload the apisix server
|
2019-05-06 18:17:29 +08:00
|
|
|
.PHONY: reload
|
2019-11-25 13:09:32 +08:00
|
|
|
reload: default
|
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
|
|
|
|
|
|
|
|
2020-07-29 19:23:49 +08:00
|
|
|
### install: Install the apisix (only for luarocks)
|
2019-05-31 21:06:55 +08:00
|
|
|
.PHONY: install
|
2020-05-26 21:26:52 +08:00
|
|
|
install: default
|
2020-04-20 09:09:14 +08:00
|
|
|
$(INSTALL) -d /usr/local/apisix/
|
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
|
2020-08-18 20:18:55 +08:00
|
|
|
$(INSTALL) conf/config-default.yaml /usr/local/apisix/conf/config-default.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
|
|
|
|
2020-03-31 23:23:29 +08:00
|
|
|
$(INSTALL) -d $(INST_LUADIR)/apisix
|
|
|
|
$(INSTALL) apisix/*.lua $(INST_LUADIR)/apisix/
|
2019-10-08 16:46:53 +08:00
|
|
|
|
2020-03-31 23:23:29 +08:00
|
|
|
$(INSTALL) -d $(INST_LUADIR)/apisix/admin
|
|
|
|
$(INSTALL) apisix/admin/*.lua $(INST_LUADIR)/apisix/admin/
|
2019-06-05 15:06:28 +08:00
|
|
|
|
2020-06-19 12:46:20 +08:00
|
|
|
$(INSTALL) -d $(INST_LUADIR)/apisix/balancer
|
|
|
|
$(INSTALL) apisix/balancer/*.lua $(INST_LUADIR)/apisix/balancer/
|
|
|
|
|
2020-03-31 23:23:29 +08:00
|
|
|
$(INSTALL) -d $(INST_LUADIR)/apisix/core
|
|
|
|
$(INSTALL) apisix/core/*.lua $(INST_LUADIR)/apisix/core/
|
2019-10-08 16:46:53 +08:00
|
|
|
|
2020-03-31 23:23:29 +08:00
|
|
|
$(INSTALL) -d $(INST_LUADIR)/apisix/http
|
|
|
|
$(INSTALL) apisix/http/*.lua $(INST_LUADIR)/apisix/http/
|
2019-10-08 16:46:53 +08:00
|
|
|
|
2020-03-31 23:23:29 +08:00
|
|
|
$(INSTALL) -d $(INST_LUADIR)/apisix/http/router
|
|
|
|
$(INSTALL) apisix/http/router/*.lua $(INST_LUADIR)/apisix/http/router/
|
2019-07-12 20:26:36 +08:00
|
|
|
|
2020-05-14 23:20:44 +08:00
|
|
|
$(INSTALL) -d $(INST_LUADIR)/apisix/discovery
|
|
|
|
$(INSTALL) apisix/discovery/*.lua $(INST_LUADIR)/apisix/discovery/
|
|
|
|
|
2020-03-31 23:23:29 +08:00
|
|
|
$(INSTALL) -d $(INST_LUADIR)/apisix/plugins
|
|
|
|
$(INSTALL) apisix/plugins/*.lua $(INST_LUADIR)/apisix/plugins/
|
2019-09-06 15:51:50 +08:00
|
|
|
|
2020-03-31 23:23:29 +08:00
|
|
|
$(INSTALL) -d $(INST_LUADIR)/apisix/plugins/grpc-transcode
|
|
|
|
$(INSTALL) apisix/plugins/grpc-transcode/*.lua $(INST_LUADIR)/apisix/plugins/grpc-transcode/
|
2019-08-06 18:06:42 +08:00
|
|
|
|
2020-03-31 23:23:29 +08:00
|
|
|
$(INSTALL) -d $(INST_LUADIR)/apisix/plugins/limit-count
|
|
|
|
$(INSTALL) apisix/plugins/limit-count/*.lua $(INST_LUADIR)/apisix/plugins/limit-count/
|
2019-08-22 14:40:56 +08:00
|
|
|
|
2020-03-31 23:23:29 +08:00
|
|
|
$(INSTALL) -d $(INST_LUADIR)/apisix/plugins/prometheus
|
|
|
|
$(INSTALL) apisix/plugins/prometheus/*.lua $(INST_LUADIR)/apisix/plugins/prometheus/
|
2019-10-08 13:15:48 +08:00
|
|
|
|
2020-03-31 23:23:29 +08:00
|
|
|
$(INSTALL) -d $(INST_LUADIR)/apisix/plugins/zipkin
|
|
|
|
$(INSTALL) apisix/plugins/zipkin/*.lua $(INST_LUADIR)/apisix/plugins/zipkin/
|
2019-06-04 20:53:58 +08:00
|
|
|
|
2020-05-27 17:55:47 +08:00
|
|
|
$(INSTALL) -d $(INST_LUADIR)/apisix/plugins/skywalking
|
|
|
|
$(INSTALL) apisix/plugins/skywalking/*.lua $(INST_LUADIR)/apisix/plugins/skywalking/
|
|
|
|
|
2020-03-31 23:23:29 +08:00
|
|
|
$(INSTALL) -d $(INST_LUADIR)/apisix/stream/plugins
|
|
|
|
$(INSTALL) apisix/stream/plugins/*.lua $(INST_LUADIR)/apisix/stream/plugins/
|
2019-10-08 16:46:53 +08:00
|
|
|
|
2020-03-31 23:23:29 +08:00
|
|
|
$(INSTALL) -d $(INST_LUADIR)/apisix/stream/router
|
|
|
|
$(INSTALL) apisix/stream/router/*.lua $(INST_LUADIR)/apisix/stream/router/
|
2019-10-08 16:46:53 +08:00
|
|
|
|
2020-03-31 23:23:29 +08:00
|
|
|
$(INSTALL) -d $(INST_LUADIR)/apisix/utils
|
|
|
|
$(INSTALL) apisix/utils/*.lua $(INST_LUADIR)/apisix/utils/
|
2020-03-27 07:34:08 +08:00
|
|
|
|
2019-06-04 10:40:45 +08:00
|
|
|
$(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
|
|
|
|
2019-11-21 09:23:16 +08:00
|
|
|
### test: Run the test case
|
2019-06-03 16:24:38 +08:00
|
|
|
test:
|
2019-07-10 11:32:16 +08:00
|
|
|
prove -I../test-nginx/lib -I./ -r -s t/
|
2019-11-21 09:23:16 +08:00
|
|
|
|
|
|
|
### license-check: Check Lua source code for Apache License
|
|
|
|
.PHONY: license-check
|
|
|
|
license-check:
|
|
|
|
ifeq ("$(wildcard .travis/openwhisk-utilities/scancode/scanCode.py)", "")
|
|
|
|
git clone https://github.com/apache/openwhisk-utilities.git .travis/openwhisk-utilities
|
|
|
|
cp .travis/ASF* .travis/openwhisk-utilities/scancode/
|
|
|
|
endif
|
|
|
|
.travis/openwhisk-utilities/scancode/scanCode.py --config .travis/ASF-Release.cfg ./
|
|
|
|
|