Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check for libnode (additional/instead of libv8) #537

Merged
merged 1 commit into from
Sep 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
122 changes: 66 additions & 56 deletions config.m4
Original file line number Diff line number Diff line change
Expand Up @@ -3,46 +3,53 @@ PHP_ARG_WITH(v8js, for V8 Javascript Engine,

if test "$PHP_V8JS" != "no"; then
SEARCH_PATH="/usr/local /usr"
SEARCH_FOR="libv8.$SHLIB_SUFFIX_NAME"

if test -d "$PHP_V8JS"; then
SEARCH_PATH="$PHP_V8JS"

# set rpath, so library loader picks up libv8 even if it's not on the
# system's library search path
case $host_os in
darwin* )
# MacOS does not support --rpath
;;
* )
LDFLAGS="$LDFLAGS -Wl,--rpath=$PHP_V8JS/$PHP_LIBDIR"
;;
esac
fi

AC_MSG_CHECKING([for V8 files in default path])
ARCH=$(uname -m)

for i in $SEARCH_PATH ; do
if test -r "$i/$PHP_LIBDIR/$SEARCH_FOR" -a -r "$i/include/v8/v8.h"; then
V8_INCLUDE_DIR="$i/include/v8"
V8_LIBRARY_DIR="$i/$PHP_LIBDIR"
AC_MSG_RESULT(found in $i)
fi

# Debian installations
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)
for libname in v8 node; do
SEARCH_FOR="lib$libname.$SHLIB_SUFFIX_NAME"

if test -d "$PHP_V8JS"; then
SEARCH_PATH="$PHP_V8JS"

# set rpath, so library loader picks up libv8 even if it's not on the
# system's library search path
case $host_os in
darwin* )
# MacOS does not support --rpath
;;
* )
LDFLAGS="$LDFLAGS -Wl,--rpath=$PHP_V8JS/$PHP_LIBDIR"
;;
esac
fi

# Manual installations
if test -r "$i/$PHP_LIBDIR/$SEARCH_FOR" -a -r "$i/include/libplatform/libplatform.h"; then
V8_INCLUDE_DIR="$i/include"
V8_LIBRARY_DIR="$i/$PHP_LIBDIR"
AC_MSG_RESULT(found in $i)
fi
AC_MSG_CHECKING([for V8 files in default path])
ARCH=$(uname -m)

for i in $SEARCH_PATH ; do
echo checking "$i/$PHP_LIBDIR/$SEARCH_FOR" -a -r "$i/include/$libname/v8.h"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are no other echos here. Is this a remaining debug snippet or is it seen helpful for the overall output of the script?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, that shouldn't actually go there...

if test -r "$i/$PHP_LIBDIR/$SEARCH_FOR" -a -r "$i/include/$libname/v8.h"; then
V8_INCLUDE_DIR="$i/include/$libname"
V8_LIBRARY_DIR="$i/$PHP_LIBDIR"
AC_MSG_RESULT(found in $i)
break 2
fi

# Debian installations
if test -r "$i/$PHP_LIBDIR/$ARCH-linux-gnu/$SEARCH_FOR"; then
V8_INCLUDE_DIR="$i/include/$libname"
V8_LIBRARY_DIR="$i/$PHP_LIBDIR/$ARCH-linux-gnu"
AC_MSG_RESULT(found in $i)
break 2
fi

# Manual installations
if test -r "$i/$PHP_LIBDIR/$SEARCH_FOR" -a -r "$i/include/libplatform/libplatform.h"; then
V8_INCLUDE_DIR="$i/include"
V8_LIBRARY_DIR="$i/$PHP_LIBDIR"
AC_MSG_RESULT(found in $i)
break 2
fi
done
done

AC_DEFINE_UNQUOTED([PHP_V8_EXEC_PATH], "$V8_LIBRARY_DIR/$SEARCH_FOR", [Full path to libv8 library file])
Expand All @@ -53,8 +60,9 @@ if test "$PHP_V8JS" != "no"; then
fi

PHP_ADD_INCLUDE($V8_INCLUDE_DIR)
PHP_ADD_LIBRARY_WITH_PATH(v8, $V8_LIBRARY_DIR, V8JS_SHARED_LIBADD)
PHP_ADD_LIBRARY_WITH_PATH($libname, $V8_LIBRARY_DIR, V8JS_SHARED_LIBADD)
PHP_SUBST(V8JS_SHARED_LIBADD)

PHP_REQUIRE_CXX()


Expand Down Expand Up @@ -112,26 +120,28 @@ if test "$PHP_V8JS" != "no"; then
CPPFLAGS="$CPPFLAGS -I$V8_INCLUDE_DIR -std=$ac_cv_v8_cstd"
LDFLAGS="$LDFLAGS -L$V8_LIBRARY_DIR"

AC_MSG_CHECKING([for libv8_libplatform])
AC_DEFUN([V8_CHECK_LINK], [
save_LIBS="$LIBS"
LIBS="$LIBS $1 -lv8_libplatform -lv8"
AC_LINK_IFELSE([AC_LANG_PROGRAM([
#include <libplatform/libplatform.h>
], [ v8::platform::NewDefaultPlatform(); ])], [
dnl libv8_libplatform.so found
AC_MSG_RESULT(found)
V8JS_SHARED_LIBADD="$1 -lv8_libplatform $V8JS_SHARED_LIBADD"
$3
], [ $4 ])
LIBS="$save_LIBS"
])
if test "$libname" = "v8"; then
AC_MSG_CHECKING([for libv8_libplatform])
AC_DEFUN([V8_CHECK_LINK], [
save_LIBS="$LIBS"
LIBS="$LIBS $1 -lv8_libplatform -lv8"
AC_LINK_IFELSE([AC_LANG_PROGRAM([
#include <libplatform/libplatform.h>
], [ v8::platform::NewDefaultPlatform(); ])], [
dnl libv8_libplatform.so found
AC_MSG_RESULT(found)
V8JS_SHARED_LIBADD="$1 -lv8_libplatform $V8JS_SHARED_LIBADD"
$3
], [ $4 ])
LIBS="$save_LIBS"
])

V8_CHECK_LINK([], [], [], [
V8_CHECK_LINK([-lv8_libbase], [], [], [
AC_MSG_ERROR([could not find libv8_libplatform library])
V8_CHECK_LINK([], [], [], [
V8_CHECK_LINK([-lv8_libbase], [], [], [
AC_MSG_ERROR([could not find libv8_libplatform library])
])
])
])
fi


dnl
Expand Down