Repository navigation
Expand file tree
/
Copy pathconfig
More file actions
70 lines (60 loc) · 3.04 KB
/
Copy pathconfig
File metadata and controls
70 lines (60 loc) · 3.04 KB
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
ngx_addon_name=ngx_http_ffi_client_module
ngx_http_ffi_client_lua_module_dir="${NGX_HTTP_LUA_MODULE_DIR:-}"
ngx_http_ffi_client_use_llhttp="${NGX_HTTP_FFI_CLIENT_USE_LLHTTP:-1}"
if [ -z "$ngx_http_ffi_client_lua_module_dir" ]; then
if [ -f "$ngx_addon_dir/../lua-nginx-module/src/api/ngx_http_lua_api.h" ]; then
ngx_http_ffi_client_lua_module_dir="$(cd "$ngx_addon_dir/../lua-nginx-module" && pwd)"
else
ngx_http_ffi_client_lua_module_dir="/home/rain/git/lua-nginx-module"
fi
fi
if [ ! -f "$ngx_http_ffi_client_lua_module_dir/src/api/ngx_http_lua_api.h" ]; then
cat << END
$0: error: ngx_http_ffi_client requires ngx_http_lua_api.h.
Set NGX_HTTP_LUA_MODULE_DIR to a lua-nginx-module checkout, for example:
NGX_HTTP_LUA_MODULE_DIR=/home/rain/git/lua-nginx-module
END
exit 1
fi
HTTP_MODULES="$HTTP_MODULES ngx_http_ffi_client_module"
ngx_http_ffi_client_srcs="\
$ngx_addon_dir/src/ngx_http_ffi_client_module.c \
$ngx_addon_dir/src/ngx_http_ffi_client_lua.c \
$ngx_addon_dir/src/ngx_http_ffi_client_keepalive.c \
$ngx_addon_dir/src/ngx_http_ffi_client_request.c"
if [ "$ngx_http_ffi_client_use_llhttp" = "1" ]; then
# Build the vendored llhttp parser as a standalone static library so its
# generated C is not subject to nginx's -Werror build flags, then link it
# in via CORE_LIBS. The FFI glue (response_llhttp.c) still builds as a
# normal addon source under nginx's flags.
ngx_http_ffi_client_llhttp_dir="$ngx_addon_dir/src/llhttp"
ngx_http_ffi_client_llhttp_lib="$ngx_http_ffi_client_llhttp_dir/libllhttp.a"
echo "ngx_http_ffi_client: building $ngx_http_ffi_client_llhttp_lib"
for ngx_http_ffi_client_unit in llhttp api http; do
# CC is unquoted on purpose: nginx's own auto/ scripts treat it as a
# word list, and a build that sets CC to more than a bare program
# name -- "gcc -fsanitize=address ...", a ccache or cross-compile
# wrapper -- would otherwise be looked up as one long filename.
${CC:-cc} -O2 -fPIC -I "$ngx_http_ffi_client_llhttp_dir" \
-c "$ngx_http_ffi_client_llhttp_dir/$ngx_http_ffi_client_unit.c" \
-o "$ngx_http_ffi_client_llhttp_dir/$ngx_http_ffi_client_unit.o" \
|| exit 1
done
ar rcs "$ngx_http_ffi_client_llhttp_lib" \
"$ngx_http_ffi_client_llhttp_dir/llhttp.o" \
"$ngx_http_ffi_client_llhttp_dir/api.o" \
"$ngx_http_ffi_client_llhttp_dir/http.o" \
|| exit 1
ngx_http_ffi_client_srcs="$ngx_http_ffi_client_srcs \
$ngx_addon_dir/src/ngx_http_ffi_client_response_llhttp.c"
CORE_INCS="$CORE_INCS $ngx_http_ffi_client_llhttp_dir"
CORE_LIBS="$CORE_LIBS $ngx_http_ffi_client_llhttp_lib"
CFLAGS="$CFLAGS -DNGX_HTTP_FFI_CLIENT_USE_LLHTTP=1"
else
ngx_http_ffi_client_srcs="$ngx_http_ffi_client_srcs \
$ngx_addon_dir/src/ngx_http_ffi_client_response.c"
fi
NGX_ADDON_SRCS="$NGX_ADDON_SRCS $ngx_http_ffi_client_srcs"
CORE_INCS="$CORE_INCS $ngx_http_ffi_client_lua_module_dir/src/api \
$ngx_http_ffi_client_lua_module_dir/src \
$ngx_addon_dir/src/compat"