2012-04-27 16:26:15 +00:00
|
|
|
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"
|
2024-09-07 14:05:07 +00:00
|
|
|
SEARCH_FOR="libv8.$SHLIB_SUFFIX_NAME"
|
|
|
|
|
2012-04-27 16:26:15 +00:00
|
|
|
if test -r $PHP_V8JS/$SEARCH_FOR; then
|
2015-03-08 23:06:01 +00:00
|
|
|
case $host_os in
|
|
|
|
darwin* )
|
|
|
|
# MacOS does not support --rpath
|
|
|
|
;;
|
|
|
|
* )
|
|
|
|
LDFLAGS="$LDFLAGS -Wl,--rpath=$PHP_V8JS/$PHP_LIBDIR"
|
|
|
|
;;
|
|
|
|
esac
|
2024-09-07 14:05:07 +00:00
|
|
|
V8_INCLUDE_DIR=$PHP_V8JS/include/v8
|
|
|
|
V8_LIBRARY_DIR=$PHP_V8JS/$PHP_LIBDIR
|
2012-04-27 16:26:15 +00:00
|
|
|
else
|
|
|
|
AC_MSG_CHECKING([for V8 files in default path])
|
2024-09-07 14:08:04 +00:00
|
|
|
ARCH=$(uname -m)
|
|
|
|
|
2012-04-27 16:26:15 +00:00
|
|
|
for i in $SEARCH_PATH ; do
|
2024-09-07 14:05:07 +00:00
|
|
|
if test -r $i/$PHP_LIBDIR/$SEARCH_FOR; then
|
|
|
|
V8_INCLUDE_DIR=$i/include/v8
|
|
|
|
V8_LIBRARY_DIR=$i/$PHP_LIBDIR
|
2012-04-27 16:26:15 +00:00
|
|
|
AC_MSG_RESULT(found in $i)
|
|
|
|
fi
|
2024-09-07 14:08:04 +00:00
|
|
|
|
|
|
|
if test -r $i/$PHP_LIBDIR/$ARCH-linux-gnu/$SEARCH_FOR; then
|
|
|
|
V8_INCLUDE_DIR=$i/include/v8
|
|
|
|
V8_LIBRARY_DIR=$i/$PHP_LIBDIR/$ARCH-linux-gnu
|
|
|
|
AC_MSG_RESULT(found in $i)
|
|
|
|
fi
|
2012-04-27 16:26:15 +00:00
|
|
|
done
|
|
|
|
fi
|
|
|
|
|
2024-09-07 14:05:07 +00:00
|
|
|
AC_DEFINE_UNQUOTED([PHP_V8_EXEC_PATH], "$V8_LIBRARY_DIR/$SEARCH_FOR", [Full path to libv8 library file])
|
2017-04-14 12:27:01 +00:00
|
|
|
|
2024-09-07 14:05:07 +00:00
|
|
|
if test -z "$V8_INCLUDE_DIR" || test -z "$V8_LIBRARY_DIR"; then
|
2012-04-27 16:26:15 +00:00
|
|
|
AC_MSG_RESULT([not found])
|
|
|
|
AC_MSG_ERROR([Please reinstall the v8 distribution])
|
|
|
|
fi
|
|
|
|
|
2024-09-07 14:05:07 +00:00
|
|
|
PHP_ADD_INCLUDE($V8_INCLUDE_DIR)
|
|
|
|
PHP_ADD_LIBRARY_WITH_PATH(v8, $V8_LIBRARY_DIR, V8JS_SHARED_LIBADD)
|
2012-04-27 16:26:15 +00:00
|
|
|
PHP_SUBST(V8JS_SHARED_LIBADD)
|
|
|
|
PHP_REQUIRE_CXX()
|
|
|
|
|
2015-03-10 13:16:37 +00:00
|
|
|
|
|
|
|
AC_CACHE_CHECK(for C standard version, ac_cv_v8_cstd, [
|
2022-06-24 19:27:33 +00:00
|
|
|
ac_cv_v8_cstd="c++17"
|
2015-03-10 13:16:37 +00:00
|
|
|
old_CPPFLAGS=$CPPFLAGS
|
|
|
|
AC_LANG_PUSH([C++])
|
|
|
|
CPPFLAGS="-std="$ac_cv_v8_cstd
|
2022-06-24 19:27:33 +00:00
|
|
|
AC_RUN_IFELSE([AC_LANG_SOURCE([[int main() { return 0; }]])],[],[
|
|
|
|
ac_cv_v8_cstd="c++14"
|
|
|
|
CPPFLAGS="-std="$ac_cv_v8_cstd
|
|
|
|
AC_RUN_IFELSE([AC_LANG_SOURCE([[int main() { return 0; }]])],[],[ ac_cv_v8_cstd="c++1y" ],[])
|
|
|
|
],[])
|
2015-03-10 13:16:37 +00:00
|
|
|
AC_LANG_POP([C++])
|
|
|
|
CPPFLAGS=$old_CPPFLAGS
|
|
|
|
]);
|
|
|
|
|
2021-03-21 02:07:53 +00:00
|
|
|
AC_CACHE_CHECK(how to allow c++14 narrowing, ac_cv_v8_narrowing, [
|
2015-07-25 19:36:34 +00:00
|
|
|
ac_cv_v8_narrowing=""
|
|
|
|
old_CXXFLAGS=$CXXFLAGS
|
|
|
|
AC_LANG_PUSH([C++])
|
2015-10-18 16:03:04 +00:00
|
|
|
CXXFLAGS="-std="$ac_cv_v8_cstd
|
2018-07-21 01:03:40 +00:00
|
|
|
AC_RUN_IFELSE([AC_LANG_SOURCE([[int main() {
|
2015-10-18 16:03:04 +00:00
|
|
|
struct { unsigned int x; } foo = {-1};
|
|
|
|
(void) foo;
|
|
|
|
return 0;
|
2018-07-21 01:03:40 +00:00
|
|
|
}]])],[ac_cv_v8_narrowing=""],[
|
2021-03-21 02:07:53 +00:00
|
|
|
CXXFLAGS="-Wno-c++14-narrowing -std="$ac_cv_v8_cstd
|
2018-07-21 01:03:40 +00:00
|
|
|
AC_RUN_IFELSE([AC_LANG_SOURCE([[int main() {
|
2015-10-18 16:03:04 +00:00
|
|
|
struct { unsigned int x; } foo = {-1};
|
|
|
|
(void) foo;
|
|
|
|
return 0;
|
2021-03-21 02:07:53 +00:00
|
|
|
}]])],[ac_cv_v8_narrowing="-Wno-c++14-narrowing"],[
|
2015-10-18 16:03:04 +00:00
|
|
|
CXXFLAGS="-Wno-narrowing -std="$ac_cv_v8_cstd
|
2018-07-21 01:03:40 +00:00
|
|
|
AC_RUN_IFELSE([AC_LANG_SOURCE([[int main() {
|
2015-10-18 16:03:04 +00:00
|
|
|
struct { unsigned int x; } foo = {-1};
|
|
|
|
(void) foo;
|
|
|
|
return 0;
|
2018-07-21 01:03:40 +00:00
|
|
|
}]])],[ac_cv_v8_narrowing="-Wno-narrowing"],[
|
2015-10-18 16:03:04 +00:00
|
|
|
AC_MSG_ERROR([cannot compile with narrowing])
|
2018-07-21 01:03:40 +00:00
|
|
|
],[])
|
|
|
|
],[])
|
|
|
|
],[])
|
2015-07-25 19:36:34 +00:00
|
|
|
AC_LANG_POP([C++])
|
|
|
|
CXXFLAGS=$old_CXXFLAGS
|
|
|
|
]);
|
|
|
|
|
2015-03-10 13:16:37 +00:00
|
|
|
|
2013-10-12 18:44:15 +00:00
|
|
|
old_LIBS=$LIBS
|
|
|
|
old_LDFLAGS=$LDFLAGS
|
|
|
|
old_CPPFLAGS=$CPPFLAGS
|
2015-03-08 23:06:01 +00:00
|
|
|
|
2018-07-21 02:48:23 +00:00
|
|
|
AC_LANG_PUSH([C++])
|
2013-10-12 18:44:15 +00:00
|
|
|
|
2024-09-07 14:05:07 +00:00
|
|
|
CPPFLAGS="$CPPFLAGS -I$V8_INCLUDE_DIR -std=$ac_cv_v8_cstd"
|
|
|
|
LDFLAGS="$LDFLAGS -L$V8_LIBRARY_DIR"
|
2016-12-05 16:18:16 +00:00
|
|
|
|
2017-03-13 21:45:55 +00:00
|
|
|
AC_MSG_CHECKING([for libv8_libplatform])
|
2016-12-05 16:18:16 +00:00
|
|
|
AC_DEFUN([V8_CHECK_LINK], [
|
|
|
|
save_LIBS="$LIBS"
|
2017-05-29 19:15:24 +00:00
|
|
|
LIBS="$LIBS $1 -lv8_libplatform -lv8"
|
|
|
|
AC_LINK_IFELSE([AC_LANG_PROGRAM([
|
|
|
|
#include <libplatform/libplatform.h>
|
2019-02-11 20:16:35 +00:00
|
|
|
], [ v8::platform::NewDefaultPlatform(); ])], [
|
2017-05-29 19:15:24 +00:00
|
|
|
dnl libv8_libplatform.so found
|
|
|
|
AC_MSG_RESULT(found)
|
|
|
|
V8JS_SHARED_LIBADD="$1 -lv8_libplatform $V8JS_SHARED_LIBADD"
|
|
|
|
$3
|
|
|
|
], [ $4 ])
|
2016-12-05 16:18:16 +00:00
|
|
|
LIBS="$save_LIBS"
|
|
|
|
])
|
|
|
|
|
2017-05-29 19:15:24 +00:00
|
|
|
V8_CHECK_LINK([], [], [], [
|
|
|
|
V8_CHECK_LINK([-lv8_libbase], [], [], [
|
|
|
|
AC_MSG_ERROR([could not find libv8_libplatform library])
|
|
|
|
])
|
2016-12-05 16:18:16 +00:00
|
|
|
])
|
|
|
|
|
|
|
|
|
|
|
|
dnl
|
|
|
|
dnl Check for V8 version
|
|
|
|
dnl (basic support for library linking assumed to be achieved above)
|
|
|
|
dnl
|
|
|
|
LIBS="$LIBS $V8JS_SHARED_LIBADD"
|
2012-04-27 16:26:15 +00:00
|
|
|
AC_CACHE_CHECK(for V8 version, ac_cv_v8_version, [
|
2018-07-21 01:03:40 +00:00
|
|
|
AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <v8.h>
|
2012-04-27 16:26:15 +00:00
|
|
|
#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;
|
2018-07-21 01:03:40 +00:00
|
|
|
}]])],[ac_cv_v8_version=`cat ./conftestval|awk '{print $1}'`],[ac_cv_v8_version=NONE],[ac_cv_v8_version=NONE])
|
2012-04-27 16:26:15 +00:00
|
|
|
])
|
|
|
|
|
|
|
|
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`
|
2022-05-31 10:28:24 +00:00
|
|
|
if test "$V8_API_VERSION" -lt 9000000 ; then
|
|
|
|
AC_MSG_ERROR([libv8 must be version 9.0 or greater])
|
2018-01-07 11:43:20 +00:00
|
|
|
fi
|
2012-04-27 16:26:15 +00:00
|
|
|
AC_DEFINE_UNQUOTED([PHP_V8_API_VERSION], $V8_API_VERSION, [ ])
|
|
|
|
AC_DEFINE_UNQUOTED([PHP_V8_VERSION], "$ac_cv_v8_version", [ ])
|
2013-10-03 21:59:27 +00:00
|
|
|
else
|
|
|
|
AC_MSG_ERROR([could not determine libv8 version])
|
2012-04-27 16:26:15 +00:00
|
|
|
fi
|
2013-10-12 05:07:34 +00:00
|
|
|
|
2016-05-11 14:50:37 +00:00
|
|
|
|
2016-12-05 16:28:59 +00:00
|
|
|
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
|
|
|
|
|
2024-09-07 14:05:07 +00:00
|
|
|
for i in "$V8_LIBRARY_DIR" "$V8_INCLUDE_DIR/../share/v8"; do
|
2016-12-05 16:28:59 +00:00
|
|
|
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
|
2016-05-11 14:50:37 +00:00
|
|
|
fi
|
2016-12-05 16:28:59 +00:00
|
|
|
done
|
2016-05-11 14:50:37 +00:00
|
|
|
|
2016-12-05 16:28:59 +00:00
|
|
|
if test "$blob_found" -ne 1; then
|
|
|
|
AC_MSG_RESULT([not found])
|
|
|
|
fi
|
2016-05-11 14:50:37 +00:00
|
|
|
])
|
2016-12-05 16:28:59 +00:00
|
|
|
V8_SEARCH_BLOB([natives_blob.bin], [PHP_V8_NATIVES_BLOB_PATH])
|
|
|
|
V8_SEARCH_BLOB([snapshot_blob.bin], [PHP_V8_SNAPSHOT_BLOB_PATH])
|
|
|
|
|
2013-10-12 18:44:15 +00:00
|
|
|
|
2022-06-27 16:00:49 +00:00
|
|
|
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
|
|
|
|
|
2017-05-29 19:41:07 +00:00
|
|
|
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
|
|
|
|
|
2018-07-21 02:48:23 +00:00
|
|
|
AC_LANG_POP([C++])
|
2016-02-28 18:52:46 +00:00
|
|
|
LIBS=$old_LIBS
|
2016-12-05 16:28:59 +00:00
|
|
|
LDFLAGS="$old_LDFLAGS"
|
2016-02-28 18:52:46 +00:00
|
|
|
CPPFLAGS=$old_CPPFLAGS
|
|
|
|
|
2017-04-23 20:49:15 +00:00
|
|
|
AC_DEFINE([V8_DEPRECATION_WARNINGS], [1], [Enable compiler warnings when using V8_DEPRECATED apis.])
|
|
|
|
|
2024-09-07 14:05:07 +00:00
|
|
|
PHP_ADD_INCLUDE($V8_INCLUDE_DIR)
|
2014-12-12 22:59:28 +00:00
|
|
|
PHP_NEW_EXTENSION(v8js, [ \
|
|
|
|
v8js_array_access.cc \
|
|
|
|
v8js_class.cc \
|
|
|
|
v8js_commonjs.cc \
|
|
|
|
v8js_convert.cc \
|
|
|
|
v8js_exceptions.cc \
|
2016-01-09 11:50:40 +00:00
|
|
|
v8js_generator_export.cc \
|
2017-03-12 16:26:39 +00:00
|
|
|
v8js_main.cc \
|
2014-12-12 22:59:28 +00:00
|
|
|
v8js_methods.cc \
|
|
|
|
v8js_object_export.cc \
|
|
|
|
v8js_timer.cc \
|
|
|
|
v8js_v8.cc \
|
|
|
|
v8js_v8object_class.cc \
|
|
|
|
v8js_variables.cc \
|
2015-07-25 19:36:34 +00:00
|
|
|
], $ext_shared, , "$ac_cv_v8_narrowing -std="$ac_cv_v8_cstd)
|
2012-04-27 16:26:15 +00:00
|
|
|
|
|
|
|
PHP_ADD_MAKEFILE_FRAGMENT
|
|
|
|
fi
|
2016-01-09 11:50:40 +00:00
|
|
|
|
|
|
|
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
|