Skip to content
This repository was archived by the owner on Mar 29, 2024. It is now read-only.

Commit 2b5ecaa

Browse files
committed
Simplify build system
1 parent 0ba3ba9 commit 2b5ecaa

File tree

3 files changed

+49
-67
lines changed

3 files changed

+49
-67
lines changed

config.m4

Lines changed: 46 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -18,53 +18,39 @@ if test "$PHP_V8" != "no"; then
1818
SEARCH_PATH="${PRIORITY_SEARCH_PATH} /usr/local /usr"
1919

2020
if test -r $PHP_V8/$SEARCH_FOR; then
21-
case $host_os in
22-
darwin* )
23-
# MacOS does not support --rpath
24-
;;
25-
* )
26-
LDFLAGS="$LDFLAGS -Wl,--rpath=$PHP_V8/$PHP_LIBDIR"
27-
;;
28-
esac
29-
V8_LIB_DIR=$PHP_V8/$PHP_LIBDIR
30-
V8_INCLUDE_DIR=$PHP_V8/include
21+
V8_ROOT_DIR=$PHP_V8
3122
else
3223
AC_MSG_CHECKING([for V8 files in default path])
3324
for i in $SEARCH_PATH ; do
3425
if test -r $i/$SEARCH_FOR; then
3526
AC_MSG_RESULT(found in $i)
36-
V8_LIB_DIR=$i/$PHP_LIBDIR
37-
V8_INCLUDE_DIR=$i/include
27+
V8_ROOT_DIR=$i
28+
break
3829
fi
3930
done
4031
fi
4132

42-
if test -z "$V8_LIB_DIR"; then
33+
if test -z "$V8_ROOT_DIR"; then
4334
AC_MSG_RESULT([not found])
4435
AC_MSG_ERROR([Please reinstall the v8 distribution or provide valid path to it])
4536
fi
4637

47-
AC_DEFINE_UNQUOTED([PHP_V8_LIB_DIR], ["$V8_LIB_DIR/"], [Root directory with libraries (and icu data file)])
38+
V8_LIB_DIR=$V8_ROOT_DIR/$PHP_LIBDIR
39+
V8_INCLUDE_DIR=$V8_ROOT_DIR/include
4840

49-
PHP_ADD_INCLUDE($V8_INCLUDE_DIR)
50-
PHP_ADD_LIBRARY_WITH_PATH(v8, $V8_LIB_DIR, V8_SHARED_LIBADD)
51-
PHP_SUBST(V8_SHARED_LIBADD)
52-
PHP_REQUIRE_CXX()
41+
AC_MSG_CHECKING([for ICU data file icudtl.dat])
5342

54-
AC_CACHE_CHECK(for C standard version, ac_cv_v8_cstd, [
55-
ac_cv_v8_cstd="c++11"
56-
old_CPPFLAGS=$CPPFLAGS
57-
AC_LANG_PUSH([C++])
58-
CPPFLAGS="-std="$ac_cv_v8_cstd
59-
AC_TRY_RUN([int main() { return 0; }],[],[ac_cv_v8_cstd="c++0x"],[])
60-
AC_LANG_POP([C++])
61-
CPPFLAGS=$old_CPPFLAGS
62-
]);
43+
if test -r "$V8_LIB_DIR/icudtl.dat"; then
44+
PHP_V8_ICU_DATA_DIR="$V8_LIB_DIR/" # trailing slash is required
45+
AC_MSG_RESULT(found in $PHP_V8_ICU_DATA_DIR)
46+
fi
6347

48+
if test -z "PHP_V8_ICU_DATA_DIR"; then
49+
AC_MSG_RESULT([not found])
50+
AC_MSG_ERROR([ICU data file icudtl.dat not found])
51+
fi
6452

65-
old_LIBS=$LIBS
66-
old_LDFLAGS=$LDFLAGS
67-
old_CPPFLAGS=$CPPFLAGS
53+
AC_DEFINE_UNQUOTED([PHP_V8_ICU_DATA_DIR], ["$PHP_V8_ICU_DATA_DIR"], [ICU data path (trailing slash is required)])
6854

6955
case $host_os in
7056
darwin* )
@@ -76,35 +62,24 @@ if test "$PHP_V8" != "no"; then
7662
;;
7763
esac
7864

79-
PHP_ADD_INCLUDE($V8_DIR)
65+
AC_CACHE_CHECK(for V8 version, ac_cv_v8_version, [
66+
if test -z "$V8_INCLUDE_DIR/v8-version.h"; then
67+
AC_MSG_RESULT([not found])
68+
AC_MSG_ERROR([Please reinstall the v8 distribution or provide valid path to it])
69+
fi
8070
81-
LDFLAGS="$LDFLAGS -lv8_libbase -lv8_libplatform"
82-
LIBS="-lv8 -lv8_libbase -lv8_libplatform"
83-
CPPFLAGS="-I$V8_INCLUDE_DIR -std=$ac_cv_v8_cstd"
84-
AC_LANG_SAVE
85-
AC_LANG_CPLUSPLUS
71+
major=`cat $V8_INCLUDE_DIR/v8-version.h | grep V8_MAJOR_VERSION | awk '{print $3}'`
72+
minor=`cat $V8_INCLUDE_DIR/v8-version.h | grep V8_MINOR_VERSION | awk '{print $3}'`
73+
build=`cat $V8_INCLUDE_DIR/v8-version.h | grep V8_BUILD_NUMBER | awk '{print $3}'`
74+
patch=`cat $V8_INCLUDE_DIR/v8-version.h | grep V8_PATCH_LEVEL | awk '{print $3}'`
75+
candidate=`cat $V8_INCLUDE_DIR/v8-version.h | grep V8_IS_CANDIDATE_VERSION | awk '{print $3}'`
8676
77+
version="$major.$minor.$build"
8778
88-
# NOTE: it is possible to get version string from headers with simple regexp match
89-
AC_CACHE_CHECK(for V8 version, ac_cv_v8_version, [
90-
AC_TRY_RUN([
91-
#include <v8.h>
92-
#include <iostream>
93-
#include <fstream>
94-
using namespace std;
95-
96-
int main ()
97-
{
98-
ofstream testfile ("conftestval");
99-
if (testfile.is_open()) {
100-
testfile << v8::V8::GetVersion();
101-
testfile << "\n";
102-
testfile.close();
103-
return 0;
104-
}
105-
return 1;
106-
}
107-
], [ac_cv_v8_version=`cat ./conftestval|awk '{print $1}'`], [ac_cv_v8_version=NONE], [ac_cv_v8_version=NONE])
79+
if test $patch -gt 0; then version="$version.$patch"; fi
80+
if test $candidate -gt 0; then version="$version (candidate)"; fi
81+
82+
ac_cv_v8_version=$version
10883
])
10984

11085
V8_MIN_API_VERSION_NUM=`echo "${V8_MIN_API_VERSION_STR}" | $AWK 'BEGIN { FS = "."; } { printf "%d", [$]1 * 1000000 + [$]2 * 1000 + [$]3;}'`
@@ -121,23 +96,30 @@ if test "$PHP_V8" != "no"; then
12196
AC_MSG_ERROR([could not determine libv8 version])
12297
fi
12398

99+
PHP_ADD_INCLUDE($V8_DIR)
100+
PHP_ADD_INCLUDE($V8_INCLUDE_DIR)
101+
102+
PHP_ADD_LIBRARY_WITH_PATH(v8, $V8_LIB_DIR, V8_SHARED_LIBADD)
103+
PHP_ADD_LIBRARY_WITH_PATH(v8_libbase, $V8_LIB_DIR, V8_SHARED_LIBADD)
104+
PHP_ADD_LIBRARY_WITH_PATH(v8_libplatform, $V8_LIB_DIR, V8_SHARED_LIBADD)
105+
106+
PHP_SUBST(V8_SHARED_LIBADD)
107+
PHP_REQUIRE_CXX()
108+
109+
CPPFLAGS="$CPPFLAGS -std=c++11"
110+
124111
# On OS X clang reports warnings in zeng_strings.h, like
125112
# php/Zend/zend_string.h:326:2: warning: 'register' storage class specifier is deprecated [-Wdeprecated-register]
126113
# also
127114
# php/Zend/zend_operators.h:128:18: warning: 'finite' is deprecated: first deprecated in macOS 10.9 [-Wdeprecated-declarations]
128115
# but as we want to track also deprecated methods from v8 we won't ignore -Wdeprecated-declarations warnings
129116
# We want to make building log cleaner, so let's suppress only -Wdeprecated-register warning
130-
PHP_V8_COMPILER_OPTIONS="-Wno-deprecated-register -Wno-unicode"
131-
#PHP_V8_COMPILER_OPTIONS="-Wno-deprecated-register -Wno-deprecated-declarations"
117+
CPPFLAGS="$CPPFLAGS -Wno-deprecated-register -Wno-unicode"
118+
#CPPFLAGS="$CPPFLAGS -Wno-deprecated-declarations"
132119

133120
AC_DEFINE([V8_DEPRECATION_WARNINGS], [1], [Enable compiler warnings when using V8_DEPRECATED apis.])
134121
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.])
135122

136-
AC_LANG_RESTORE
137-
LIBS=$old_LIBS
138-
#LDFLAGS=$old_LDFLAGS # we have to links some libraries
139-
CPPFLAGS=$old_CPPFLAGS
140-
141123
if test -z "$TRAVIS" ; then
142124
type git &>/dev/null
143125

@@ -221,7 +203,7 @@ if test "$PHP_V8" != "no"; then
221203
src/php_v8_named_property_handler_configuration.cc \
222204
src/php_v8_indexed_property_handler_configuration.cc \
223205
src/php_v8_access_type.cc \
224-
], $ext_shared, , "$PHP_V8_COMPILER_OPTIONS -std="$ac_cv_v8_cstd -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1)
206+
], $ext_shared, , -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1)
225207

226208
PHP_ADD_BUILD_DIR($ext_builddir/src)
227209

php_v8.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ extern "C" {
2929
extern zend_module_entry php_v8_module_entry;
3030
#define phpext_v8_ptr &php_v8_module_entry
3131

32-
#ifndef PHP_V8_LIB_DIR
33-
#define PHP_V8_LIB_DIR NULL
32+
#ifndef PHP_V8_ICU_DATA_DIR
33+
#define PHP_V8_ICU_DATA_DIR NULL
3434
#endif
3535

3636
#ifndef PHP_V8_VERSION

src/php_v8_a.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ void php_v8_init()
2727
return;
2828
}
2929

30-
v8::V8::InitializeICUDefaultLocation(PHP_V8_LIB_DIR);
30+
v8::V8::InitializeICUDefaultLocation(PHP_V8_ICU_DATA_DIR);
3131

3232
// NOTE: if we use snapshot and extenal startup data then we have to initialize it (see https://codereview.chromium.org/315033002/)
3333
// v8::V8::InitializeExternalStartupData(NULL);

0 commit comments

Comments
 (0)