-
Notifications
You must be signed in to change notification settings - Fork 208
PHPC-759: Ensure that the driver can be compiled as a built-in PHP extension #830
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
Changes from all commits
94d8c77
62894c1
d01b08b
7d1de0d
dd36d74
4500d8d
c0fc8dd
746f92e
62bb969
e1827ed
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,12 +5,23 @@ PHP_ARG_ENABLE([mongodb], | |
[Enable MongoDB support])]) | ||
|
||
if test "$PHP_MONGODB" != "no"; then | ||
AC_MSG_CHECKING([Check for supported PHP versions]) | ||
PHP_MONGODB_FOUND_VERSION=`${PHP_CONFIG} --version` | ||
PHP_MONGODB_FOUND_VERNUM=`echo "${PHP_MONGODB_FOUND_VERSION}" | $AWK 'BEGIN { FS = "."; } { printf "%d", ([$]1 * 100 + [$]2) * 100 + [$]3;}'` | ||
AC_MSG_RESULT($PHP_MONGODB_FOUND_VERSION) | ||
if test "$PHP_MONGODB_FOUND_VERNUM" -lt "50500"; then | ||
AC_MSG_ERROR([not supported. Need a PHP version >= 5.5.0 (found $PHP_MONGODB_FOUND_VERSION)]) | ||
dnl Check PHP version is compatible with this extension | ||
AC_MSG_CHECKING([PHP version]) | ||
|
||
PHP_MONGODB_PHP_VERSION=$PHP_VERSION | ||
PHP_MONGODB_PHP_VERSION_ID=$PHP_VERSION_ID | ||
|
||
if test -z "$PHP_MONGODB_PHP_VERSION"; then | ||
if test -z "$PHP_CONFIG"; then | ||
AC_MSG_ERROR([php-config not found]) | ||
fi | ||
PHP_MONGODB_PHP_VERSION=`${PHP_CONFIG} --version` | ||
PHP_MONGODB_PHP_VERSION_ID=`echo "${PHP_MONGODB_PHP_VERSION}" | $AWK 'BEGIN { FS = "."; } { printf "%d", ([$]1 * 100 + [$]2) * 100 + [$]3;}'` | ||
fi | ||
|
||
AC_MSG_RESULT($PHP_MONGODB_PHP_VERSION) | ||
if test "$PHP_MONGODB_PHP_VERSION_ID" -lt "50500"; then | ||
AC_MSG_ERROR([not supported. Need a PHP version >= 5.5.0 (found $PHP_MONGODB_PHP_VERSION)]) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we currently want a check to make sure it's also lower than 7.3? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think so. In the case of 7.3, we know there's a BC break for iteration that leads to a compile-time error, but jumping between earlier 7.x releases didn't require changes IIRC. I'm fine with that behavior. Similarly, we don't limit the libbson/libmongoc shared library versions with an upper bound -- provided they satisfy 1.0 ABI. I realize they're more strict about BC than PHP, but it's also possible that behaviors of some of the internal functions we use could change inadvertently :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK |
||
fi | ||
|
||
PHP_ARG_ENABLE([developer-flags], | ||
|
@@ -173,18 +184,18 @@ if test "$PHP_MONGODB" != "no"; then | |
AC_MSG_CHECKING(for libbson) | ||
if test -x "$PKG_CONFIG" && $PKG_CONFIG --exists libbson-1.0; then | ||
if $PKG_CONFIG libbson-1.0 --atleast-version 1.9.0; then | ||
LIBBSON_INC=`$PKG_CONFIG libbson-1.0 --cflags` | ||
LIBBSON_LIB=`$PKG_CONFIG libbson-1.0 --libs` | ||
LIBBSON_VER=`$PKG_CONFIG libbson-1.0 --modversion` | ||
AC_MSG_RESULT(version $LIBBSON_VER found) | ||
PHP_MONGODB_BSON_CFLAGS=`$PKG_CONFIG libbson-1.0 --cflags` | ||
PHP_MONGODB_BSON_LIBS=`$PKG_CONFIG libbson-1.0 --libs` | ||
PHP_MONGODB_BSON_VERSION=`$PKG_CONFIG libbson-1.0 --modversion` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These names were changed for consistency with other |
||
AC_MSG_RESULT(version $PHP_MONGODB_BSON_VERSION found) | ||
else | ||
AC_MSG_ERROR(system libbson must be upgraded to version >= 1.9.0) | ||
fi | ||
else | ||
AC_MSG_ERROR(pkgconfig and libbson must be installed) | ||
fi | ||
PHP_EVAL_INCLINE($LIBBSON_INC) | ||
PHP_EVAL_LIBLINE($LIBBSON_LIB, MONGODB_SHARED_LIBADD) | ||
PHP_MONGODB_CFLAGS="$PHP_MONGODB_CFLAGS $PHP_MONGODB_BSON_CFLAGS" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On the off chance that I do think it's OK to continue using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. AFAIK, PHP_EVAL_INCLINE also makes sure there are no duplicates - not sure if that could be a problem here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (Not important, if this is broken, people will tell us) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Nearly all of these instances obtain CFLAGS from One real exception is One other thought. There are more There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wouldn't worry about it then. I'd defer making a ticket until somebody notices it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Created PHPC-1190. |
||
PHP_EVAL_LIBLINE($PHP_MONGODB_BSON_LIBS, MONGODB_SHARED_LIBADD) | ||
AC_DEFINE(HAVE_SYSTEM_LIBBSON, 1, [Use system libbson]) | ||
fi | ||
|
||
|
@@ -197,52 +208,66 @@ if test "$PHP_MONGODB" != "no"; then | |
AC_MSG_CHECKING(for libmongoc) | ||
if test -x "$PKG_CONFIG" && $PKG_CONFIG --exists libmongoc-1.0; then | ||
if $PKG_CONFIG libmongoc-1.0 --atleast-version 1.9.0; then | ||
LIBMONGOC_INC=`$PKG_CONFIG libmongoc-1.0 --cflags` | ||
LIBMONGOC_LIB=`$PKG_CONFIG libmongoc-1.0 --libs` | ||
LIBMONGOC_VER=`$PKG_CONFIG libmongoc-1.0 --modversion` | ||
AC_MSG_RESULT(version $LIBMONGOC_VER found) | ||
|
||
PHP_MONGODB_MONGOC_CFLAGS=`$PKG_CONFIG libmongoc-1.0 --cflags` | ||
PHP_MONGODB_MONGOC_LIBS=`$PKG_CONFIG libmongoc-1.0 --libs` | ||
PHP_MONGODB_MONGOC_VERSION=`$PKG_CONFIG libmongoc-1.0 --modversion` | ||
AC_MSG_RESULT(version $PHP_MONGODB_MONGOC_VERSION found) | ||
else | ||
AC_MSG_ERROR(system libmongoc must be upgraded to version >= 1.9.0) | ||
fi | ||
else | ||
AC_MSG_ERROR(pkgconfig and libmongoc must be installed) | ||
fi | ||
PHP_EVAL_INCLINE($LIBMONGOC_INC) | ||
PHP_EVAL_LIBLINE($LIBMONGOC_LIB, MONGODB_SHARED_LIBADD) | ||
PHP_MONGODB_CFLAGS="$PHP_MONGODB_CFLAGS $PHP_MONGODB_MONGOC_CFLAGS" | ||
PHP_EVAL_LIBLINE($PHP_MONGODB_MONGOC_LIBS, MONGODB_SHARED_LIBADD) | ||
AC_DEFINE(HAVE_SYSTEM_LIBMONGOC, 1, [Use system libmongoc]) | ||
fi | ||
|
||
if test "$PHP_LIBBSON" = "no" -a "$PHP_LIBMONGOC" = "no"; then | ||
PHP_MONGODB_BSON_CFLAGS="$STD_CFLAGS -DBSON_COMPILATION" | ||
PHP_MONGODB_MONGOC_CFLAGS="$STD_CFLAGS -DMONGOC_COMPILATION -DMONGOC_TRACE" | ||
|
||
dnl M4 doesn't know if we're building statically or as a shared module, so | ||
dnl attempt to include both paths while ignoring errors. If neither path | ||
dnl exists, report an error during configure (this is later than M4 parsing | ||
dnl during phpize but better than nothing). | ||
m4_pushdef([_include],[ | ||
if test ! \( -f "$1" -o -f "ext/mongodb/$1" \); then | ||
AC_MSG_ERROR([m4 could not include $1: No such file or directory]) | ||
fi | ||
m4_builtin([sinclude],[$1]) | ||
m4_builtin([sinclude],[ext/mongodb/][$1]) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we can assume that the extension will be build from this path, since it's the extension's name. That said, users need to manually copy/symlink in order to build statically so I suppose they could inadvertently place us under a different path. If so, the conditional a few lines up isn't going to point out that the Let me know if you'd like a more helpful error for that case. It may be as simple as adding "ext/mongodb" to the error message, or conditionally printing a special message if There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think we should do this, as we don't want to promote compiling the driver as a static extension. |
||
]) | ||
|
||
dnl Avoid using AC_CONFIG_MACRO_DIR, which might conflict with PHP | ||
m4_include([scripts/build/autotools/m4/ac_compile_check_sizeof.m4]) | ||
m4_include([scripts/build/autotools/m4/ac_create_stdint_h.m4]) | ||
m4_include([scripts/build/autotools/m4/as_var_copy.m4]) | ||
m4_include([scripts/build/autotools/m4/ax_check_compile_flag.m4]) | ||
m4_include([scripts/build/autotools/m4/ax_prototype.m4]) | ||
m4_include([scripts/build/autotools/m4/ax_pthread.m4]) | ||
m4_include([scripts/build/autotools/m4/pkg.m4]) | ||
|
||
m4_include([scripts/build/autotools/CheckCompiler.m4]) | ||
m4_include([scripts/build/autotools/CheckHost.m4]) | ||
|
||
m4_include([scripts/build/autotools/libbson/CheckAtomics.m4]) | ||
m4_include([scripts/build/autotools/libbson/CheckHeaders.m4]) | ||
m4_include([scripts/build/autotools/libbson/Endian.m4]) | ||
m4_include([scripts/build/autotools/libbson/FindDependencies.m4]) | ||
m4_include([scripts/build/autotools/libbson/Versions.m4]) | ||
|
||
m4_include([scripts/build/autotools/libmongoc/CheckCompression.m4]) | ||
m4_include([scripts/build/autotools/libmongoc/CheckResolv.m4]) | ||
m4_include([scripts/build/autotools/libmongoc/CheckSasl.m4]) | ||
m4_include([scripts/build/autotools/libmongoc/CheckSSL.m4]) | ||
m4_include([scripts/build/autotools/libmongoc/FindDependencies.m4]) | ||
m4_include([scripts/build/autotools/libmongoc/PlatformFlags.m4]) | ||
m4_include([scripts/build/autotools/libmongoc/Versions.m4]) | ||
m4_include([scripts/build/autotools/libmongoc/WeakSymbols.m4]) | ||
_include([scripts/build/autotools/m4/ac_compile_check_sizeof.m4]) | ||
_include([scripts/build/autotools/m4/ac_create_stdint_h.m4]) | ||
_include([scripts/build/autotools/m4/as_var_copy.m4]) | ||
_include([scripts/build/autotools/m4/ax_check_compile_flag.m4]) | ||
_include([scripts/build/autotools/m4/ax_prototype.m4]) | ||
_include([scripts/build/autotools/m4/ax_pthread.m4]) | ||
_include([scripts/build/autotools/m4/php_mongodb.m4]) | ||
_include([scripts/build/autotools/m4/pkg.m4]) | ||
|
||
_include([scripts/build/autotools/CheckCompiler.m4]) | ||
_include([scripts/build/autotools/CheckHost.m4]) | ||
|
||
_include([scripts/build/autotools/libbson/CheckAtomics.m4]) | ||
_include([scripts/build/autotools/libbson/CheckHeaders.m4]) | ||
_include([scripts/build/autotools/libbson/Endian.m4]) | ||
_include([scripts/build/autotools/libbson/FindDependencies.m4]) | ||
_include([scripts/build/autotools/libbson/Versions.m4]) | ||
|
||
_include([scripts/build/autotools/libmongoc/CheckCompression.m4]) | ||
_include([scripts/build/autotools/libmongoc/CheckResolv.m4]) | ||
_include([scripts/build/autotools/libmongoc/CheckSasl.m4]) | ||
_include([scripts/build/autotools/libmongoc/CheckSSL.m4]) | ||
_include([scripts/build/autotools/libmongoc/FindDependencies.m4]) | ||
_include([scripts/build/autotools/libmongoc/PlatformFlags.m4]) | ||
_include([scripts/build/autotools/libmongoc/Versions.m4]) | ||
_include([scripts/build/autotools/libmongoc/WeakSymbols.m4]) | ||
|
||
m4_popdef([_include]) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just cleaning up after ourselves so not to pollute the global M4 namespace. This should also be flexible in the event that some other extension (or PHP) defines an There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Or also prefix it with php_mongodb_ ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Currently there is no risk of conflicting with an
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK |
||
|
||
AC_SUBST(BSON_EXTRA_ALIGN, 0) | ||
AC_SUBST(BSON_OS, 1) | ||
|
@@ -271,42 +296,40 @@ if test "$PHP_MONGODB" != "no"; then | |
dnl Generated with: find src/libmongoc/src/zlib-1.2.11 -maxdepth 1 -name '*.c' -print0 | cut -sz -d / -f 5- | sort -z | tr '\000' ' ' | ||
PHP_MONGODB_ZLIB_SOURCES="adler32.c compress.c crc32.c deflate.c gzclose.c gzlib.c gzread.c gzwrite.c infback.c inffast.c inflate.c inftrees.c trees.c uncompr.c zutil.c" | ||
|
||
PHP_ADD_SOURCES_X(PHP_EXT_DIR(mongodb)[src/libbson/src/bson], $PHP_MONGODB_BSON_SOURCES, $PHP_MONGODB_BSON_CFLAGS, shared_objects_mongodb, yes) | ||
PHP_ADD_SOURCES_X(PHP_EXT_DIR(mongodb)[src/libbson/src/jsonsl], $PHP_MONGODB_JSONSL_SOURCES, $PHP_MONGODB_BSON_CFLAGS, shared_objects_mongodb, yes) | ||
PHP_ADD_SOURCES_X(PHP_EXT_DIR(mongodb)[src/libmongoc/src/mongoc], $PHP_MONGODB_MONGOC_SOURCES, $PHP_MONGODB_MONGOC_CFLAGS, shared_objects_mongodb, yes) | ||
PHP_MONGODB_ADD_SOURCES([src/libbson/src/bson/], $PHP_MONGODB_BSON_SOURCES, $PHP_MONGODB_BSON_CFLAGS) | ||
PHP_MONGODB_ADD_SOURCES([src/libbson/src/jsonsl/], $PHP_MONGODB_JSONSL_SOURCES, $PHP_MONGODB_BSON_CFLAGS) | ||
PHP_MONGODB_ADD_SOURCES([src/libmongoc/src/mongoc/], $PHP_MONGODB_MONGOC_SOURCES, $PHP_MONGODB_MONGOC_CFLAGS) | ||
|
||
PHP_ADD_INCLUDE(PHP_EXT_SRCDIR(mongodb)[/src/libbson/src/]) | ||
PHP_ADD_INCLUDE(PHP_EXT_SRCDIR(mongodb)[/src/libbson/src/bson/]) | ||
PHP_ADD_INCLUDE(PHP_EXT_SRCDIR(mongodb)[/src/libbson/src/jsonsl/]) | ||
PHP_ADD_INCLUDE(PHP_EXT_SRCDIR(mongodb)[/src/libmongoc/src/mongoc/]) | ||
PHP_MONGODB_ADD_INCLUDE([src/libbson/src/]) | ||
PHP_MONGODB_ADD_INCLUDE([src/libbson/src/bson/]) | ||
PHP_MONGODB_ADD_INCLUDE([src/libbson/src/jsonsl/]) | ||
PHP_MONGODB_ADD_INCLUDE([src/libmongoc/src/mongoc/]) | ||
|
||
PHP_ADD_BUILD_DIR(PHP_EXT_BUILDDIR(mongodb)[/src/libbson/src/jsonsl/]) | ||
PHP_ADD_BUILD_DIR(PHP_EXT_BUILDDIR(mongodb)[/src/libbson/src/bson/]) | ||
PHP_ADD_BUILD_DIR(PHP_EXT_BUILDDIR(mongodb)[/src/libmongoc/src/mongoc/]) | ||
PHP_MONGODB_ADD_BUILD_DIR([src/libbson/src/bson/]) | ||
PHP_MONGODB_ADD_BUILD_DIR([src/libbson/src/jsonsl/]) | ||
PHP_MONGODB_ADD_BUILD_DIR([src/libmongoc/src/mongoc/]) | ||
|
||
dnl TODO: Use $ext_srcdir if we can move this after PHP_NEW_EXTENSION | ||
ac_config_dir=PHP_EXT_SRCDIR(mongodb) | ||
|
||
AC_CONFIG_FILES([ | ||
src/libbson/src/bson/bson-config.h | ||
src/libbson/src/bson/bson-version.h | ||
src/libmongoc/src/mongoc/mongoc-config.h | ||
src/libmongoc/src/mongoc/mongoc-version.h | ||
${ac_config_dir}/src/libbson/src/bson/bson-config.h | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In my testing, I wasn't able to use |
||
${ac_config_dir}/src/libbson/src/bson/bson-version.h | ||
${ac_config_dir}/src/libmongoc/src/mongoc/mongoc-config.h | ||
${ac_config_dir}/src/libmongoc/src/mongoc/mongoc-version.h | ||
]) | ||
|
||
if test "x$bundled_zlib" = "xyes"; then | ||
PHP_ADD_SOURCES_X(PHP_EXT_DIR(mongodb)[src/libmongoc/src/zlib-1.2.11], $PHP_MONGODB_ZLIB_SOURCES, $PHP_MONGODB_MONGOC_CFLAGS, shared_objects_mongodb, yes) | ||
PHP_ADD_INCLUDE(PHP_EXT_SRCDIR(mongodb)[/src/libmongoc/src/zlib-1.2.11/]) | ||
PHP_ADD_BUILD_DIR(PHP_EXT_BUILDDIR(mongodb)[/src/libmongoc/src/zlib-1.2.11/]) | ||
AC_CONFIG_FILES(src/libmongoc/src/zlib-1.2.11/zconf.h) | ||
PHP_MONGODB_ADD_SOURCES([src/libmongoc/src/zlib-1.2.11/], $PHP_MONGODB_ZLIB_SOURCES, $PHP_MONGODB_MONGOC_CFLAGS) | ||
PHP_MONGODB_ADD_INCLUDE([src/libmongoc/src/zlib-1.2.11/]) | ||
PHP_MONGODB_ADD_BUILD_DIR([src/libmongoc/src/zlib-1.2.11/]) | ||
AC_CONFIG_FILES([${ac_config_dir}/src/libmongoc/src/zlib-1.2.11/zconf.h]) | ||
fi | ||
|
||
dnl Apply any CFLAGS and LIBS from libbson calling AX_PTHREAD | ||
PHP_EVAL_INCLINE([$PTHREAD_CFLAGS]) | ||
PHP_EVAL_LIBLINE([$PTHREAD_LIBS],[MONGODB_SHARED_LIBADD]) | ||
fi | ||
|
||
PHP_NEW_EXTENSION(mongodb, $PHP_MONGODB_SOURCES, $ext_shared,, $PHP_MONGODB_CFLAGS) | ||
|
||
PHP_SUBST(MONGODB_SHARED_LIBADD) | ||
PHP_SUBST(EXTRA_LDFLAGS) | ||
|
||
PHP_ADD_EXTENSION_DEP(mongodb, date) | ||
PHP_ADD_EXTENSION_DEP(mongodb, json) | ||
|
@@ -325,10 +348,17 @@ if test "$PHP_MONGODB" != "no"; then | |
PHP_ADD_BUILD_DIR(PHP_EXT_BUILDDIR(mongodb)[/src/MongoDB/Monitoring/]) | ||
PHP_ADD_BUILD_DIR(PHP_EXT_BUILDDIR(mongodb)[/src/contrib/]) | ||
|
||
dnl Necessary to ensure that static builds include "-pthread" when linking | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you decide that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As I said in the other PR: I don't think it's relevant. |
||
if test "$ext_shared" != "yes"; then | ||
EXTRA_LDFLAGS_PROGRAM="$EXTRA_LDFLAGS_PROGRAM $EXTRA_LDFLAGS" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I took a look at the We're adding |
||
fi | ||
|
||
dnl This must come after PHP_NEW_EXTENSION, otherwise the srcdir won't be set | ||
PHP_ADD_MAKEFILE_FRAGMENT | ||
|
||
AC_CONFIG_COMMANDS_POST([echo " | ||
AC_CONFIG_COMMANDS_POST([ | ||
if test "$enable_static" = "no"; then | ||
echo " | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I opted not to use |
||
mongodb was configured with the following options: | ||
|
||
Build configuration: | ||
|
@@ -345,7 +375,9 @@ Build configuration: | |
Please submit bugreports at: | ||
https://jira.mongodb.org/browse/PHPC | ||
|
||
"]) | ||
" | ||
fi | ||
]) | ||
fi | ||
|
||
dnl: vim: et sw=2 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -78,8 +78,16 @@ AC_CHECK_FUNC(rand_r, [AC_SUBST(BSON_HAVE_RAND_R, 1)], [], [#include <stdlib.h>] | |
# Check for pthreads. We might need to make this better to handle mingw, | ||
# but I actually think it is okay to just check for it even though we will | ||
# use win32 primatives. | ||
AX_PTHREAD([], | ||
[AC_MSG_ERROR([libbson requires pthreads on non-Windows platforms.])]) | ||
AX_PTHREAD([ | ||
PHP_MONGODB_BSON_CFLAGS="$PHP_MONGODB_BSON_CFLAGS $PTHREAD_CFLAGS" | ||
PHP_EVAL_LIBLINE([$PTHREAD_LIBS],[MONGODB_SHARED_LIBADD]) | ||
|
||
# PTHREAD_CFLAGS may come back as "-pthread", which should also be used when | ||
# linking. We can trust PHP_EVAL_LIBLINE to ignore other values. | ||
PHP_EVAL_LIBLINE([$PTHREAD_CFLAGS],[MONGODB_SHARED_LIBADD]) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is an odd edge case.
Note: this goes hand in hand with our logic in |
||
],[ | ||
AC_MSG_ERROR([libbson requires pthreads on non-Windows platforms.]) | ||
]) | ||
|
||
|
||
# The following is borrowed from the guile configure script. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,5 +23,16 @@ AC_CHECK_TYPE([socklen_t], | |
[AC_SUBST(MONGOC_HAVE_SOCKLEN, 0)], | ||
[#include <sys/socket.h>]) | ||
|
||
dnl libbson already requires pthreads, so skip a redundant, optional check here | ||
dnl AX_PTHREAD | ||
# Check for pthreads. libmongoc's original FindDependencies.m4 script did not | ||
# require pthreads, but it does appear to be necessary on non-Windows platforms | ||
# based on mongoc-openssl.c and mongoc-thread-private.h. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure why libmongoc always considered pthreads optional, but they are certainly assumed to exist in these files. It's possible that this was an edge case and the dependency was satisfied by also linking libbson successfully. In any event, I think this is correct and I'm not going to both libmongoc about it since the M4 file in question no longer exists in their repository. |
||
AX_PTHREAD([ | ||
PHP_MONGODB_MONGOC_CFLAGS="$PHP_MONGODB_MONGOC_CFLAGS $PTHREAD_CFLAGS" | ||
PHP_EVAL_LIBLINE([$PTHREAD_LIBS],[MONGODB_SHARED_LIBADD]) | ||
|
||
# PTHREAD_CFLAGS may come back as "-pthread", which should also be used when | ||
# linking. We can trust PHP_EVAL_LIBLINE to ignore other values. | ||
PHP_EVAL_LIBLINE([$PTHREAD_CFLAGS],[MONGODB_SHARED_LIBADD]) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note: PHP uses |
||
],[ | ||
AC_MSG_ERROR([libmongoc requires pthreads on non-Windows platforms.]) | ||
]) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
dnl | ||
dnl PHP_MONGODB_ADD_SOURCES(source-path, sources [, special-flags]) | ||
dnl | ||
dnl Adds sources which are located relative to source-path. source-path should | ||
dnl be relative to the extension directory (i.e. PHP_EXT_DIR). special-flags | ||
dnl will be passed to the compiler. | ||
dnl | ||
dnl This macro will call PHP_ADD_SOURCES or PHP_ADD_SOURCES_X depending on | ||
dnl whether the extension is being built statically or as a shared module. | ||
dnl | ||
AC_DEFUN([PHP_MONGODB_ADD_SOURCES],[ | ||
_src_path=PHP_EXT_DIR(mongodb) | ||
|
||
dnl Join extension directory and source path | ||
case $_src_path in | ||
""[)] _src_path="$1" ;; | ||
*/[)] _src_path="$_src_path$1" ;; | ||
*[)] _src_path="$_src_path/$1" ;; | ||
esac | ||
|
||
dnl Trim trailing slash from source path | ||
case $_src_path in | ||
*/[)] _src_path=${_src_path%?} | ||
esac | ||
|
||
if test "$ext_shared" = "no"; then | ||
PHP_ADD_SOURCES($_src_path, [$2], [$3]) | ||
else | ||
PHP_ADD_SOURCES_X($_src_path, [$2], [$3], shared_objects_mongodb, yes) | ||
fi | ||
]) | ||
|
||
dnl | ||
dnl PHP_MONGODB_ADD_INCLUDE(path) | ||
dnl | ||
dnl Adds an include path relative to the extension source directory (i.e. | ||
dnl PHP_EXT_SRCDIR). | ||
dnl | ||
AC_DEFUN([PHP_MONGODB_ADD_INCLUDE],[ | ||
PHP_ADD_INCLUDE(PHP_EXT_SRCDIR(mongodb)[/][$1]) | ||
]) | ||
|
||
dnl | ||
dnl PHP_MONGODB_ADD_BUILD_DIR(path) | ||
dnl | ||
dnl Adds a build directory relative to the extension build directory (i.e. | ||
dnl PHP_EXT_BUILDDIR). | ||
dnl | ||
AC_DEFUN([PHP_MONGODB_ADD_BUILD_DIR],[ | ||
PHP_ADD_BUILD_DIR(PHP_EXT_BUILDDIR(mongodb)[/][$1]) | ||
]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How can it sometimes be set, and sometimes not?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
test -z
checks if the string has non-zero length. For shared builds,PHP_VERSION
is never set soPHP_MONGODB_PHP_VERSION
will be initialized as an empty string.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK