-
Notifications
You must be signed in to change notification settings - Fork 200
/
config.m4
276 lines (239 loc) · 7.77 KB
/
config.m4
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
PHP_ARG_WITH(v8js, for V8 Javascript Engine,
[ --with-v8js Include V8 JavaScript Engine])
if test "$PHP_V8JS" != "no"; then
SEARCH_PATH="/usr/local /usr"
for libname in v8 node; do
SEARCH_FOR="lib$libname.$SHLIB_SUFFIX_NAME"
if test -d "$PHP_V8JS"; then
SEARCH_PATH="$PHP_V8JS"
# set rpath, so library loader picks up libv8 even if it's not on the
# system's library search path
case $host_os in
darwin* )
# MacOS does not support --rpath
;;
* )
LDFLAGS="$LDFLAGS -Wl,--rpath=$PHP_V8JS/$PHP_LIBDIR"
;;
esac
fi
AC_MSG_CHECKING([for V8 files in default path])
ARCH=$(uname -m)
for i in $SEARCH_PATH ; do
if test -r "$i/$PHP_LIBDIR/$SEARCH_FOR" -a -r "$i/include/$libname/v8.h"; then
V8_INCLUDE_DIR="$i/include/$libname"
V8_LIBRARY_DIR="$i/$PHP_LIBDIR"
AC_MSG_RESULT(found in $i)
break 2
fi
# Debian installations
if test -r "$i/$PHP_LIBDIR/$ARCH-linux-gnu/$SEARCH_FOR"; then
V8_INCLUDE_DIR="$i/include/$libname"
V8_LIBRARY_DIR="$i/$PHP_LIBDIR/$ARCH-linux-gnu"
AC_MSG_RESULT(found in $i)
break 2
fi
# Manual installations
if test -r "$i/$PHP_LIBDIR/$SEARCH_FOR" -a -r "$i/include/libplatform/libplatform.h"; then
V8_INCLUDE_DIR="$i/include"
V8_LIBRARY_DIR="$i/$PHP_LIBDIR"
AC_MSG_RESULT(found in $i)
break 2
fi
done
done
AC_DEFINE_UNQUOTED([PHP_V8_EXEC_PATH], "$V8_LIBRARY_DIR/$SEARCH_FOR", [Full path to libv8 library file])
if test -z "$V8_INCLUDE_DIR" || test -z "$V8_LIBRARY_DIR"; then
AC_MSG_RESULT([not found])
AC_MSG_ERROR([Please reinstall the v8 distribution])
fi
PHP_ADD_INCLUDE($V8_INCLUDE_DIR)
PHP_ADD_LIBRARY_WITH_PATH($libname, $V8_LIBRARY_DIR, V8JS_SHARED_LIBADD)
PHP_SUBST(V8JS_SHARED_LIBADD)
PHP_REQUIRE_CXX()
AC_CACHE_CHECK(for C standard version, ac_cv_v8_cstd, [
ac_cv_v8_cstd="c++20"
old_CPPFLAGS=$CPPFLAGS
AC_LANG_PUSH([C++])
CPPFLAGS="-std="$ac_cv_v8_cstd
AC_RUN_IFELSE([AC_LANG_SOURCE([[int main() { return 0; }]])],[],[
ac_cv_v8_cstd="c++17"
CPPFLAGS="-std="$ac_cv_v8_cstd
AC_RUN_IFELSE([AC_LANG_SOURCE([[int main() { return 0; }]])],[],[ ac_cv_v8_cstd="c++14" ],[])
],[])
AC_LANG_POP([C++])
CPPFLAGS=$old_CPPFLAGS
]);
AC_CACHE_CHECK(how to allow c++14 narrowing, ac_cv_v8_narrowing, [
ac_cv_v8_narrowing=""
old_CXXFLAGS=$CXXFLAGS
AC_LANG_PUSH([C++])
CXXFLAGS="-std="$ac_cv_v8_cstd
AC_RUN_IFELSE([AC_LANG_SOURCE([[int main() {
struct { unsigned int x; } foo = {-1};
(void) foo;
return 0;
}]])],[ac_cv_v8_narrowing=""],[
CXXFLAGS="-Wno-c++14-narrowing -std="$ac_cv_v8_cstd
AC_RUN_IFELSE([AC_LANG_SOURCE([[int main() {
struct { unsigned int x; } foo = {-1};
(void) foo;
return 0;
}]])],[ac_cv_v8_narrowing="-Wno-c++14-narrowing"],[
CXXFLAGS="-Wno-narrowing -std="$ac_cv_v8_cstd
AC_RUN_IFELSE([AC_LANG_SOURCE([[int main() {
struct { unsigned int x; } foo = {-1};
(void) foo;
return 0;
}]])],[ac_cv_v8_narrowing="-Wno-narrowing"],[
AC_MSG_ERROR([cannot compile with narrowing])
],[])
],[])
],[])
AC_LANG_POP([C++])
CXXFLAGS=$old_CXXFLAGS
]);
old_LIBS=$LIBS
old_LDFLAGS=$LDFLAGS
old_CPPFLAGS=$CPPFLAGS
AC_LANG_PUSH([C++])
CPPFLAGS="$CPPFLAGS -I$V8_INCLUDE_DIR -std=$ac_cv_v8_cstd"
LDFLAGS="$LDFLAGS -L$V8_LIBRARY_DIR"
if test "$libname" = "v8"; then
AC_MSG_CHECKING([for libv8_libplatform])
AC_DEFUN([V8_CHECK_LINK], [
save_LIBS="$LIBS"
LIBS="$LIBS $1 -lv8_libplatform -lv8"
AC_LINK_IFELSE([AC_LANG_PROGRAM([
#include <libplatform/libplatform.h>
], [ v8::platform::NewDefaultPlatform(); ])], [
dnl libv8_libplatform.so found
AC_MSG_RESULT(found)
V8JS_SHARED_LIBADD="$1 -lv8_libplatform $V8JS_SHARED_LIBADD"
$3
], [ $4 ])
LIBS="$save_LIBS"
])
V8_CHECK_LINK([], [], [], [
V8_CHECK_LINK([-lv8_libbase], [], [], [
AC_MSG_ERROR([could not find libv8_libplatform library])
])
])
fi
dnl
dnl Check for V8 version
dnl (basic support for library linking assumed to be achieved above)
dnl
LIBS="$LIBS $V8JS_SHARED_LIBADD"
AC_CACHE_CHECK(for V8 version, ac_cv_v8_version, [
AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <v8.h>
#include <iostream>
#include <fstream>
using namespace std;
int main ()
{
ofstream testfile ("conftestval");
if (testfile.is_open()) {
testfile << v8::V8::GetVersion();
testfile << "\n";
testfile.close();
return 0;
}
return 1;
}]])],[ac_cv_v8_version=`cat ./conftestval|awk '{print $1}'`],[ac_cv_v8_version=NONE],[ac_cv_v8_version=NONE])
])
if test "$ac_cv_v8_version" != "NONE"; then
ac_IFS=$IFS
IFS=.
set $ac_cv_v8_version
IFS=$ac_IFS
V8_API_VERSION=`expr [$]1 \* 1000000 + [$]2 \* 1000 + [$]3`
if test "$V8_API_VERSION" -lt 9000000 ; then
AC_MSG_ERROR([libv8 must be version 9.0 or greater])
fi
AC_DEFINE_UNQUOTED([PHP_V8_API_VERSION], $V8_API_VERSION, [ ])
AC_DEFINE_UNQUOTED([PHP_V8_VERSION], "$ac_cv_v8_version", [ ])
else
AC_MSG_ERROR([could not determine libv8 version])
fi
dnl
dnl Scan for blob.bin files (that might be needed)
dnl
AC_DEFUN([V8_SEARCH_BLOB], [
AC_MSG_CHECKING([for $1])
blob_found=0
for i in "$V8_LIBRARY_DIR" "$V8_INCLUDE_DIR/../share/v8"; do
if test -r "$i/$1"; then
AC_MSG_RESULT([found ($i/$1)])
AC_DEFINE_UNQUOTED([$2], "$i/$1", [Full path to $1 file])
blob_found=1
fi
done
if test "$blob_found" -ne 1; then
AC_MSG_RESULT([not found])
fi
])
V8_SEARCH_BLOB([natives_blob.bin], [PHP_V8_NATIVES_BLOB_PATH])
V8_SEARCH_BLOB([snapshot_blob.bin], [PHP_V8_SNAPSHOT_BLOB_PATH])
dnl
dnl Check for v8::V8::InitializeSandbox
dnl
AC_CACHE_CHECK([for v8::V8::InitializeSandbox], ac_cv_has_initialize_sandbox, [
AC_LINK_IFELSE([AC_LANG_PROGRAM([
#define V8_ENABLE_SANDBOX 1
#include <v8.h>
], [ v8::V8::InitializeSandbox(); ])], [
ac_cv_has_initialize_sandbox=yes
], [
ac_cv_has_initialize_sandbox=no
])
])
if test "x$ac_cv_has_initialize_sandbox" = "xyes"; then
AC_DEFINE([V8_HAS_INITIALIZE_SANDBOX], [1],
[Define if V8::InitializeSandbox must be called.])
fi
dnl
dnl Check for v8::ArrayBuffer::Allocator::NewDefaultAllocator
dnl
AC_CACHE_CHECK([for v8::ArrayBuffer::Allocator::NewDefaultAllocator], ac_cv_has_default_allocator, [
AC_LINK_IFELSE([AC_LANG_PROGRAM([
#include <v8.h>
], [ v8::ArrayBuffer::Allocator::NewDefaultAllocator(); ])], [
ac_cv_has_default_allocator=yes
], [
ac_cv_has_default_allocator=no
])
])
if test "x$ac_cv_has_default_allocator" = "xno"; then
AC_DEFINE([USE_INTERNAL_ALLOCATOR], [1],
[Define unless v8::ArrayBuffer::Allocator::NewDefaultAllocator is usable.])
fi
AC_LANG_POP([C++])
LIBS=$old_LIBS
LDFLAGS="$old_LDFLAGS"
CPPFLAGS=$old_CPPFLAGS
AC_DEFINE([V8_DEPRECATION_WARNINGS], [1], [Enable compiler warnings when using V8_DEPRECATED apis.])
PHP_ADD_INCLUDE($V8_INCLUDE_DIR)
PHP_NEW_EXTENSION(v8js, [ \
v8js_array_access.cc \
v8js_class.cc \
v8js_commonjs.cc \
v8js_convert.cc \
v8js_exceptions.cc \
v8js_generator_export.cc \
v8js_main.cc \
v8js_methods.cc \
v8js_object_export.cc \
v8js_timer.cc \
v8js_v8.cc \
v8js_v8object_class.cc \
v8js_variables.cc \
], $ext_shared, , "$ac_cv_v8_narrowing -std="$ac_cv_v8_cstd)
PHP_ADD_MAKEFILE_FRAGMENT
fi
dnl Local variables:
dnl tab-width: 4
dnl c-basic-offset: 4
dnl End:
dnl vim600: noet sw=4 ts=4 fdm=marker
dnl vim<600: noet sw=4 ts=4