aboutsummaryrefslogtreecommitdiff
path: root/nginx/config
blob: b994f97f30121c91a088b7e12e28bf6783bfb60a (plain)
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
ngx_addon_name="ngx_js_module"

NJS_OPENSSL=${NJS_OPENSSL:-YES}
NJS_LIBXSLT=${NJS_LIBXSLT:-YES}
NJS_ZLIB=${NJS_ZLIB:-YES}
NJS_QUICKJS=${NJS_QUICKJS:-YES}

NJS_DEPS="$ngx_addon_dir/ngx_js.h \
    $ngx_addon_dir/ngx_js_http.h \
    $ngx_addon_dir/ngx_js_fetch.h \
    $ngx_addon_dir/ngx_js_shared_dict.h"
NJS_SRCS="$ngx_addon_dir/ngx_js.c \
    $ngx_addon_dir/ngx_js_http.c \
    $ngx_addon_dir/ngx_js_fetch.c \
    $ngx_addon_dir/ngx_js_regex.c \
    $ngx_addon_dir/ngx_js_shared_dict.c"

QJS_DEPS=""
QJS_SRCS=""

NJS_OPENSSL_LIB=
NJS_XSLT_LIB=
NJS_ZLIB_LIB=
NJS_QUICKJS_LIB=
NJS_QUICKJS_INC=
NJS_HAVE_QUICKJS=

if [ $NJS_QUICKJS != NO ]; then

    ngx_feature="QuickJS library -lquickjs.lto"
    ngx_feature_name=NJS_HAVE_QUICKJS
    ngx_feature_run=yes
    ngx_feature_incs="#if defined(__GNUC__) && (__GNUC__ >= 8)
                      #pragma GCC diagnostic push
                      #pragma GCC diagnostic ignored \"-Wcast-function-type\"
                      #endif

                      #include <quickjs.h>"
    ngx_feature_path=""
    ngx_feature_libs="-lquickjs.lto -lm -ldl -lpthread"
    ngx_feature_test="JSRuntime *rt;

                      rt = JS_NewRuntime();
                      JS_FreeRuntime(rt);
                      return 0;"
    . auto/feature

    if [ $ngx_found = no ]; then
        ngx_feature="QuickJS library -lquickjs"
        ngx_feature_libs="-lquickjs -lm -ldl -lpthread"

        . auto/feature
    fi

    if [ $ngx_found = no ]; then
        ngx_feature="QuickJS library -I/usr/include/quickjs/ -L/usr/lib/quickjs/ -lquickjs.lto"
        ngx_feature_path="/usr/include/quickjs/"
        ngx_feature_libs="-L/usr/lib/quickjs/ -lquickjs.lto -lm -ldl -lpthread"

        . auto/feature
    fi

    if [ $ngx_found = no ]; then
        ngx_feature="QuickJS library -I/usr/include/quickjs/ -L/usr/lib/quickjs/ -lquickjs"
        ngx_feature_libs="-L/usr/lib/quickjs/ -lquickjs -lm -ldl -lpthread"

        . auto/feature
    fi

    if [ $ngx_found = no ]; then
        ngx_feature="QuickJS-NG library -lqjs"
        ngx_feature_path=""
        ngx_feature_libs="-lqjs -lm -ldl -lpthread"

        . auto/feature
    fi

    if [ $ngx_found = yes ]; then

        ngx_feature="QuickJS JS_GetClassID()"
        ngx_feature_name=NJS_HAVE_QUICKJS_GET_CLASS_ID
        ngx_feature_run=no
        ngx_feature_test="(void) JS_GetClassID(JS_UNDEFINED);"

        . auto/feature

        if [ $ngx_found = no ]; then
            echo
            echo $0: error: QuickJS library found, but JS_GetClassID\(\) is missing.
            echo
            exit 1;
        fi

        ngx_feature="QuickJS JS_NewTypedArray()"
        ngx_feature_name=NJS_HAVE_QUICKJS_NEW_TYPED_ARRAY
        ngx_feature_test="JSValue argv;
                         (void) JS_NewTypedArray(NULL, 1, &argv,
                                                 JS_TYPED_ARRAY_UINT8);
                          return 0;"

        . auto/feature

        ngx_feature="QuickJS JS_IsSameValue()"
        ngx_feature_name=NJS_HAVE_QUICKJS_IS_SAME_VALUE
        ngx_feature_test="(void) JS_IsSameValue(NULL, JS_UNDEFINED, JS_UNDEFINED);"

        . auto/feature

        NJS_HAVE_QUICKJS=YES
        NJS_QUICKJS_LIB="$ngx_feature_libs"
        NJS_QUICKJS_INC="$ngx_feature_path"

        echo " enabled QuickJS engine"
    fi
fi

if [ $NJS_OPENSSL != NO ]; then
    NJS_OPENSSL_LIB=OPENSSL
    have=NJS_HAVE_OPENSSL . auto/have
    NJS_SRCS="$NJS_SRCS $ngx_addon_dir/../external/njs_webcrypto_module.c"

    if [ "$NJS_HAVE_QUICKJS" = "YES" ];  then
        NJS_SRCS="$NJS_SRCS $ngx_addon_dir/../external/qjs_webcrypto_module.c"
    fi

    echo " enabled webcrypto module"
fi

if [ $NJS_LIBXSLT != NO ]; then
    NJS_XSLT_LIB=LIBXSLT
    have=NJS_HAVE_XML . auto/have
    NJS_SRCS="$NJS_SRCS $ngx_addon_dir/../external/njs_xml_module.c"

    if [ "$NJS_HAVE_QUICKJS" = "YES" ];  then
        NJS_SRCS="$NJS_SRCS $ngx_addon_dir/../external/qjs_xml_module.c"
    fi

    echo " enabled xml module"
fi

if [ $NJS_ZLIB != NO ]; then
    NJS_ZLIB_LIB=ZLIB
    have=NJS_HAVE_ZLIB . auto/have
    NJS_SRCS="$NJS_SRCS $ngx_addon_dir/../external/njs_zlib_module.c"

    if [ "$NJS_HAVE_QUICKJS" = "YES" ];  then
        NJS_SRCS="$NJS_SRCS $ngx_addon_dir/../external/qjs_zlib_module.c"
    fi

    echo " enabled zlib module"
fi


NJS_ENGINE_DEP="$ngx_addon_dir/../build/libnjs.a"
NJS_ENGINE_LIB="$ngx_addon_dir/../build/libnjs.a"
if [ "$NJS_HAVE_QUICKJS" = "YES" ];  then
    NJS_ENGINE_DEP="$ngx_addon_dir/../build/libqjs.a"
    NJS_ENGINE_LIB="$ngx_addon_dir/../build/libnjs.a $ngx_addon_dir/../build/libqjs.a"
fi

if [ $HTTP != NO ]; then
    ngx_module_type=HTTP_AUX_FILTER
    ngx_module_name=ngx_http_js_module
    ngx_module_incs="$ngx_addon_dir/../src $ngx_addon_dir/../build \
                     $NJS_QUICKJS_INC"
    ngx_module_deps="$NJS_ENGINE_DEP $NJS_DEPS $QJS_DEPS"
    ngx_module_srcs="$ngx_addon_dir/ngx_http_js_module.c $NJS_SRCS $QJS_SRCS"
    ngx_module_libs="PCRE $NJS_OPENSSL_LIB $NJS_XSLT_LIB $NJS_ZLIB_LIB \
                     $NJS_QUICKJS_LIB $NJS_ENGINE_LIB -lm"

    . auto/module

    if [ "$ngx_module_link" != DYNAMIC ]; then
        NJS_SRCS=
    fi
fi

if [ $STREAM != NO ]; then
    ngx_module_type=STREAM
    ngx_module_name=ngx_stream_js_module
    ngx_module_incs="$ngx_addon_dir/../src $ngx_addon_dir/../build \
                     $NJS_QUICKJS_INC"
    ngx_module_deps="$NJS_ENGINE_DEP $NJS_DEPS $QJS_DEPS"
    ngx_module_srcs="$ngx_addon_dir/ngx_stream_js_module.c $NJS_SRCS $QJS_SRCS"
    ngx_module_libs="PCRE $NJS_OPENSSL_LIB $NJS_XSLT_LIB $NJS_ZLIB_LIB \
                     $NJS_QUICKJS_LIB $NJS_ENGINE_LIB -lm"

    . auto/module
fi