Skip to content

Commit

Permalink
fix: fail to run make deps on macOS (#3718)
Browse files Browse the repository at this point in the history
  • Loading branch information
nic-chen authored Mar 8, 2021
1 parent 39c65e4 commit fc9fcff
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 9 deletions.
21 changes: 16 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ INST_BINDIR ?= /usr/bin
INSTALL ?= install
UNAME ?= $(shell uname)
OR_EXEC ?= $(shell which openresty || which nginx)
LUAROCKS ?= luarocks
LUAROCKS_VER ?= $(shell luarocks --version | grep -E -o "luarocks [0-9]+.")
OR_PREFIX ?= $(shell $(OR_EXEC) -V 2>&1 | grep -Eo 'prefix=(.*)/nginx\s+' | grep -Eo '/.*/')
OPENSSL_PREFIX ?= $(addprefix $(OR_PREFIX), openssl)
Expand All @@ -31,6 +32,16 @@ ifeq ($(shell test -d $(addprefix $(OR_PREFIX), openssl111) && echo -n yes), yes
OPENSSL_PREFIX=$(addprefix $(OR_PREFIX), openssl111)
endif

ifeq ($(UNAME), Darwin)
LUAROCKS=luarocks --lua-dir=/usr/local/opt/lua@5.1
ifeq ($(shell test -d /usr/local/opt/openresty-openssl && echo yes), yes)
OPENSSL_PREFIX=/usr/local/opt/openresty-openssl
endif
ifeq ($(shell test -d /usr/local/opt/openresty-openssl111 && echo yes), yes)
OPENSSL_PREFIX=/usr/local/opt/openresty-openssl111
endif
endif

SHELL := /bin/bash -o pipefail

VERSION ?= latest
Expand Down Expand Up @@ -63,13 +74,13 @@ deps: default
ifeq ($(LUAROCKS_VER),luarocks 3.)
mkdir -p ~/.luarocks
ifeq ($(shell whoami),root)
luarocks config variables.OPENSSL_LIBDIR $(addprefix $(OPENSSL_PREFIX), /lib)
luarocks config variables.OPENSSL_INCDIR $(addprefix $(OPENSSL_PREFIX), /include)
$(LUAROCKS) config variables.OPENSSL_LIBDIR $(addprefix $(OPENSSL_PREFIX), /lib)
$(LUAROCKS) config variables.OPENSSL_INCDIR $(addprefix $(OPENSSL_PREFIX), /include)
else
luarocks config --local variables.OPENSSL_LIBDIR $(addprefix $(OPENSSL_PREFIX), /lib)
luarocks config --local variables.OPENSSL_INCDIR $(addprefix $(OPENSSL_PREFIX), /include)
$(LUAROCKS) config --local variables.OPENSSL_LIBDIR $(addprefix $(OPENSSL_PREFIX), /lib)
$(LUAROCKS) config --local variables.OPENSSL_INCDIR $(addprefix $(OPENSSL_PREFIX), /include)
endif
luarocks install rockspec/apisix-master-0.rockspec --tree=deps --only-deps --local
$(LUAROCKS) install rockspec/apisix-master-0.rockspec --tree=deps --only-deps --local
else
@echo "WARN: You're not using LuaRocks 3.x, please add the following items to your LuaRocks config file:"
@echo "variables = {"
Expand Down
4 changes: 2 additions & 2 deletions docs/en/latest/install-dependencies.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,10 @@ nohup etcd &

```shell
# install OpenResty, etcd and some compilation tools
brew install openresty/brew/openresty etcd luarocks curl git
brew install openresty/brew/openresty luarocks lua@5.1 etcd curl git

# start etcd server
etcd &
brew services start etcd

# enable TLS for etcd server
etcd --cert-file=/path/to/cert --key-file=/path/to/pkey --advertise-client-urls https://127.0.0.1:2379
Expand Down
4 changes: 2 additions & 2 deletions docs/zh/latest/install-dependencies.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,10 @@ nohup etcd &

```shell
# 安装 OpenResty, etcd 和 编译工具
brew install openresty/brew/openresty etcd luarocks curl git
brew install openresty/brew/openresty luarocks lua@5.1 etcd curl git

# 开启 etcd server
etcd &
brew services start etcd

# 为 etcd 服务启用 TLS
etcd --cert-file=/path/to/cert --key-file=/path/to/pkey --advertise-client-urls https://127.0.0.1:2379
Expand Down

0 comments on commit fc9fcff

Please sign in to comment.