doc: ngx.worker.count() is available in the init_worker_by_lua* context.
[lua-nginx-module.git] / config
blob0f2749d32f4948e6a0a13311d15d5b8d6817c534
1 ngx_feature="Lua library"
2 ngx_feature_libs="-llua -lm"
3 ngx_feature_name=
4 ngx_feature_run=no
5 ngx_feature_incs="#include <lauxlib.h>"
6 ngx_feature_path=
7 ngx_feature_test="#if LUA_VERSION_NUM != 501
8 #   error unsupported Lua language version
9 #endif
10 (void) luaL_newstate();"
11 ngx_lua_opt_I=
12 ngx_lua_opt_L=
14 if [ -n "$LUAJIT_INC" -o -n "$LUAJIT_LIB" ]; then
15     # explicitly set LuaJIT paths
17     if [ "$NGX_PLATFORM" = win32 ]; then
18         ngx_feature="LuaJIT library in $LUAJIT_LIB and $LUAJIT_INC (win32)"
19         ngx_feature_path="$LUAJIT_INC"
20         ngx_lua_opt_I="-I$LUAJIT_INC"
21         ngx_lua_opt_L="-L$LUAJIT_LIB"
23         # ensure that our -I$LUAJIT_INC and -L$LUAJIT_LIB is at the first.
24         SAVED_CC_TEST_FLAGS="$CC_TEST_FLAGS"
25         CC_TEST_FLAGS="$ngx_lua_opt_I $CC_TEST_FLAGS"
26         SAVED_NGX_TEST_LD_OPT="$NGX_TEST_LD_OPT"
27         NGX_TEST_LD_OPT="$ngx_lua_opt_L $NGX_TEST_LD_OPT"
29         # LuaJIT's win32 build uses the library file name lua51.dll.
30         ngx_feature_libs="$ngx_lua_opt_L -llua51"
32         . auto/feature
34         # clean up
35         CC_TEST_FLAGS="$SAVED_CC_TEST_FLAGS"
36         NGX_TEST_LD_OPT="$SAVED_NGX_TEST_LD_OPT"
37     else
39         # attempt to link with -ldl, static linking on Linux requires it.
40         ngx_feature="LuaJIT library in $LUAJIT_LIB and $LUAJIT_INC (specified by the LUAJIT_LIB and LUAJIT_INC env, with -ldl)"
41         ngx_feature_path="$LUAJIT_INC"
42         ngx_lua_opt_I="-I$LUAJIT_INC"
43         ngx_lua_opt_L="-L$LUAJIT_LIB"
45         # ensure that our -I$LUAJIT_INC and -L$LUAJIT_LIB is at the first.
46         SAVED_CC_TEST_FLAGS="$CC_TEST_FLAGS"
47         CC_TEST_FLAGS="$ngx_lua_opt_I $CC_TEST_FLAGS"
48         SAVED_NGX_TEST_LD_OPT="$NGX_TEST_LD_OPT"
49         NGX_TEST_LD_OPT="$ngx_lua_opt_L $NGX_TEST_LD_OPT"
51         if [ $NGX_RPATH = YES ]; then
52             ngx_feature_libs="-R$LUAJIT_LIB $ngx_lua_opt_L -lluajit-5.1 -lm -ldl"
53         else
54             ngx_feature_libs="$ngx_lua_opt_L -lluajit-5.1 -lm -ldl"
55         fi
57         . auto/feature
59         # clean up
60         CC_TEST_FLAGS="$SAVED_CC_TEST_FLAGS"
61         NGX_TEST_LD_OPT="$SAVED_NGX_TEST_LD_OPT"
63         if [ $ngx_found = no ]; then
64             # retry without -ldl
65             ngx_feature="LuaJIT library in $LUAJIT_LIB and $LUAJIT_INC (specified by the LUAJIT_LIB and LUAJIT_INC env)"
66             ngx_feature_path="$LUAJIT_INC"
67             ngx_lua_opt_I="-I$LUAJIT_INC"
68             ngx_lua_opt_L="-L$LUAJIT_LIB"
70             # ensure that our -I$LUAJIT_INC and -L$LUAJIT_LIB is at the first.
71             SAVED_CC_TEST_FLAGS="$CC_TEST_FLAGS"
72             CC_TEST_FLAGS="$ngx_lua_opt_I $CC_TEST_FLAGS"
73             SAVED_NGX_TEST_LD_OPT="$NGX_TEST_LD_OPT"
74             NGX_TEST_LD_OPT="$ngx_lua_opt_L $NGX_TEST_LD_OPT"
76             if [ $NGX_RPATH = YES ]; then
77                 ngx_feature_libs="-R$LUAJIT_LIB $ngx_lua_opt_L -lluajit-5.1 -lm"
78             else
79                 ngx_feature_libs="$ngx_lua_opt_L -lluajit-5.1 -lm"
80             fi
82             . auto/feature
84             # clean up
85             CC_TEST_FLAGS="$SAVED_CC_TEST_FLAGS"
86             NGX_TEST_LD_OPT="$SAVED_NGX_TEST_LD_OPT"
87         fi
88     fi
90     if [ $ngx_found = no ]; then
91         cat << END
92         $0: error: ngx_http_lua_module requires the Lua or LuaJIT library and LUAJIT_LIB is defined as $LUAJIT_LIB and LUAJIT_INC (path for lua.h) $LUAJIT_INC, but we cannot find LuaJIT there.
93 END
94         exit 1
95     fi
97     case "$NGX_PLATFORM" in
98         Darwin:*)
99             case "$NGX_MACHINE" in
100                 amd64 | x86_64 | i386)
101                     echo "adding extra linking options needed by LuaJIT"
102                     ngx_feature_libs="$ngx_feature_libs -pagezero_size 10000 -image_base 100000000"
103                 ;;
105                 *)
106                 ;;
107             esac
108         ;;
110         *)
111         ;;
112     esac
113 else
114     if [ -n "$LUA_INC" -o -n "$LUA_LIB" ]; then
115         # explicitly set Lua paths
116         ngx_feature="Lua library in $LUA_LIB and $LUA_INC (specified by the LUA_LIB and LUA_INC env)"
117         ngx_feature_path="$LUA_INC"
118         ngx_lua_opt_I="-I$LUA_INC"
119         ngx_lua_opt_L="-L$LUA_LIB"
121         # ensure that our -I$LUA_INC and -L$LUA_LIB is at the first.
122         SAVED_CC_TEST_FLAGS="$CC_TEST_FLAGS"
123         CC_TEST_FLAGS="$ngx_lua_opt_I $CC_TEST_FLAGS"
124         SAVED_NGX_TEST_LD_OPT="$NGX_TEST_LD_OPT"
125         NGX_TEST_LD_OPT="$ngx_lua_opt_L $NGX_TEST_LD_OPT"
127         if [ $NGX_RPATH = YES ]; then
128             ngx_feature_libs="-R$LUA_LIB $ngx_lua_opt_L -llua -lm -ldl"
129         else
130             ngx_feature_libs="$ngx_lua_opt_L -llua -lm -ldl"
131         fi
133         . auto/feature
135         # clean up
136         CC_TEST_FLAGS="$SAVED_CC_TEST_FLAGS"
137         NGX_TEST_LD_OPT="$SAVED_NGX_TEST_LD_OPT"
139         if [ $ngx_found = no ]; then
140             # retry without -ldl
142             ngx_feature_path="$LUA_INC"
143             ngx_lua_opt_I="-I$LUA_INC"
144             ngx_lua_opt_L="-L$LUA_LIB"
146             # ensure that our -I$LUA_INC and -L$LUA_LIB is at the first.
147             SAVED_CC_TEST_FLAGS="$CC_TEST_FLAGS"
148             CC_TEST_FLAGS="$ngx_lua_opt_I $CC_TEST_FLAGS"
149             SAVED_NGX_TEST_LD_OPT="$NGX_TEST_LD_OPT"
150             NGX_TEST_LD_OPT="$ngx_lua_opt_L $NGX_TEST_LD_OPT"
152             if [ $NGX_RPATH = YES ]; then
153                 ngx_feature_libs="-R$LUA_LIB $ngx_lua_opt_L -llua -lm"
154             else
155                 ngx_feature_libs="$ngx_lua_opt_L -llua -lm"
156             fi
158             . auto/feature
160             # clean up
161             CC_TEST_FLAGS="$SAVED_CC_TEST_FLAGS"
162             NGX_TEST_LD_OPT="$SAVED_NGX_TEST_LD_OPT"
163         fi
165         if [ $ngx_found = no ]; then
166             cat << END
167             $0: error: ngx_http_lua_module requires the Lua or LuaJIT library and LUA_LIB is defined as $LUA_LIB and LUA_INC (path for lua.h) is $LUA_INC, but we cannot find standard Lua there.
169             exit 1
170         fi
171     else
172         # auto-discovery
173         ngx_feature="Lua library"
174         ngx_feature_libs="-llua -lm"
175         . auto/feature
177         if [ $ngx_found = no ]; then
178             # OpenBSD-5.2
179             ngx_feature="Lua library in /usr/local/"
180             ngx_feature_path="/usr/local/include/lua-5.1"
181             if [ $NGX_RPATH = YES ]; then
182                 ngx_feature_libs="-R/usr/local/lib -L/usr/local/lib -llua -lm"
183             else
184                 ngx_feature_libs="-L/usr/local/lib -llua5.1 -lm"
185             fi
186             . auto/feature
187         fi
189         if [ $ngx_found = no ]; then
190             # OpenBSD < 5.2
191             ngx_feature="Lua library in /usr/local/"
192             ngx_feature_path="/usr/local/include"
193             if [ $NGX_RPATH = YES ]; then
194                 ngx_feature_libs="-R/usr/local/lib -L/usr/local/lib -llua -lm"
195             else
196                 ngx_feature_libs="-L/usr/local/lib -llua -lm"
197             fi
198             . auto/feature
199         fi
201         if [ $ngx_found = no ]; then
202             # NetBSD
203             ngx_feature="Lua library in /usr/pkg/"
204             ngx_feature_path="/usr/pkg/include/"
205             if [ $NGX_RPATH = YES ]; then
206                 ngx_feature_libs="-R/usr/pkg/lib -L/usr/pkg/lib -lm -llua"
207             else
208                 ngx_feature_libs="-L/usr/pkg/lib -lm -llua"
209             fi
210             . auto/feature
211         fi
213         if [ $ngx_found = no ]; then
214             # MacPorts
215             ngx_feature="Lua library in /opt/local/"
216             ngx_feature_path="/opt/local/include"
217             if [ $NGX_RPATH = YES ]; then
218                 ngx_feature_libs="-R/opt/local/lib -L/opt/local/lib -lm -llua"
219             else
220                 ngx_feature_libs="-L/opt/local/lib -lm -llua"
221             fi
222             . auto/feature
223         fi
225         if [ $ngx_found = no ]; then
226             # FreeBSD
227             ngx_feature="Lua library in /usr/local/*/lua51/"
228             ngx_feature_path="/usr/local/include/lua51"
229             if [ $NGX_RPATH = YES ]; then
230                 ngx_feature_libs="-R/usr/local/lib/lua51 -L/usr/local/lib/lua51 -llua -lm"
231             else
232                 ngx_feature_libs="-L/usr/local/lib/lua51 -llua -lm"
233             fi
234             . auto/feature
235         fi
237         if [ $ngx_found = no ]; then
238             # Debian
239             ngx_feature="Lua library in /usr/"
240             ngx_feature_path="/usr/include/lua5.1"
241             if [ $NGX_RPATH = YES ]; then
242                 ngx_feature_libs="-R/usr/lib -L/usr/lib -lm -llua5.1"
243             else
244                 ngx_feature_libs="-L/usr/lib -lm -llua5.1"
245             fi
246             . auto/feature
247         fi
249         if [ $ngx_found = no ]; then
250             # FreeBSD with luajit-2.0 from ports collection
251             ngx_feature="LuaJIT library in /usr/local/"
252             ngx_feature_path="/usr/local/include/luajit-2.0"
253             if [ $NGX_RPATH = YES ]; then
254                 ngx_feature_libs="-R/usr/local/lib -L/usr/local/lib -lluajit-5.1 -lm"
255             else
256                 ngx_feature_libs="-L/usr/local/lib -lluajit-5.1 -lm"
257             fi
258             . auto/feature
259         fi
261         if [ $ngx_found = no ]; then
262             # Gentoo with LuaJIT-2.0, try with -ldl
263             ngx_feature="LuaJIT library in /usr/"
264             ngx_feature_path="/usr/include/luajit-2.0"
265             if [ $NGX_RPATH = YES ]; then
266                 ngx_feature_libs="-R/usr/lib -L/usr/lib -lm -lluajit-5.1 -ldl"
267             else
268                 ngx_feature_libs="-L/usr/lib -lm -lluajit-5.1 -ldl"
269             fi
270             . auto/feature
271         fi
273         if [ $ngx_found = no ]; then
274             # Gentoo with LuaJIT 2.0
275             ngx_feature="LuaJIT library in /usr/"
276             ngx_feature_path="/usr/include/luajit-2.0"
277             if [ $NGX_RPATH = YES ]; then
278                 ngx_feature_libs="-R/usr/lib -L/usr/lib -lm -lluajit-5.1"
279             else
280                 ngx_feature_libs="-L/usr/lib -lm -lluajit-5.1"
281             fi
282             . auto/feature
283         fi
284     fi
287 ngx_module_incs=
288 ngx_module_libs=
290 if [ $ngx_found = yes ]; then
291     # this is a hack to persuade nginx's build system to favor
292     # the paths set by our user environments:
293     CFLAGS="$ngx_lua_opt_I $CFLAGS"
294     NGX_LD_OPT="$ngx_lua_opt_L $NGX_LD_OPT"
296     ngx_module_incs="$ngx_module_incs $ngx_feature_path"
297     ngx_module_libs="$ngx_module_libs $ngx_feature_libs"
298 else
299  cat << END
300  $0: error: ngx_http_lua_module requires the Lua library.
302  exit 1
305 ngx_addon_name=ngx_http_lua_module
306 HTTP_LUA_SRCS=" \
307             $ngx_addon_dir/src/ngx_http_lua_script.c \
308             $ngx_addon_dir/src/ngx_http_lua_log.c \
309             $ngx_addon_dir/src/ngx_http_lua_subrequest.c \
310             $ngx_addon_dir/src/ngx_http_lua_ndk.c \
311             $ngx_addon_dir/src/ngx_http_lua_control.c \
312             $ngx_addon_dir/src/ngx_http_lua_time.c \
313             $ngx_addon_dir/src/ngx_http_lua_misc.c \
314             $ngx_addon_dir/src/ngx_http_lua_variable.c \
315             $ngx_addon_dir/src/ngx_http_lua_string.c \
316             $ngx_addon_dir/src/ngx_http_lua_output.c \
317             $ngx_addon_dir/src/ngx_http_lua_headers.c \
318             $ngx_addon_dir/src/ngx_http_lua_req_body.c \
319             $ngx_addon_dir/src/ngx_http_lua_uri.c \
320             $ngx_addon_dir/src/ngx_http_lua_args.c \
321             $ngx_addon_dir/src/ngx_http_lua_ctx.c \
322             $ngx_addon_dir/src/ngx_http_lua_regex.c \
323             $ngx_addon_dir/src/ngx_http_lua_module.c \
324             $ngx_addon_dir/src/ngx_http_lua_headers_out.c \
325             $ngx_addon_dir/src/ngx_http_lua_headers_in.c \
326             $ngx_addon_dir/src/ngx_http_lua_directive.c \
327             $ngx_addon_dir/src/ngx_http_lua_consts.c \
328             $ngx_addon_dir/src/ngx_http_lua_exception.c \
329             $ngx_addon_dir/src/ngx_http_lua_util.c \
330             $ngx_addon_dir/src/ngx_http_lua_cache.c \
331             $ngx_addon_dir/src/ngx_http_lua_contentby.c \
332             $ngx_addon_dir/src/ngx_http_lua_rewriteby.c \
333             $ngx_addon_dir/src/ngx_http_lua_accessby.c \
334             $ngx_addon_dir/src/ngx_http_lua_setby.c \
335             $ngx_addon_dir/src/ngx_http_lua_capturefilter.c \
336             $ngx_addon_dir/src/ngx_http_lua_clfactory.c \
337             $ngx_addon_dir/src/ngx_http_lua_pcrefix.c \
338             $ngx_addon_dir/src/ngx_http_lua_headerfilterby.c \
339             $ngx_addon_dir/src/ngx_http_lua_shdict.c \
340             $ngx_addon_dir/src/ngx_http_lua_socket_tcp.c \
341             $ngx_addon_dir/src/ngx_http_lua_api.c \
342             $ngx_addon_dir/src/ngx_http_lua_logby.c \
343             $ngx_addon_dir/src/ngx_http_lua_sleep.c \
344             $ngx_addon_dir/src/ngx_http_lua_semaphore.c\
345             $ngx_addon_dir/src/ngx_http_lua_coroutine.c \
346             $ngx_addon_dir/src/ngx_http_lua_bodyfilterby.c \
347             $ngx_addon_dir/src/ngx_http_lua_initby.c \
348             $ngx_addon_dir/src/ngx_http_lua_initworkerby.c \
349             $ngx_addon_dir/src/ngx_http_lua_socket_udp.c \
350             $ngx_addon_dir/src/ngx_http_lua_req_method.c \
351             $ngx_addon_dir/src/ngx_http_lua_phase.c \
352             $ngx_addon_dir/src/ngx_http_lua_uthread.c \
353             $ngx_addon_dir/src/ngx_http_lua_timer.c \
354             $ngx_addon_dir/src/ngx_http_lua_config.c \
355             $ngx_addon_dir/src/ngx_http_lua_worker.c \
356             $ngx_addon_dir/src/ngx_http_lua_ssl_certby.c \
357             $ngx_addon_dir/src/ngx_http_lua_ssl_ocsp.c \
358             $ngx_addon_dir/src/ngx_http_lua_lex.c \
359             $ngx_addon_dir/src/ngx_http_lua_balancer.c \
360             $ngx_addon_dir/src/ngx_http_lua_ssl_session_storeby.c \
361             $ngx_addon_dir/src/ngx_http_lua_ssl_session_fetchby.c \
362             $ngx_addon_dir/src/ngx_http_lua_ssl.c \
363             "
365 HTTP_LUA_DEPS=" \
366             $ngx_addon_dir/src/ddebug.h \
367             $ngx_addon_dir/src/ngx_http_lua_script.h \
368             $ngx_addon_dir/src/ngx_http_lua_log.h \
369             $ngx_addon_dir/src/ngx_http_lua_subrequest.h \
370             $ngx_addon_dir/src/ngx_http_lua_ndk.h \
371             $ngx_addon_dir/src/ngx_http_lua_control.h \
372             $ngx_addon_dir/src/ngx_http_lua_time.h \
373             $ngx_addon_dir/src/ngx_http_lua_string.h \
374             $ngx_addon_dir/src/ngx_http_lua_misc.h \
375             $ngx_addon_dir/src/ngx_http_lua_variable.h \
376             $ngx_addon_dir/src/ngx_http_lua_output.h \
377             $ngx_addon_dir/src/ngx_http_lua_headers.h \
378             $ngx_addon_dir/src/ngx_http_lua_uri.h \
379             $ngx_addon_dir/src/ngx_http_lua_req_body.h \
380             $ngx_addon_dir/src/ngx_http_lua_args.h \
381             $ngx_addon_dir/src/ngx_http_lua_ctx.h \
382             $ngx_addon_dir/src/ngx_http_lua_regex.h \
383             $ngx_addon_dir/src/ngx_http_lua_common.h \
384             $ngx_addon_dir/src/ngx_http_lua_directive.h \
385             $ngx_addon_dir/src/ngx_http_lua_headers_out.h \
386             $ngx_addon_dir/src/ngx_http_lua_headers_in.h \
387             $ngx_addon_dir/src/ngx_http_lua_consts.h \
388             $ngx_addon_dir/src/ngx_http_lua_exception.h \
389             $ngx_addon_dir/src/ngx_http_lua_util.h \
390             $ngx_addon_dir/src/ngx_http_lua_cache.h \
391             $ngx_addon_dir/src/ngx_http_lua_contentby.h \
392             $ngx_addon_dir/src/ngx_http_lua_rewriteby.h \
393             $ngx_addon_dir/src/ngx_http_lua_accessby.h \
394             $ngx_addon_dir/src/ngx_http_lua_setby.h \
395             $ngx_addon_dir/src/ngx_http_lua_capturefilter.h \
396             $ngx_addon_dir/src/ngx_http_lua_clfactory.h \
397             $ngx_addon_dir/src/ngx_http_lua_pcrefix.h \
398             $ngx_addon_dir/src/ngx_http_lua_headerfilterby.h \
399             $ngx_addon_dir/src/ngx_http_lua_shdict.h \
400             $ngx_addon_dir/src/ngx_http_lua_socket_tcp.h \
401             $ngx_addon_dir/src/api/ngx_http_lua_api.h \
402             $ngx_addon_dir/src/ngx_http_lua_logby.h \
403             $ngx_addon_dir/src/ngx_http_lua_sleep.h \
404             $ngx_addon_dir/src/ngx_http_lua_semaphore.h\
405             $ngx_addon_dir/src/ngx_http_lua_coroutine.h \
406             $ngx_addon_dir/src/ngx_http_lua_bodyfilterby.h \
407             $ngx_addon_dir/src/ngx_http_lua_initby.h \
408             $ngx_addon_dir/src/ngx_http_lua_initworkerby.h \
409             $ngx_addon_dir/src/ngx_http_lua_socket_udp.h \
410             $ngx_addon_dir/src/ngx_http_lua_req_method.h \
411             $ngx_addon_dir/src/ngx_http_lua_phase.h \
412             $ngx_addon_dir/src/ngx_http_lua_probe.h \
413             $ngx_addon_dir/src/ngx_http_lua_uthread.h \
414             $ngx_addon_dir/src/ngx_http_lua_timer.h \
415             $ngx_addon_dir/src/ngx_http_lua_config.h \
416             $ngx_addon_dir/src/ngx_http_lua_worker.h \
417             $ngx_addon_dir/src/ngx_http_lua_ssl_certby.h \
418             $ngx_addon_dir/src/ngx_http_lua_lex.h \
419             $ngx_addon_dir/src/ngx_http_lua_balancer.h \
420             $ngx_addon_dir/src/ngx_http_lua_ssl_session_storeby.h \
421             $ngx_addon_dir/src/ngx_http_lua_ssl_session_fetchby.h \
422             $ngx_addon_dir/src/ngx_http_lua_ssl.h \
423             "
425 CFLAGS="$CFLAGS -DNDK_SET_VAR"
427 ngx_feature="export symbols by default (-E)"
428 ngx_feature_libs="-Wl,-E"
429 ngx_feature_name=
430 ngx_feature_run=no
431 ngx_feature_incs="#include <stdio.h>"
432 ngx_feature_path=
433 ngx_feature_test='printf("hello");'
435 . auto/feature
437 if [ $ngx_found = yes ]; then
438     CORE_LIBS="-Wl,-E $CORE_LIBS"
441 # for Cygwin
442 ngx_feature="export symbols by default (--export-all-symbols)"
443 ngx_feature_libs="-Wl,--export-all-symbols"
444 ngx_feature_name=
445 ngx_feature_run=no
446 ngx_feature_incs="#include <stdio.h>"
447 ngx_feature_path=
448 ngx_feature_test='printf("hello");'
450 . auto/feature
452 if [ $ngx_found = yes ]; then
453     CORE_LIBS="-Wl,--export-all-symbols $CORE_LIBS"
456 NGX_DTRACE_PROVIDERS="$NGX_DTRACE_PROVIDERS $ngx_addon_dir/dtrace/ngx_lua_provider.d"
457 NGX_TAPSET_SRCS="$NGX_TAPSET_SRCS $ngx_addon_dir/tapset/ngx_lua.stp"
459 USE_MD5=YES
460 USE_SHA1=YES
462 CORE_INCS="$CORE_INCS $ngx_addon_dir/src/api"
464 ngx_feature="SO_PASSCRED"
465 ngx_feature_libs=
466 ngx_feature_name="NGX_HTTP_LUA_HAVE_SO_PASSCRED"
467 ngx_feature_run=no
468 ngx_feature_incs="#include <sys/types.h>
469 #include <sys/socket.h>"
470 ngx_feature_path=
471 ngx_feature_test='setsockopt(1, SOL_SOCKET, SO_PASSCRED, NULL, 0);'
473 . auto/feature
475 ngx_feature="mmap(sbrk(0))"
476 ngx_feature_libs=
477 ngx_feature_name="NGX_HTTP_LUA_HAVE_MMAP_SBRK"
478 ngx_feature_run=yes
479 ngx_feature_incs="#include <unistd.h>
480 #include <stdlib.h>
481 #include <stdint.h>
482 #include <sys/mman.h>
483 #define align_ptr(p, a)                                                   \
484     (u_char *) (((uintptr_t) (p) + ((uintptr_t) a - 1)) & ~((uintptr_t) a - 1))
486 ngx_feature_test="
487 #if defined(__x86_64__)
488 exit(mmap(align_ptr(sbrk(0), getpagesize()), 1, PROT_READ,
489           MAP_FIXED|MAP_PRIVATE|MAP_ANON, -1, 0) < (void *) 0x40000000LL
490           ? 0 : 1);
491 #else
492 exit(1);
493 #endif
495 SAVED_CC_TEST_FLAGS="$CC_TEST_FLAGS"
496 CC_TEST_FLAGS="-Werror -Wall $CC_TEST_FLAGS"
498 . auto/feature
500 CC_TEST_FLAGS="$SAVED_CC_TEST_FLAGS"
502 ngx_feature="__attribute__(constructor)"
503 ngx_feature_libs=
504 ngx_feature_name="NGX_HTTP_LUA_HAVE_CONSTRUCTOR"
505 ngx_feature_run=yes
506 ngx_feature_incs="#include <stdlib.h>
507 int a = 2;
508 __attribute__((constructor))
509 static void foo(void)
511     a = 0;
514 ngx_feature_test="exit(a);"
515 SAVED_CC_TEST_FLAGS="$CC_TEST_FLAGS"
516 CC_TEST_FLAGS="-Werror -Wall $CC_TEST_FLAGS"
518 . auto/feature
520 CC_TEST_FLAGS="$SAVED_CC_TEST_FLAGS"
522 if test -n "$ngx_module_link"; then
523     ngx_module_type=HTTP_AUX_FILTER
524     ngx_module_name=$ngx_addon_name
525     ngx_module_deps="$HTTP_LUA_DEPS"
526     ngx_module_srcs="$HTTP_LUA_SRCS"
528     . auto/module
529 else
530     HTTP_AUX_FILTER_MODULES="$HTTP_AUX_FILTER_MODULES $ngx_addon_name"
531     NGX_ADDON_SRCS="$NGX_ADDON_SRCS $HTTP_LUA_SRCS"
532     NGX_ADDON_DEPS="$NGX_ADDON_DEPS $HTTP_LUA_DEPS"
534     CORE_INCS="$CORE_INCS $ngx_module_incs"
535     CORE_LIBS="$CORE_LIBS $ngx_module_libs"
538 #CFLAGS=$"$CFLAGS -DLUA_DEFAULT_PATH='\"/usr/local/openresty/lualib/?.lua\"'"
539 #CFLAGS=$"$CFLAGS -DLUA_DEFAULT_CPATH='\"/usr/local/openresty/lualib/?.so\"'"