@@ -2,9 +2,19 @@ PHP_ARG_WITH(v8, for V8 Javascript Engine,
22[ --with-v8 Include V8 JavaScript Engine] )
33
44if test "$PHP_V8" != "no"; then
5+ V8_LIB_DIR=""
6+ V8_INCLUDE_DIR=""
7+
58 SEARCH_PATH="/usr/local /usr"
69 SEARCH_FOR="include/v8.h"
710
11+ DESIRED_V8_VERSION=5.7
12+
13+ # Path where v8 from packages we recommend are installed, it's /opt/libv8-MAJOR.MINOR on Ubuntu
14+ # and /usr/local/opt/v8@MAJOR.MINOR on macOS
15+ PRIORITY_SEARCH_PATH="/opt/libv8-${DESIRED_V8_VERSION} /usr/local/opt/v8@${DESIRED_V8_VERSION}"
16+ SEARCH_PATH="${PRIORITY_SEARCH_PATH} /usr/local /usr"
17+
818 if test -r $PHP_V8/$SEARCH_FOR; then
919 case $host_os in
1020 darwin* )
@@ -14,28 +24,31 @@ if test "$PHP_V8" != "no"; then
1424 LDFLAGS="$LDFLAGS -Wl,--rpath=$PHP_V8/$PHP_LIBDIR"
1525 ;;
1626 esac
17- V8_DIR=$PHP_V8
27+ V8_LIB_DIR=$PHP_V8/$PHP_LIBDIR
28+ V8_INCLUDE_DIR=$PHP_V8/include
1829 else
1930 AC_MSG_CHECKING ( [ for V8 files in default path] )
2031 for i in $SEARCH_PATH ; do
2132 if test -r $i/$SEARCH_FOR; then
22- V8_DIR=$i
2333 AC_MSG_RESULT ( found in $i )
34+ V8_LIB_DIR=$i/$PHP_LIBDIR
35+ V8_INCLUDE_DIR=$i/include
2436 fi
2537 done
2638 fi
2739
28- if test -z "$V8_DIR "; then
40+ if test -z "$V8_LIB_DIR "; then
2941 AC_MSG_RESULT ( [ not found] )
30- AC_MSG_ERROR ( [ Please reinstall the v8 distribution] )
42+ AC_MSG_ERROR ( [ Please reinstall the v8 distribution or provide valid path to it ] )
3143 fi
3244
33- PHP_ADD_INCLUDE($V8_DIR/include)
34- PHP_ADD_LIBRARY_WITH_PATH(v8, $V8_DIR/$PHP_LIBDIR, V8_SHARED_LIBADD)
45+ AC_DEFINE_UNQUOTED ( [ PHP_V8_LIB_DIR] , [ "$V8_LIB_DIR/"] , [ Root directory with libraries (and icu data file)] )
46+
47+ PHP_ADD_INCLUDE($V8_INCLUDE_DIR)
48+ PHP_ADD_LIBRARY_WITH_PATH(v8, $V8_LIB_DIR, V8_SHARED_LIBADD)
3549 PHP_SUBST(V8_SHARED_LIBADD)
3650 PHP_REQUIRE_CXX()
3751
38-
3952 AC_CACHE_CHECK ( for C standard version , ac_cv_v8_cstd , [
4053 ac_cv_v8_cstd="c++11"
4154 old_CPPFLAGS=$CPPFLAGS
@@ -54,54 +67,22 @@ if test "$PHP_V8" != "no"; then
5467 case $host_os in
5568 darwin* )
5669 # MacOS does not support --rpath
57- LDFLAGS="-L$V8_DIR/$PHP_LIBDIR "
70+ LDFLAGS="-L$V8_LIB_DIR "
5871 ;;
5972 * )
60- LDFLAGS="-Wl,--rpath=$V8_DIR/$PHP_LIBDIR -L$V8_DIR/$PHP_LIBDIR "
73+ LDFLAGS="-Wl,--rpath=$V8_LIB_DIR -L$V8_LIB_DIR "
6174 ;;
6275 esac
6376
6477 PHP_ADD_INCLUDE($V8_DIR)
6578
66- case $host_os in
67- darwin* )
68- static_link_extra="libv8_libplatform.a libv8_libbase.a"
69- # static_link_extra="libv8_base.a libv8_libbase.a libv8_libplatform.a libv8_snapshot.a"
70- ;;
71- * )
72- static_link_extra="libv8_libplatform.a"
73- # static_link_extra="libv8_base.a libv8_libbase.a libv8_libplatform.a libv8_snapshot.a"
74- ;;
75- esac
76-
77- for static_link_extra_file in $static_link_extra; do
78- AC_MSG_CHECKING ( [ for $static_link_extra_file] )
79- static_link_dir=""
80-
81- for i in $PHP_V8 $SEARCH_PATH ; do
82- if test -r $i/lib64/$static_link_extra_file; then
83- static_link_dir=$i/lib64
84- AC_MSG_RESULT ( found in $i )
85- fi
86- if test -r $i/lib/$static_link_extra_file; then
87- static_link_dir=$i/lib
88- AC_MSG_RESULT ( found in $i )
89- fi
90- done
91-
92- if test -z "$static_link_dir"; then
93- AC_MSG_RESULT ( [ not found] )
94- AC_MSG_ERROR ( [ Please provide $static_link_extra_file next to the libv8.so] )
95- fi
96-
97- LDFLAGS="$LDFLAGS $static_link_dir/$static_link_extra_file"
98- done
99-
100- LIBS=-lv8
101- CPPFLAGS="-I$V8_DIR/include -std=$ac_cv_v8_cstd"
79+ LDFLAGS="$LDFLAGS -lv8_libbase -lv8_libplatform"
80+ LIBS="-lv8 -lv8_libbase -lv8_libplatform"
81+ CPPFLAGS="-I$V8_INCLUDE_DIR -std=$ac_cv_v8_cstd"
10282 AC_LANG_SAVE
10383 AC_LANG_CPLUSPLUS
10484
85+
10586 # NOTE: it is possible to get version string from headers with simple regexp match
10687 AC_CACHE_CHECK ( for V8 version , ac_cv_v8_version , [
10788 AC_TRY_RUN ( [
@@ -124,7 +105,7 @@ if test "$PHP_V8" != "no"; then
124105 ] , [ ac_cv_v8_version=`cat ./conftestval|awk '{print $1 }'`] , [ ac_cv_v8_version=NONE] , [ ac_cv_v8_version=NONE] )
125106 ] )
126107
127- V8_MIN_API_VERSION_STR=5.4.420
108+ V8_MIN_API_VERSION_STR=5.7.202
128109
129110 if test "$ac_cv_v8_version" != "NONE"; then
130111 ac_IFS=$IFS
@@ -147,15 +128,18 @@ if test "$PHP_V8" != "no"; then
147128
148129 # On OS X clang reports warnings in zeng_strings.h, like
149130 # php/Zend/zend_string.h:326:2: warning: 'register' storage class specifier is deprecated [-Wdeprecated-register]
150- # We want to make building log cleaner, so let's suppress this warning
131+ # also
132+ # php/Zend/zend_operators.h:128:18: warning: 'finite' is deprecated: first deprecated in macOS 10.9 [-Wdeprecated-declarations]
133+ # but as we want to track also deprecated methods from v8 we won't ignore -Wdeprecated-declarations warnings
134+ # We want to make building log cleaner, so let's suppress only -Wdeprecated-register warning
151135 ac_cv_suppress_register_warnings_flag="-Wno-deprecated-register"
136+ # ac_cv_suppress_register_warnings_flag="-Wno-deprecated-register -Wno-deprecated-declarations"
152137
153138 AC_DEFINE ( [ V8_DEPRECATION_WARNINGS] , [ 1] , [ Enable compiler warnings when using V8_DEPRECATED apis.] )
154139 AC_DEFINE ( [ V8_IMMINENT_DEPRECATION_WARNINGS] , [ 1] , [ Enable compiler warnings to make it easier to see what v8 apis will be deprecated (V8_DEPRECATED) soon.] )
155140
156141 AC_LANG_RESTORE
157- LIBS=$old_LIBS
158- # LDFLAGS=$old_LDFLAGS # we have to links some static libraries
142+ # LDFLAGS=$old_LDFLAGS # we have to links some libraries
159143 CPPFLAGS=$old_CPPFLAGS
160144
161145 if test -z "$TRAVIS" ; then
0 commit comments