aboutsummaryrefslogtreecommitdiff
path: root/auto/quickjs
blob: 60c0888e3faff6b5455af21c5cdb816f29f60ea5 (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
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
# Copyright (C) Dmitry Volyntsev
# Copyright (C) NGINX, Inc.


NJS_QUICKJS_LIB=
NJS_HAVE_QUICKJS=NO

if [ $NJS_TRY_QUICKJS = YES ]; then
    njs_found=no

    njs_feature="QuickJS library -lquickjs.lto"
    njs_feature_name=NJS_HAVE_QUICKJS
    njs_feature_run=yes
    njs_feature_incs=
    njs_feature_libs="-lquickjs.lto -lm -ldl -lpthread"
    njs_feature_test="#if defined(__GNUC__) && (__GNUC__ >= 8)
                      #pragma GCC diagnostic push
                      #pragma GCC diagnostic ignored \"-Wcast-function-type\"
                      #endif

                      #include <quickjs.h>

                      int main() {
                          JSRuntime *rt;

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

    if [ $njs_found = no ]; then
        njs_feature="QuickJS library -lquickjs"
        njs_feature_libs="-lquickjs -lm -ldl -lpthread"

        . auto/feature
    fi

    if [ $njs_found = no ]; then
        njs_feature="QuickJS library -I/usr/include/quickjs/ -L/usr/lib/quickjs/ -lquickjs.lto"
        njs_feature_incs="/usr/include/quickjs/"
        njs_feature_libs="-L/usr/lib/quickjs/ -lquickjs.lto -lm -ldl -lpthread"

        . auto/feature
    fi

    if [ $njs_found = no ]; then
        njs_feature="QuickJS library -I/usr/include/quickjs/ -L/usr/lib/quickjs/ -lquickjs"
        njs_feature_incs="/usr/include/quickjs/"
        njs_feature_libs="-L/usr/lib/quickjs/ -lquickjs -lm -ldl -lpthread"

        . auto/feature
    fi

    if [ $njs_found = no ]; then
        njs_feature="QuickJS-NG library -lqjs"
        njs_feature_incs=""
        njs_feature_libs="-lqjs -lm -ldl -lpthread"

        . auto/feature
    fi


    if [ $njs_found = yes ]; then

        njs_feature="QuickJS JS_GetClassID()"
        njs_feature_name=NJS_HAVE_QUICKJS_GET_CLASS_ID
        njs_feature_test="#if defined(__GNUC__) && (__GNUC__ >= 8)
                          #pragma GCC diagnostic push
                          #pragma GCC diagnostic ignored \"-Wcast-function-type\"
                          #endif

                          #include <quickjs.h>

                          int main() {
                              (void) JS_GetClassID(JS_UNDEFINED);
                              return 0;
                         }"

        . auto/feature

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

        njs_feature="QuickJS JS_NewTypedArray()"
        njs_feature_name=NJS_HAVE_QUICKJS_NEW_TYPED_ARRAY
        njs_feature_test="#if defined(__GNUC__) && (__GNUC__ >= 8)
                          #pragma GCC diagnostic push
                          #pragma GCC diagnostic ignored \"-Wcast-function-type\"
                          #endif

                          #include <quickjs.h>

                          int main() {
                              JSValue   ta, argv;
                              JSRuntime *rt;
                              JSContext *ctx;

                              rt = JS_NewRuntime();
                              ctx = JS_NewContext(rt);
                              argv = JS_NewInt64(ctx, 1);
                              ta = JS_NewTypedArray(ctx, 1, &argv,
                                                    JS_TYPED_ARRAY_UINT8);
                              JS_FreeValue(ctx, ta);
                              JS_FreeContext(ctx);
                              JS_FreeRuntime(rt);
                              return 0;
                         }"

        . auto/feature

        njs_feature="QuickJS JS_IsSameValue()"
        njs_feature_name=NJS_HAVE_QUICKJS_IS_SAME_VALUE
        njs_feature_test="#if defined(__GNUC__) && (__GNUC__ >= 8)
                          #pragma GCC diagnostic push
                          #pragma GCC diagnostic ignored \"-Wcast-function-type\"
                          #endif

                          #include <quickjs.h>

                          int main() {
                              JSRuntime *rt;
                              JSContext *ctx;

                              rt = JS_NewRuntime();
                              ctx = JS_NewContext(rt);
                              (void) JS_IsSameValue(ctx, JS_UNDEFINED, JS_UNDEFINED);
                              JS_FreeContext(ctx);
                              JS_FreeRuntime(rt);
                              return 0;
                         }"

        . auto/feature

        njs_feature="QuickJS JS_IsArray()"
        njs_feature_name=NJS_HAVE_QUICKJS_IS_ARRAY_SINGLE_ARG
        njs_feature_test="#if defined(__GNUC__) && (__GNUC__ >= 8)
                          #pragma GCC diagnostic push
                          #pragma GCC diagnostic ignored \"-Wcast-function-type\"
                          #endif

                          #include <quickjs.h>

                          int main() {
                              JSRuntime *rt;
                              JSContext *ctx;

                              rt = JS_NewRuntime();
                              ctx = JS_NewContext(rt);
                              (void) JS_IsArray(JS_UNDEFINED);
                              JS_FreeContext(ctx);
                              JS_FreeRuntime(rt);
                              return 0;
                         }"

        . auto/feature

        njs_feature="QuickJS JS_AddIntrinsicBigInt()"
        njs_feature_name=NJS_HAVE_QUICKJS_ADD_INTRINSIC_BIG_INT
        njs_feature_test="#if defined(__GNUC__) && (__GNUC__ >= 8)
                          #pragma GCC diagnostic push
                          #pragma GCC diagnostic ignored \"-Wcast-function-type\"
                          #endif

                          #include <quickjs.h>

                          int main() {
                              JSRuntime *rt;
                              JSContext *ctx;

                              rt = JS_NewRuntime();
                              ctx = JS_NewContextRaw(rt);
                              JS_AddIntrinsicBigInt(ctx);
                              JS_FreeContext(ctx);
                              JS_FreeRuntime(rt);
                              return 0;
                         }"

        . auto/feature

        njs_feature="QuickJS version"
        njs_feature_name=NJS_QUICKJS_VERSION
        njs_feature_run=value
        njs_feature_test="#if defined(__GNUC__) && (__GNUC__ >= 8)
                          #pragma GCC diagnostic push
                          #pragma GCC diagnostic ignored \"-Wcast-function-type\"
                          #endif

                          #include <quickjs.h>

                          int main() {
#if defined(QJS_VERSION_MAJOR)
                              printf(\"\\\"%s\\\"\", JS_GetVersion());
#else
                              printf(\"\\\"Unknown\\\"\");
#endif
                              return 0;
                         }"

        . auto/feature

        NJS_HAVE_QUICKJS=YES
        NJS_QUICKJS_LIB="$njs_feature_libs"
        NJS_LIB_INCS="$NJS_LIB_INCS $njs_feature_incs"
        NJS_LIB_AUX_LIBS="$NJS_LIB_AUX_LIBS $njs_feature_libs"
    fi

    if [ $NJS_QUICKJS = YES -a $NJS_HAVE_QUICKJS = NO ]; then
        echo
        echo $0: error: no QuickJS library found.
        echo
        exit 1;
    fi

fi