This repository has been archived by the owner on Aug 26, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 111
/
Makefile
179 lines (144 loc) · 5.57 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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
##############################################################################
# Project Slardar top level Makefile for installation. Requires GNU Make.
#
# Suitable for POSIX platforms (Linux, *BSD, OSX etc.)
#
# Copyright (C) 2015 - 2016, UPYUN Inc.
##############################################################################
include util/ver.cfg
ROOTDIR= $(shell pwd)
ifeq (dev,$(firstword $(MAKECMDGOALS)))
PREFIX= $(ROOTDIR)
DEV= 1
endif
ifndef PREFIX
PREFIX= /usr/local/slardar
endif
ifeq ($(shell uname -s), Darwin)
PLAT=macosx
else
PLAT=linux
endif
ifeq ($(shell uname -m), x86_64)
export KERNEL_BITS=64
endif
export LUAJIT_LIB= $(PREFIX)/luajit/lib
export LUAJIT_INC= $(PREFIX)/luajit/include/luajit-2.1
##############################################################################
RM= rm -f
CP= cp -f
MKDIR= mkdir -p
RMDIR= rmdir 2>/dev/null
INSTALL_F= install -m 0644
UNINSTALL= $(RM)
WITH_SSL_MODULE= --with-http_ssl_module --with-stream_ssl_module --with-openssl=$(ROOTDIR)/deps/openssl-OpenSSL_$(V_OPENSSL)
##############################################################################
NGINX_DIR= deps/nginx-$(V_NGINX)
default all: cjson cmsgpack luasocket
@echo "==== Building Nginx $(V_NGINX) ===="
cd $(NGINX_DIR) && $(MAKE)
@echo "==== Successfully build Nginx $(V_NGINX) ===="
INSTALL_LIBDIR=$(PREFIX)/nginx/app/lib/
configure: deps luajit
@echo "==== Configuring Nginx $(V_NGINX) ===="
cd $(NGINX_DIR) && ./configure $(WITH_SSL_MODULE) \
--with-pcre=$(ROOTDIR)/deps/pcre-$(V_PCRE) \
--with-ld-opt="-Wl,-rpath,$(LUAJIT_LIB),-rpath,$(INSTALL_LIBDIR)" \
--with-zlib=$(ROOTDIR)/deps/zlib-$(V_ZLIB) \
--with-http_stub_status_module \
--with-stream \
--add-module=$(ROOTDIR)/deps/stream-lua-nginx-module-$(V_STREAM_LUA_NGX_MODULE) \
--add-module=$(ROOTDIR)/deps/lua-nginx-module-$(V_NGX_LUA_MODULE) \
--prefix=$(PREFIX)/nginx
@echo "==== Successfully configure Nginx $(V_NGINX) ===="
INSTALL_SRCDIR=$(PREFIX)/nginx/app/src/
INSTALL_ETCDIR=$(PREFIX)/nginx/app/etc/
INSTALL_DIRS=$(INSTALL_SRCDIR)/modules \
$(INSTALL_SRCDIR)/stream \
$(INSTALL_SRCDIR)/script \
$(INSTALL_LIBDIR)/ngx \
$(INSTALL_LIBDIR)/resty \
$(INSTALL_LIBDIR)/resty/core \
$(INSTALL_LIBDIR)/resty/checkups \
$(INSTALL_LIBDIR)/resty/store \
$(INSTALL_LIBDIR)/resty/logger \
$(INSTALL_ETCDIR)
install: install-cjson install-cmsgpack
$(MKDIR) $(INSTALL_DIRS) $(PREFIX)/nginx/conf/slardar
$(MKDIR) $(INSTALL_DIRS) $(PREFIX)/nginx/conf/stream
@echo "==== Installing Slardar $(V_SLARDAR) to $(PREFIX) ===="
cd $(NGINX_DIR) && $(MAKE) install
ifndef DEV
$(INSTALL_F) nginx/app/lib/resty/*.lua $(INSTALL_LIBDIR)/resty
$(INSTALL_F) nginx/app/lib/ngx/*.lua $(INSTALL_LIBDIR)/ngx
$(INSTALL_F) nginx/app/lib/resty/core/*.lua $(INSTALL_LIBDIR)/resty/core
$(INSTALL_F) nginx/app/lib/resty/logger/*.lua $(INSTALL_LIBDIR)/resty/logger
$(INSTALL_F) nginx/app/lib/resty/store/*.lua $(INSTALL_LIBDIR)/resty/store
$(INSTALL_F) nginx/app/lib/resty/checkups/*.lua $(INSTALL_LIBDIR)/resty/checkups
$(INSTALL_F) nginx/app/src/*.lua $(INSTALL_SRCDIR)
$(INSTALL_F) nginx/app/etc/*.lua $(INSTALL_ETCDIR)
$(INSTALL_F) nginx/app/src/modules/*.lua $(INSTALL_SRCDIR)/modules
$(INSTALL_F) nginx/app/src/stream/*.lua $(INSTALL_SRCDIR)/stream
$(INSTALL_F) nginx/conf/*.conf $(PREFIX)/nginx/conf
$(INSTALL_F) nginx/conf/slardar/*.conf $(PREFIX)/nginx/conf/slardar
$(INSTALL_F) nginx/conf/stream/*.conf $(PREFIX)/nginx/conf/stream
endif
@echo "==== Successfully installed Slardar $(V_SLARDAR) to $(PREFIX) ===="
dev: configure all install
##############################################################################
deps:
./util/deps
LUAJIT_DIR= deps/luajit2-$(V_LUAJIT)
luajit:
cd $(LUAJIT_DIR) && $(MAKE) PREFIX=$(PREFIX)/luajit && $(MAKE) install PREFIX=$(PREFIX)/luajit
LUA_CJSON_DIR= deps/lua-cjson-$(V_LUA_CJSON)
cjson:
@echo "==== Building Lua CJSON $(V_LUA_CJSON) ===="
ifeq ($(shell uname -s), Darwin)
cd $(LUA_CJSON_DIR) && $(MAKE) LUA_INCLUDE_DIR=$(LUAJIT_INC) "CJSON_LDFLAGS+=-undefined dynamic_lookup"
else
cd $(LUA_CJSON_DIR) && $(MAKE) LUA_INCLUDE_DIR=$(LUAJIT_INC)
endif
@echo "==== Successfully build Lua CJSON $(V_LUA_CJSON) ===="
install-cjson:
$(MKDIR) $(INSTALL_LIBDIR)
$(INSTALL_F) $(LUA_CJSON_DIR)/*.so $(INSTALL_LIBDIR)
LUA_CMSGPACK_DIR= deps/lua-cmsgpack-$(V_CMSGPACK)
cmsgpack:
@echo "==== Building Lua cmsgpack ===="
ifeq ($(shell uname -s), Darwin)
cd $(LUA_CMSGPACK_DIR) && $(MAKE) LUA_INCLUDE_DIR=$(LUAJIT_INC) "CMSGPACK_LDFLAGS+=-undefined dynamic_lookup"
else
cd $(LUA_CMSGPACK_DIR) && $(MAKE) LUA_INCLUDE_DIR=$(LUAJIT_INC)
endif
@echo "==== Successfully build Lua cmsgpack ===="
install-cmsgpack:
$(MKDIR) $(INSTALL_LIBDIR)
$(INSTALL_F) $(LUA_CMSGPACK_DIR)/*.so $(INSTALL_LIBDIR)
LUASOCKET_DIR = deps/luasocket-$(V_LUASOCKET)
luasocket: luajit
cd $(LUASOCKET_DIR);make LUAINC=$(LUAJIT_INC) PLAT=$(PLAT)
cd $(LUASOCKET_DIR);make LUAINC=$(LUAJIT_INC) PLAT=$(PLAT) prefix=$(PREFIX)/luajit install
clean:
cd $(LUAJIT_DIR) && $(MAKE) clean
cd $(NGINX_DIR) && $(MAKE) clean
cd $(LUA_CJSON_DIR) && $(MAKE) clean
cd $(LUA_CMSGPACK_DIR) && $(MAKE) clean
@rm -rf $(ROOTDIR)/luajit
@rm -rf $(ROOTDIR)/nginx/app/lib/*.so
@rm -rf $(ROOTDIR)/nginx/sbin/nginx
.PHONY: deps luajit cjson cmsgpack clean luasocket
##############################################################################
start:
./nginx/sbin/nginx
@echo "NGINX start"
stop:
-kill -QUIT `cat ./nginx/logs/nginx.pid`
@echo "NGINX stop"
reload:
-kill -HUP `cat ./nginx/logs/nginx.pid`
@echo "NGINX reload"
test:
util/lua-releng
python ./util/ytest
##############################################################################