0
0
mirror of https://github.com/phpv8/v8js.git synced 2024-12-22 18:41:52 +00:00
phpv8/config.m4
C. Scott Ananian 1f2eefdbea Support compiling v8js with v8 in a custom path.
If you don't want to overwrite the system copy of v8 in /usr/lib/libv8.so,
you can use the --with-v8=<path> option to have php-v8js use its own
copy of libv8.
2013-10-01 18:05:36 -04:00

82 lines
2.1 KiB
Plaintext

dnl $Id$
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"
SEARCH_FOR="include/v8.h"
if test -r $PHP_V8JS/$SEARCH_FOR; then
LDFLAGS="$LDFLAGS -Wl,--rpath=$PHP_V8JS/$PHP_LIBDIR"
V8_DIR=$PHP_V8JS
else
AC_MSG_CHECKING([for V8 files in default path])
for i in $SEARCH_PATH ; do
if test -r $i/$SEARCH_FOR; then
V8_DIR=$i
AC_MSG_RESULT(found in $i)
fi
done
fi
if test -z "$V8_DIR"; then
AC_MSG_RESULT([not found])
AC_MSG_ERROR([Please reinstall the v8 distribution])
fi
PHP_ADD_INCLUDE($V8_DIR/include)
PHP_ADD_LIBRARY_WITH_PATH(v8, $V8_DIR/$PHP_LIBDIR, V8JS_SHARED_LIBADD)
PHP_SUBST(V8JS_SHARED_LIBADD)
PHP_REQUIRE_CXX()
AC_CACHE_CHECK(for V8 version, ac_cv_v8_version, [
old_LIBS=$LIBS
old_LDFLAGS=$LDFLAGS
old_CPPFLAGS=$CPPFLAGS
LDFLAGS="-Wl,--rpath=$V8_DIR/$PHP_LIBDIR -L$V8_DIR/$PHP_LIBDIR"
LIBS=-lv8
CPPFLAGS=-I$V8_DIR/include
AC_LANG_SAVE
AC_LANG_CPLUSPLUS
AC_TRY_RUN([#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])
AC_LANG_RESTORE
LIBS=$old_LIBS
LDFLAGS=$old_LDFLAGS
CPPFLAGS=$old_CPPFLAGS
])
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 3017011 ; then
# see https://github.com/preillyme/v8js/issues/12
AC_MSG_ERROR([libv8 must be version 3.17.11 or greater])
fi
AC_DEFINE_UNQUOTED([PHP_V8_API_VERSION], $V8_API_VERSION, [ ])
AC_DEFINE_UNQUOTED([PHP_V8_VERSION], "$ac_cv_v8_version", [ ])
fi
PHP_NEW_EXTENSION(v8js, v8js.cc v8js_convert.cc v8js_methods.cc v8js_variables.cc v8js_commonjs.cc, $ext_shared, , "-std=c++11")
PHP_ADD_MAKEFILE_FRAGMENT
fi