config.m4 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. PHP_ARG_WITH(v8js, for V8 Javascript Engine,
  2. [ --with-v8js Include V8 JavaScript Engine])
  3. if test "$PHP_V8JS" != "no"; then
  4. SEARCH_PATH="/usr/local /usr"
  5. SEARCH_FOR="include/v8.h"
  6. if test -r $PHP_V8JS/$SEARCH_FOR; then
  7. case $host_os in
  8. darwin* )
  9. # MacOS does not support --rpath
  10. ;;
  11. * )
  12. LDFLAGS="$LDFLAGS -Wl,--rpath=$PHP_V8JS/$PHP_LIBDIR"
  13. ;;
  14. esac
  15. V8_DIR=$PHP_V8JS
  16. else
  17. AC_MSG_CHECKING([for V8 files in default path])
  18. for i in $SEARCH_PATH ; do
  19. if test -r $i/$SEARCH_FOR; then
  20. V8_DIR=$i
  21. AC_MSG_RESULT(found in $i)
  22. fi
  23. done
  24. fi
  25. if test -z "$V8_DIR"; then
  26. AC_MSG_RESULT([not found])
  27. AC_MSG_ERROR([Please reinstall the v8 distribution])
  28. fi
  29. PHP_ADD_INCLUDE($V8_DIR/include)
  30. PHP_ADD_LIBRARY_WITH_PATH(v8, $V8_DIR/$PHP_LIBDIR, V8JS_SHARED_LIBADD)
  31. PHP_SUBST(V8JS_SHARED_LIBADD)
  32. PHP_REQUIRE_CXX()
  33. old_LIBS=$LIBS
  34. old_LDFLAGS=$LDFLAGS
  35. old_CPPFLAGS=$CPPFLAGS
  36. case $host_os in
  37. darwin* )
  38. # MacOS does not support --rpath
  39. LDFLAGS="-L$V8_DIR/$PHP_LIBDIR"
  40. ;;
  41. * )
  42. LDFLAGS="-Wl,--rpath=$V8_DIR/$PHP_LIBDIR -L$V8_DIR/$PHP_LIBDIR"
  43. ;;
  44. esac
  45. LIBS=-lv8
  46. CPPFLAGS=-I$V8_DIR/include
  47. AC_LANG_SAVE
  48. AC_LANG_CPLUSPLUS
  49. AC_CACHE_CHECK(for V8 version, ac_cv_v8_version, [
  50. AC_TRY_RUN([#include <v8.h>
  51. #include <iostream>
  52. #include <fstream>
  53. using namespace std;
  54. int main ()
  55. {
  56. ofstream testfile ("conftestval");
  57. if (testfile.is_open()) {
  58. testfile << v8::V8::GetVersion();
  59. testfile << "\n";
  60. testfile.close();
  61. return 0;
  62. }
  63. return 1;
  64. }], [ac_cv_v8_version=`cat ./conftestval|awk '{print $1}'`], [ac_cv_v8_version=NONE], [ac_cv_v8_version=NONE])
  65. ])
  66. if test "$ac_cv_v8_version" != "NONE"; then
  67. ac_IFS=$IFS
  68. IFS=.
  69. set $ac_cv_v8_version
  70. IFS=$ac_IFS
  71. V8_API_VERSION=`expr [$]1 \* 1000000 + [$]2 \* 1000 + [$]3`
  72. if test "$V8_API_VERSION" -lt 3021012 ; then
  73. AC_MSG_ERROR([libv8 must be version 3.21.12 or greater])
  74. fi
  75. AC_DEFINE_UNQUOTED([PHP_V8_API_VERSION], $V8_API_VERSION, [ ])
  76. AC_DEFINE_UNQUOTED([PHP_V8_VERSION], "$ac_cv_v8_version", [ ])
  77. else
  78. AC_MSG_ERROR([could not determine libv8 version])
  79. fi
  80. AC_CACHE_CHECK(for debuggersupport in v8, ac_cv_v8_debuggersupport, [
  81. AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <v8-debug.h>]],
  82. [[v8::Debug::DisableAgent()]])],
  83. [ac_cv_v8_debuggersupport=yes],
  84. [ac_cv_v8_debuggersupport=no])
  85. ])
  86. if test "$ac_cv_v8_debuggersupport" = "yes"; then
  87. AC_DEFINE([ENABLE_DEBUGGER_SUPPORT], [1], [Enable debugger support in V8Js])
  88. fi
  89. AC_LANG_RESTORE
  90. LIBS=$old_LIBS
  91. LDFLAGS=$old_LDFLAGS
  92. CPPFLAGS=$old_CPPFLAGS
  93. if test "$V8_API_VERSION" -ge 3029036 ; then
  94. dnl building for v8 3.29.36 or later, which requires us to
  95. dnl initialize and provide a platform; hence we need to
  96. dnl link in libplatform to make our life easier.
  97. PHP_ADD_INCLUDE($V8_DIR)
  98. case $host_os in
  99. darwin* )
  100. static_link_extra="libv8_libplatform.a libv8_libbase.a"
  101. ;;
  102. * )
  103. static_link_extra="libv8_libplatform.a"
  104. ;;
  105. esac
  106. for static_link_extra_file in $static_link_extra; do
  107. AC_MSG_CHECKING([for $static_link_extra_file])
  108. for i in $PHP_V8JS $SEARCH_PATH ; do
  109. if test -r $i/lib/$static_link_extra_file; then
  110. static_link_dir=$i
  111. AC_MSG_RESULT(found in $i)
  112. fi
  113. done
  114. if test -z "$static_link_dir"; then
  115. AC_MSG_RESULT([not found])
  116. AC_MSG_ERROR([Please provide $static_link_extra_file next to the libv8.so, see README.md for details])
  117. fi
  118. LDFLAGS="$LDFLAGS $static_link_dir/lib/$static_link_extra_file"
  119. done
  120. fi
  121. AC_CACHE_CHECK(for C standard version, ac_cv_v8_cstd, [
  122. ac_cv_v8_cstd="c++11"
  123. old_CPPFLAGS=$CPPFLAGS
  124. AC_LANG_PUSH([C++])
  125. CPPFLAGS="-std="$ac_cv_v8_cstd
  126. AC_TRY_RUN([int main() { return 0; }],[],[ac_cv_v8_cstd="c++0x"],[])
  127. AC_LANG_POP([C++])
  128. CPPFLAGS=$old_CPPFLAGS
  129. ]);
  130. PHP_NEW_EXTENSION(v8js, [ \
  131. v8js_array_access.cc \
  132. v8js.cc \
  133. v8js_class.cc \
  134. v8js_commonjs.cc \
  135. v8js_convert.cc \
  136. v8js_exceptions.cc \
  137. v8js_methods.cc \
  138. v8js_object_export.cc \
  139. v8js_timer.cc \
  140. v8js_v8.cc \
  141. v8js_v8object_class.cc \
  142. v8js_variables.cc \
  143. ], $ext_shared, , "-std="$ac_cv_v8_cstd)
  144. PHP_ADD_MAKEFILE_FRAGMENT
  145. fi