forked from openresty/stream-lua-nginx-module
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config
455 lines (385 loc) · 15.8 KB
/
config
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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
ngx_lua_opt_I=
ngx_lua_opt_L=
luajit_ld_opt=
ngx_feature_name=
ngx_feature_run=no
ngx_feature_incs=
ngx_feature_test=
if [ -n "$LUAJIT_INC" -o -n "$LUAJIT_LIB" ]; then
# explicitly set LuaJIT paths
if [ "$NGX_PLATFORM" = win32 ]; then
ngx_feature="LuaJIT library in $LUAJIT_LIB and $LUAJIT_INC (win32)"
ngx_feature_path="$LUAJIT_INC"
ngx_lua_opt_I="-I$LUAJIT_INC"
ngx_lua_opt_L="-L$LUAJIT_LIB"
# ensure that -I$LUAJIT_INC and -L$LUAJIT_LIB come first.
SAVED_CC_TEST_FLAGS="$CC_TEST_FLAGS"
CC_TEST_FLAGS="$ngx_lua_opt_I $CC_TEST_FLAGS"
SAVED_NGX_TEST_LD_OPT="$NGX_TEST_LD_OPT"
NGX_TEST_LD_OPT="$ngx_lua_opt_L $NGX_TEST_LD_OPT"
# LuaJIT's win32 build uses the library file name lua51.dll
ngx_feature_libs="$ngx_lua_opt_L -llua51"
. auto/feature
# clean up
CC_TEST_FLAGS="$SAVED_CC_TEST_FLAGS"
NGX_TEST_LD_OPT="$SAVED_NGX_TEST_LD_OPT"
else
# attempt to link with -ldl, static linking on Linux requires it.
ngx_feature="LuaJIT library in $LUAJIT_LIB and $LUAJIT_INC (specified by the LUAJIT_LIB and LUAJIT_INC env, with -ldl)"
ngx_feature_path="$LUAJIT_INC"
ngx_lua_opt_I="-I$LUAJIT_INC"
ngx_lua_opt_L="-L$LUAJIT_LIB"
luajit_ld_opt="-lm -ldl"
# ensure that -I$LUAJIT_INC and -L$LUAJIT_LIB come first
SAVED_CC_TEST_FLAGS="$CC_TEST_FLAGS"
CC_TEST_FLAGS="$ngx_lua_opt_I $CC_TEST_FLAGS"
SAVED_NGX_TEST_LD_OPT="$NGX_TEST_LD_OPT"
NGX_TEST_LD_OPT="$ngx_lua_opt_L $NGX_TEST_LD_OPT"
if [ $NGX_RPATH = YES ]; then
ngx_feature_libs="-R$LUAJIT_LIB $ngx_lua_opt_L -lluajit-5.1 $luajit_ld_opt"
else
ngx_feature_libs="$ngx_lua_opt_L -lluajit-5.1 $luajit_ld_opt"
fi
. auto/feature
# clean up
CC_TEST_FLAGS="$SAVED_CC_TEST_FLAGS"
NGX_TEST_LD_OPT="$SAVED_NGX_TEST_LD_OPT"
if [ $ngx_found = no ]; then
# retry without -ldl
ngx_feature="LuaJIT library in $LUAJIT_LIB and $LUAJIT_INC (specified by the LUAJIT_LIB and LUAJIT_INC env)"
ngx_feature_path="$LUAJIT_INC"
ngx_lua_opt_I="-I$LUAJIT_INC"
ngx_lua_opt_L="-L$LUAJIT_LIB"
luajit_ld_opt="-lm"
# ensure that -I$LUAJIT_INC and -L$LUAJIT_LIB come first
SAVED_CC_TEST_FLAGS="$CC_TEST_FLAGS"
CC_TEST_FLAGS="$ngx_lua_opt_I $CC_TEST_FLAGS"
SAVED_NGX_TEST_LD_OPT="$NGX_TEST_LD_OPT"
NGX_TEST_LD_OPT="$ngx_lua_opt_L $NGX_TEST_LD_OPT"
if [ $NGX_RPATH = YES ]; then
ngx_feature_libs="-R$LUAJIT_LIB $ngx_lua_opt_L -lluajit-5.1 $luajit_ld_opt"
else
ngx_feature_libs="$ngx_lua_opt_L -lluajit-5.1 $luajit_ld_opt"
fi
. auto/feature
# clean up
CC_TEST_FLAGS="$SAVED_CC_TEST_FLAGS"
NGX_TEST_LD_OPT="$SAVED_NGX_TEST_LD_OPT"
fi
fi
if [ $ngx_found = no ]; then
cat << END
$0: error: ngx_stream_lua_module requires the LuaJIT library, but it could not be found where specified (LUAJIT_LIB=$LUAJIT_LIB, LUAJIT_INC=$LUAJIT_INC).
END
exit 1
fi
case "$NGX_PLATFORM" in
Darwin:*)
case "$NGX_MACHINE" in
amd64 | x86_64 | i386)
echo "adding extra linking options needed by LuaJIT on $NGX_MACHINE"
luajit_ld_opt="$luajit_ld_opt -pagezero_size 10000 -image_base 100000000"
ngx_feature_libs="$ngx_feature_libs -pagezero_size 10000 -image_base 100000000"
;;
*)
;;
esac
;;
*)
;;
esac
else
# auto-discovery
if [ $ngx_found = no ]; then
# FreeBSD with luajit-2.0 from ports collection
ngx_feature="LuaJIT library in /usr/local/"
ngx_feature_path="/usr/local/include/luajit-2.0"
luajit_ld_opt="-lm"
LUAJIT_LIB="/usr/local/lib"
if [ $NGX_RPATH = YES ]; then
ngx_feature_libs="-R/usr/local/lib -L/usr/local/lib -lluajit-5.1 -lm"
else
ngx_feature_libs="-L/usr/local/lib -lluajit-5.1 -lm"
fi
. auto/feature
fi
if [ $ngx_found = no ]; then
# Gentoo with LuaJIT-2.0, try with -ldl
ngx_feature="LuaJIT library in /usr/"
ngx_feature_path="/usr/include/luajit-2.0"
luajit_ld_opt="-lm -ldl"
LUAJIT_LIB="/usr/lib"
if [ $NGX_RPATH = YES ]; then
ngx_feature_libs="-R/usr/lib -L/usr/lib -lm -lluajit-5.1 -ldl"
else
ngx_feature_libs="-L/usr/lib -lm -lluajit-5.1 -ldl"
fi
. auto/feature
fi
if [ $ngx_found = no ]; then
# Gentoo with LuaJIT 2.0
ngx_feature="LuaJIT library in /usr/"
ngx_feature_path="/usr/include/luajit-2.0"
luajit_ld_opt="-lm"
LUAJIT_LIB="/usr/lib"
if [ $NGX_RPATH = YES ]; then
ngx_feature_libs="-R/usr/lib -L/usr/lib -lm -lluajit-5.1"
else
ngx_feature_libs="-L/usr/lib -lm -lluajit-5.1"
fi
. auto/feature
fi
fi
ngx_module_incs=
ngx_module_libs=
if [ $ngx_found = yes ]; then
# this is a hack to persuade nginx's build system to favor
# the paths set by our user environment
CFLAGS="$ngx_lua_opt_I $CFLAGS"
NGX_LD_OPT="$ngx_lua_opt_L $NGX_LD_OPT"
ngx_module_incs="$ngx_module_incs $ngx_feature_path"
ngx_module_libs="$ngx_module_libs $ngx_feature_libs"
else
cat << END
$0: error: ngx_stream_lua_module requires the LuaJIT library.
END
exit 1
fi
# ----------------------------------------
ngx_feature="LuaJIT 2.x"
ngx_feature_run=no
ngx_feature_incs="#include <luajit.h>"
ngx_feature_test="#if !defined(LUAJIT_VERSION_NUM) || LUAJIT_VERSION_NUM < 20000
# error unsupported LuaJIT version
#endif
"
. auto/feature
if [ $ngx_found = no ]; then
cat << END
$0: error: unsupported LuaJIT version; ngx_stream_lua_module requires LuaJIT 2.x.
END
exit 1
fi
# ----------------------------------------
ngx_feature="Lua language 5.1"
ngx_feature_run=no
ngx_feature_incs="#include <lua.h>"
ngx_feature_test="#if !defined(LUA_VERSION_NUM) || LUA_VERSION_NUM != 501
# error unsupported Lua language version
#endif
"
. auto/feature
if [ $ngx_found = no ]; then
cat << END
$0: error: unsupported Lua language version; ngx_stream_lua_module requires Lua 5.1.
END
exit 1
fi
# ----------------------------------------
ngx_feature="LuaJIT has FFI"
ngx_feature_libs="$ngx_module_libs"
ngx_feature_run=no
ngx_feature_incs="#include <lualib.h>
#include <lauxlib.h>
#include <assert.h>
"
ngx_feature_test="lua_State *L = luaL_newstate();
assert(L != NULL);
luaopen_ffi(L);
"
. auto/feature
if [ $ngx_found = no ]; then
cat << END
$0: error: unsupported LuaJIT build; ngx_stream_lua_module requires LuaJIT with FFI enabled.
END
exit 1
fi
# ----------------------------------------
ngx_addon_name=ngx_stream_lua_module
STREAM_LUA_SRCS=" \
$ngx_addon_dir/src/ngx_stream_lua_api.c \
$ngx_addon_dir/src/ngx_stream_lua_request.c \
$ngx_addon_dir/src/ngx_stream_lua_module.c \
$ngx_addon_dir/src/ngx_stream_lua_directive.c \
$ngx_addon_dir/src/ngx_stream_lua_lex.c \
$ngx_addon_dir/src/ngx_stream_lua_contentby.c \
$ngx_addon_dir/src/ngx_stream_lua_util.c \
$ngx_addon_dir/src/ngx_stream_lua_cache.c \
$ngx_addon_dir/src/ngx_stream_lua_clfactory.c \
$ngx_addon_dir/src/ngx_stream_lua_exception.c \
$ngx_addon_dir/src/ngx_stream_lua_pcrefix.c \
$ngx_addon_dir/src/ngx_stream_lua_uthread.c \
$ngx_addon_dir/src/ngx_stream_lua_coroutine.c \
$ngx_addon_dir/src/ngx_stream_lua_output.c \
$ngx_addon_dir/src/ngx_stream_lua_consts.c \
$ngx_addon_dir/src/ngx_stream_lua_log.c \
$ngx_addon_dir/src/ngx_stream_lua_time.c \
$ngx_addon_dir/src/ngx_stream_lua_string.c \
$ngx_addon_dir/src/ngx_stream_lua_control.c \
$ngx_addon_dir/src/ngx_stream_lua_sleep.c \
$ngx_addon_dir/src/ngx_stream_lua_phase.c \
$ngx_addon_dir/src/ngx_stream_lua_ctx.c \
$ngx_addon_dir/src/ngx_stream_lua_regex.c \
$ngx_addon_dir/src/ngx_stream_lua_script.c \
$ngx_addon_dir/src/ngx_stream_lua_shdict.c \
$ngx_addon_dir/src/ngx_stream_lua_variable.c \
$ngx_addon_dir/src/ngx_stream_lua_timer.c \
$ngx_addon_dir/src/ngx_stream_lua_config.c \
$ngx_addon_dir/src/ngx_stream_lua_worker.c \
$ngx_addon_dir/src/ngx_stream_lua_misc.c \
$ngx_addon_dir/src/ngx_stream_lua_initby.c \
$ngx_addon_dir/src/ngx_stream_lua_initworkerby.c \
$ngx_addon_dir/src/ngx_stream_lua_socket_tcp.c \
$ngx_addon_dir/src/ngx_stream_lua_socket_udp.c \
$ngx_addon_dir/src/ngx_stream_lua_args.c \
$ngx_addon_dir/src/ngx_stream_lua_ssl.c \
$ngx_addon_dir/src/ngx_stream_lua_balancer.c \
$ngx_addon_dir/src/ngx_stream_lua_logby.c \
$ngx_addon_dir/src/ngx_stream_lua_prereadby.c \
$ngx_addon_dir/src/ngx_stream_lua_semaphore.c \
$ngx_addon_dir/src/ngx_stream_lua_ssl_client_helloby.c \
$ngx_addon_dir/src/ngx_stream_lua_ssl_certby.c \
$ngx_addon_dir/src/ngx_stream_lua_log_ringbuf.c \
$ngx_addon_dir/src/ngx_stream_lua_input_filters.c \
"
STREAM_LUA_DEPS=" \
$ngx_addon_dir/src/ddebug.h \
$ngx_addon_dir/src/ngx_stream_lua_autoconf.h \
$ngx_addon_dir/src/api/ngx_stream_lua_api.h \
$ngx_addon_dir/src/ngx_stream_lua_request.h \
$ngx_addon_dir/src/ngx_stream_lua_common.h \
$ngx_addon_dir/src/ngx_stream_lua_lex.h \
$ngx_addon_dir/src/ngx_stream_lua_contentby.h \
$ngx_addon_dir/src/ngx_stream_lua_util.h \
$ngx_addon_dir/src/ngx_stream_lua_cache.h \
$ngx_addon_dir/src/ngx_stream_lua_clfactory.h \
$ngx_addon_dir/src/ngx_stream_lua_pcrefix.h \
$ngx_addon_dir/src/ngx_stream_lua_uthread.h \
$ngx_addon_dir/src/ngx_stream_lua_coroutine.h \
$ngx_addon_dir/src/ngx_stream_lua_output.h \
$ngx_addon_dir/src/ngx_stream_lua_consts.h \
$ngx_addon_dir/src/ngx_stream_lua_log.h \
$ngx_addon_dir/src/ngx_stream_lua_string.h \
$ngx_addon_dir/src/ngx_stream_lua_control.h \
$ngx_addon_dir/src/ngx_stream_lua_sleep.h \
$ngx_addon_dir/src/ngx_stream_lua_phase.h \
$ngx_addon_dir/src/ngx_stream_lua_ctx.h \
$ngx_addon_dir/src/ngx_stream_lua_script.h \
$ngx_addon_dir/src/ngx_stream_lua_shdict.h \
$ngx_addon_dir/src/ngx_stream_lua_timer.h \
$ngx_addon_dir/src/ngx_stream_lua_config.h \
$ngx_addon_dir/src/api/ngx_stream_lua_api.h \
$ngx_addon_dir/src/ngx_stream_lua_misc.h \
$ngx_addon_dir/src/ngx_stream_lua_initby.h \
$ngx_addon_dir/src/ngx_stream_lua_initworkerby.h \
$ngx_addon_dir/src/ngx_stream_lua_socket_tcp.h \
$ngx_addon_dir/src/ngx_stream_lua_socket_udp.h \
$ngx_addon_dir/src/ngx_stream_lua_args.h \
$ngx_addon_dir/src/ngx_stream_lua_ssl.h \
$ngx_addon_dir/src/ngx_stream_lua_balancer.h \
$ngx_addon_dir/src/ngx_stream_lua_logby.h \
$ngx_addon_dir/src/ngx_stream_lua_prereadby.h \
$ngx_addon_dir/src/ngx_stream_lua_semaphore.h \
$ngx_addon_dir/src/ngx_stream_lua_ssl_client_helloby.h \
$ngx_addon_dir/src/ngx_stream_lua_ssl_certby.h \
$ngx_addon_dir/src/ngx_stream_lua_log_ringbuf.h \
$ngx_addon_dir/src/ngx_stream_lua_input_filters.h \
"
# ----------------------------------------
ngx_feature="export symbols by default (-E)"
ngx_feature_libs="-Wl,-E"
ngx_feature_name=
ngx_feature_run=no
ngx_feature_incs="#include <stdio.h>"
ngx_feature_path=
ngx_feature_test='printf("hello");'
. auto/feature
if [ $ngx_found = yes ]; then
CORE_LIBS="-Wl,-E $CORE_LIBS"
fi
# ----------------------------------------
# for Cygwin
ngx_feature="export symbols by default (--export-all-symbols)"
ngx_feature_libs="-Wl,--export-all-symbols"
ngx_feature_name=
ngx_feature_run=no
ngx_feature_incs="#include <stdio.h>"
ngx_feature_path=
ngx_feature_test='printf("hello");'
. auto/feature
if [ $ngx_found = yes ]; then
CORE_LIBS="-Wl,--export-all-symbols $CORE_LIBS"
fi
# ----------------------------------------
ngx_feature="SO_PASSCRED"
ngx_feature_libs=
ngx_feature_name="NGX_STREAM_LUA_HAVE_SO_PASSCRED"
ngx_feature_run=no
ngx_feature_incs="#include <sys/types.h>
#include <sys/socket.h>"
ngx_feature_path=
ngx_feature_test='setsockopt(1, SOL_SOCKET, SO_PASSCRED, NULL, 0);'
. auto/feature
# ----------------------------------------
ngx_feature="SA_RESTART"
ngx_feature_libs=
ngx_feature_name="NGX_STREAM_LUA_HAVE_SA_RESTART"
ngx_feature_run=no
ngx_feature_incs="#include <signal.h>"
ngx_feature_path=
ngx_feature_test='struct sigaction act;
act.sa_flags |= SA_RESTART;'
. auto/feature
# ----------------------------------------
if [ -n "$ngx_module_link" ]; then
ngx_module_type=STREAM
ngx_module_name=$ngx_addon_name
ngx_module_deps="$STREAM_LUA_DEPS"
ngx_module_srcs="$STREAM_LUA_SRCS"
. auto/module
else
STREAM_MODULES="$STREAM_MODULES $ngx_addon_name"
NGX_ADDON_SRCS="$NGX_ADDON_SRCS $STREAM_LUA_SRCS"
NGX_ADDON_DEPS="$NGX_ADDON_DEPS $STREAM_LUA_DEPS"
CORE_INCS="$CORE_INCS $ngx_module_incs"
CORE_LIBS="$CORE_LIBS $ngx_module_libs"
fi
# ----------------------------------------
if [ $USE_PCRE = YES -o $PCRE != NONE ] && [ $PCRE != NO -a $PCRE != YES ]; then
# force pcre_version symbol to be required when PCRE is statically linked
case "$NGX_PLATFORM" in
Darwin:*)
ngx_feature="require defined symbols (-u)"
ngx_feature_name=
ngx_feature_path=
ngx_feature_libs="-Wl,-u,_strerror"
ngx_feature_run=no
ngx_feature_incs="#include <stdio.h>"
ngx_feature_test='printf("hello");'
. auto/feature
if [ $ngx_found = yes ]; then
CORE_LIBS="-Wl,-u,_pcre_version $CORE_LIBS"
fi
;;
*)
ngx_feature="require defined symbols (--require-defined)"
ngx_feature_name=
ngx_feature_path=
ngx_feature_libs="-Wl,--require-defined=strerror"
ngx_feature_run=no
ngx_feature_incs="#include <stdio.h>"
ngx_feature_test='printf("hello");'
. auto/feature
if [ $ngx_found = yes ]; then
CORE_LIBS="-Wl,--require-defined=pcre_version $CORE_LIBS"
fi
;;
esac
fi
# ----------------------------------------
USE_MD5=YES
USE_SHA1=YES
#NGX_DTRACE_PROVIDERS="$NGX_DTRACE_PROVIDERS $ngx_addon_dir/dtrace/ngx_lua_provider.d"
#NGX_TAPSET_SRCS="$NGX_TAPSET_SRCS $ngx_addon_dir/tapset/ngx_lua.stp"
CORE_INCS="$CORE_INCS $ngx_addon_dir/src/api"
echo "/* DO NOT EDIT! This file was automatically generated by config */" > "$ngx_addon_dir/src/ngx_stream_lua_autoconf.h"