Skip to content

Commit c78c03f

Browse files
committed
Merge pull request #830
2 parents b4060ab + e1827ed commit c78c03f

File tree

7 files changed

+181
-79
lines changed

7 files changed

+181
-79
lines changed

config.m4

Lines changed: 101 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,23 @@ PHP_ARG_ENABLE([mongodb],
55
[Enable MongoDB support])])
66

77
if test "$PHP_MONGODB" != "no"; then
8-
AC_MSG_CHECKING([Check for supported PHP versions])
9-
PHP_MONGODB_FOUND_VERSION=`${PHP_CONFIG} --version`
10-
PHP_MONGODB_FOUND_VERNUM=`echo "${PHP_MONGODB_FOUND_VERSION}" | $AWK 'BEGIN { FS = "."; } { printf "%d", ([$]1 * 100 + [$]2) * 100 + [$]3;}'`
11-
AC_MSG_RESULT($PHP_MONGODB_FOUND_VERSION)
12-
if test "$PHP_MONGODB_FOUND_VERNUM" -lt "50500"; then
13-
AC_MSG_ERROR([not supported. Need a PHP version >= 5.5.0 (found $PHP_MONGODB_FOUND_VERSION)])
8+
dnl Check PHP version is compatible with this extension
9+
AC_MSG_CHECKING([PHP version])
10+
11+
PHP_MONGODB_PHP_VERSION=$PHP_VERSION
12+
PHP_MONGODB_PHP_VERSION_ID=$PHP_VERSION_ID
13+
14+
if test -z "$PHP_MONGODB_PHP_VERSION"; then
15+
if test -z "$PHP_CONFIG"; then
16+
AC_MSG_ERROR([php-config not found])
17+
fi
18+
PHP_MONGODB_PHP_VERSION=`${PHP_CONFIG} --version`
19+
PHP_MONGODB_PHP_VERSION_ID=`echo "${PHP_MONGODB_PHP_VERSION}" | $AWK 'BEGIN { FS = "."; } { printf "%d", ([$]1 * 100 + [$]2) * 100 + [$]3;}'`
20+
fi
21+
22+
AC_MSG_RESULT($PHP_MONGODB_PHP_VERSION)
23+
if test "$PHP_MONGODB_PHP_VERSION_ID" -lt "50500"; then
24+
AC_MSG_ERROR([not supported. Need a PHP version >= 5.5.0 (found $PHP_MONGODB_PHP_VERSION)])
1425
fi
1526

1627
PHP_ARG_ENABLE([developer-flags],
@@ -173,18 +184,18 @@ if test "$PHP_MONGODB" != "no"; then
173184
AC_MSG_CHECKING(for libbson)
174185
if test -x "$PKG_CONFIG" && $PKG_CONFIG --exists libbson-1.0; then
175186
if $PKG_CONFIG libbson-1.0 --atleast-version 1.9.0; then
176-
LIBBSON_INC=`$PKG_CONFIG libbson-1.0 --cflags`
177-
LIBBSON_LIB=`$PKG_CONFIG libbson-1.0 --libs`
178-
LIBBSON_VER=`$PKG_CONFIG libbson-1.0 --modversion`
179-
AC_MSG_RESULT(version $LIBBSON_VER found)
187+
PHP_MONGODB_BSON_CFLAGS=`$PKG_CONFIG libbson-1.0 --cflags`
188+
PHP_MONGODB_BSON_LIBS=`$PKG_CONFIG libbson-1.0 --libs`
189+
PHP_MONGODB_BSON_VERSION=`$PKG_CONFIG libbson-1.0 --modversion`
190+
AC_MSG_RESULT(version $PHP_MONGODB_BSON_VERSION found)
180191
else
181192
AC_MSG_ERROR(system libbson must be upgraded to version >= 1.9.0)
182193
fi
183194
else
184195
AC_MSG_ERROR(pkgconfig and libbson must be installed)
185196
fi
186-
PHP_EVAL_INCLINE($LIBBSON_INC)
187-
PHP_EVAL_LIBLINE($LIBBSON_LIB, MONGODB_SHARED_LIBADD)
197+
PHP_MONGODB_CFLAGS="$PHP_MONGODB_CFLAGS $PHP_MONGODB_BSON_CFLAGS"
198+
PHP_EVAL_LIBLINE($PHP_MONGODB_BSON_LIBS, MONGODB_SHARED_LIBADD)
188199
AC_DEFINE(HAVE_SYSTEM_LIBBSON, 1, [Use system libbson])
189200
fi
190201

@@ -197,52 +208,66 @@ if test "$PHP_MONGODB" != "no"; then
197208
AC_MSG_CHECKING(for libmongoc)
198209
if test -x "$PKG_CONFIG" && $PKG_CONFIG --exists libmongoc-1.0; then
199210
if $PKG_CONFIG libmongoc-1.0 --atleast-version 1.9.0; then
200-
LIBMONGOC_INC=`$PKG_CONFIG libmongoc-1.0 --cflags`
201-
LIBMONGOC_LIB=`$PKG_CONFIG libmongoc-1.0 --libs`
202-
LIBMONGOC_VER=`$PKG_CONFIG libmongoc-1.0 --modversion`
203-
AC_MSG_RESULT(version $LIBMONGOC_VER found)
204-
211+
PHP_MONGODB_MONGOC_CFLAGS=`$PKG_CONFIG libmongoc-1.0 --cflags`
212+
PHP_MONGODB_MONGOC_LIBS=`$PKG_CONFIG libmongoc-1.0 --libs`
213+
PHP_MONGODB_MONGOC_VERSION=`$PKG_CONFIG libmongoc-1.0 --modversion`
214+
AC_MSG_RESULT(version $PHP_MONGODB_MONGOC_VERSION found)
205215
else
206216
AC_MSG_ERROR(system libmongoc must be upgraded to version >= 1.9.0)
207217
fi
208218
else
209219
AC_MSG_ERROR(pkgconfig and libmongoc must be installed)
210220
fi
211-
PHP_EVAL_INCLINE($LIBMONGOC_INC)
212-
PHP_EVAL_LIBLINE($LIBMONGOC_LIB, MONGODB_SHARED_LIBADD)
221+
PHP_MONGODB_CFLAGS="$PHP_MONGODB_CFLAGS $PHP_MONGODB_MONGOC_CFLAGS"
222+
PHP_EVAL_LIBLINE($PHP_MONGODB_MONGOC_LIBS, MONGODB_SHARED_LIBADD)
213223
AC_DEFINE(HAVE_SYSTEM_LIBMONGOC, 1, [Use system libmongoc])
214224
fi
215225

216226
if test "$PHP_LIBBSON" = "no" -a "$PHP_LIBMONGOC" = "no"; then
217227
PHP_MONGODB_BSON_CFLAGS="$STD_CFLAGS -DBSON_COMPILATION"
218228
PHP_MONGODB_MONGOC_CFLAGS="$STD_CFLAGS -DMONGOC_COMPILATION -DMONGOC_TRACE"
219229

230+
dnl M4 doesn't know if we're building statically or as a shared module, so
231+
dnl attempt to include both paths while ignoring errors. If neither path
232+
dnl exists, report an error during configure (this is later than M4 parsing
233+
dnl during phpize but better than nothing).
234+
m4_pushdef([_include],[
235+
if test ! \( -f "$1" -o -f "ext/mongodb/$1" \); then
236+
AC_MSG_ERROR([m4 could not include $1: No such file or directory])
237+
fi
238+
m4_builtin([sinclude],[$1])
239+
m4_builtin([sinclude],[ext/mongodb/][$1])
240+
])
241+
220242
dnl Avoid using AC_CONFIG_MACRO_DIR, which might conflict with PHP
221-
m4_include([scripts/build/autotools/m4/ac_compile_check_sizeof.m4])
222-
m4_include([scripts/build/autotools/m4/ac_create_stdint_h.m4])
223-
m4_include([scripts/build/autotools/m4/as_var_copy.m4])
224-
m4_include([scripts/build/autotools/m4/ax_check_compile_flag.m4])
225-
m4_include([scripts/build/autotools/m4/ax_prototype.m4])
226-
m4_include([scripts/build/autotools/m4/ax_pthread.m4])
227-
m4_include([scripts/build/autotools/m4/pkg.m4])
228-
229-
m4_include([scripts/build/autotools/CheckCompiler.m4])
230-
m4_include([scripts/build/autotools/CheckHost.m4])
231-
232-
m4_include([scripts/build/autotools/libbson/CheckAtomics.m4])
233-
m4_include([scripts/build/autotools/libbson/CheckHeaders.m4])
234-
m4_include([scripts/build/autotools/libbson/Endian.m4])
235-
m4_include([scripts/build/autotools/libbson/FindDependencies.m4])
236-
m4_include([scripts/build/autotools/libbson/Versions.m4])
237-
238-
m4_include([scripts/build/autotools/libmongoc/CheckCompression.m4])
239-
m4_include([scripts/build/autotools/libmongoc/CheckResolv.m4])
240-
m4_include([scripts/build/autotools/libmongoc/CheckSasl.m4])
241-
m4_include([scripts/build/autotools/libmongoc/CheckSSL.m4])
242-
m4_include([scripts/build/autotools/libmongoc/FindDependencies.m4])
243-
m4_include([scripts/build/autotools/libmongoc/PlatformFlags.m4])
244-
m4_include([scripts/build/autotools/libmongoc/Versions.m4])
245-
m4_include([scripts/build/autotools/libmongoc/WeakSymbols.m4])
243+
_include([scripts/build/autotools/m4/ac_compile_check_sizeof.m4])
244+
_include([scripts/build/autotools/m4/ac_create_stdint_h.m4])
245+
_include([scripts/build/autotools/m4/as_var_copy.m4])
246+
_include([scripts/build/autotools/m4/ax_check_compile_flag.m4])
247+
_include([scripts/build/autotools/m4/ax_prototype.m4])
248+
_include([scripts/build/autotools/m4/ax_pthread.m4])
249+
_include([scripts/build/autotools/m4/php_mongodb.m4])
250+
_include([scripts/build/autotools/m4/pkg.m4])
251+
252+
_include([scripts/build/autotools/CheckCompiler.m4])
253+
_include([scripts/build/autotools/CheckHost.m4])
254+
255+
_include([scripts/build/autotools/libbson/CheckAtomics.m4])
256+
_include([scripts/build/autotools/libbson/CheckHeaders.m4])
257+
_include([scripts/build/autotools/libbson/Endian.m4])
258+
_include([scripts/build/autotools/libbson/FindDependencies.m4])
259+
_include([scripts/build/autotools/libbson/Versions.m4])
260+
261+
_include([scripts/build/autotools/libmongoc/CheckCompression.m4])
262+
_include([scripts/build/autotools/libmongoc/CheckResolv.m4])
263+
_include([scripts/build/autotools/libmongoc/CheckSasl.m4])
264+
_include([scripts/build/autotools/libmongoc/CheckSSL.m4])
265+
_include([scripts/build/autotools/libmongoc/FindDependencies.m4])
266+
_include([scripts/build/autotools/libmongoc/PlatformFlags.m4])
267+
_include([scripts/build/autotools/libmongoc/Versions.m4])
268+
_include([scripts/build/autotools/libmongoc/WeakSymbols.m4])
269+
270+
m4_popdef([_include])
246271

247272
AC_SUBST(BSON_EXTRA_ALIGN, 0)
248273
AC_SUBST(BSON_OS, 1)
@@ -271,42 +296,40 @@ if test "$PHP_MONGODB" != "no"; then
271296
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' ' '
272297
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"
273298

274-
PHP_ADD_SOURCES_X(PHP_EXT_DIR(mongodb)[src/libbson/src/bson], $PHP_MONGODB_BSON_SOURCES, $PHP_MONGODB_BSON_CFLAGS, shared_objects_mongodb, yes)
275-
PHP_ADD_SOURCES_X(PHP_EXT_DIR(mongodb)[src/libbson/src/jsonsl], $PHP_MONGODB_JSONSL_SOURCES, $PHP_MONGODB_BSON_CFLAGS, shared_objects_mongodb, yes)
276-
PHP_ADD_SOURCES_X(PHP_EXT_DIR(mongodb)[src/libmongoc/src/mongoc], $PHP_MONGODB_MONGOC_SOURCES, $PHP_MONGODB_MONGOC_CFLAGS, shared_objects_mongodb, yes)
299+
PHP_MONGODB_ADD_SOURCES([src/libbson/src/bson/], $PHP_MONGODB_BSON_SOURCES, $PHP_MONGODB_BSON_CFLAGS)
300+
PHP_MONGODB_ADD_SOURCES([src/libbson/src/jsonsl/], $PHP_MONGODB_JSONSL_SOURCES, $PHP_MONGODB_BSON_CFLAGS)
301+
PHP_MONGODB_ADD_SOURCES([src/libmongoc/src/mongoc/], $PHP_MONGODB_MONGOC_SOURCES, $PHP_MONGODB_MONGOC_CFLAGS)
277302

278-
PHP_ADD_INCLUDE(PHP_EXT_SRCDIR(mongodb)[/src/libbson/src/])
279-
PHP_ADD_INCLUDE(PHP_EXT_SRCDIR(mongodb)[/src/libbson/src/bson/])
280-
PHP_ADD_INCLUDE(PHP_EXT_SRCDIR(mongodb)[/src/libbson/src/jsonsl/])
281-
PHP_ADD_INCLUDE(PHP_EXT_SRCDIR(mongodb)[/src/libmongoc/src/mongoc/])
303+
PHP_MONGODB_ADD_INCLUDE([src/libbson/src/])
304+
PHP_MONGODB_ADD_INCLUDE([src/libbson/src/bson/])
305+
PHP_MONGODB_ADD_INCLUDE([src/libbson/src/jsonsl/])
306+
PHP_MONGODB_ADD_INCLUDE([src/libmongoc/src/mongoc/])
282307

283-
PHP_ADD_BUILD_DIR(PHP_EXT_BUILDDIR(mongodb)[/src/libbson/src/jsonsl/])
284-
PHP_ADD_BUILD_DIR(PHP_EXT_BUILDDIR(mongodb)[/src/libbson/src/bson/])
285-
PHP_ADD_BUILD_DIR(PHP_EXT_BUILDDIR(mongodb)[/src/libmongoc/src/mongoc/])
308+
PHP_MONGODB_ADD_BUILD_DIR([src/libbson/src/bson/])
309+
PHP_MONGODB_ADD_BUILD_DIR([src/libbson/src/jsonsl/])
310+
PHP_MONGODB_ADD_BUILD_DIR([src/libmongoc/src/mongoc/])
311+
312+
dnl TODO: Use $ext_srcdir if we can move this after PHP_NEW_EXTENSION
313+
ac_config_dir=PHP_EXT_SRCDIR(mongodb)
286314

287315
AC_CONFIG_FILES([
288-
src/libbson/src/bson/bson-config.h
289-
src/libbson/src/bson/bson-version.h
290-
src/libmongoc/src/mongoc/mongoc-config.h
291-
src/libmongoc/src/mongoc/mongoc-version.h
316+
${ac_config_dir}/src/libbson/src/bson/bson-config.h
317+
${ac_config_dir}/src/libbson/src/bson/bson-version.h
318+
${ac_config_dir}/src/libmongoc/src/mongoc/mongoc-config.h
319+
${ac_config_dir}/src/libmongoc/src/mongoc/mongoc-version.h
292320
])
293321

294322
if test "x$bundled_zlib" = "xyes"; then
295-
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)
296-
PHP_ADD_INCLUDE(PHP_EXT_SRCDIR(mongodb)[/src/libmongoc/src/zlib-1.2.11/])
297-
PHP_ADD_BUILD_DIR(PHP_EXT_BUILDDIR(mongodb)[/src/libmongoc/src/zlib-1.2.11/])
298-
AC_CONFIG_FILES(src/libmongoc/src/zlib-1.2.11/zconf.h)
323+
PHP_MONGODB_ADD_SOURCES([src/libmongoc/src/zlib-1.2.11/], $PHP_MONGODB_ZLIB_SOURCES, $PHP_MONGODB_MONGOC_CFLAGS)
324+
PHP_MONGODB_ADD_INCLUDE([src/libmongoc/src/zlib-1.2.11/])
325+
PHP_MONGODB_ADD_BUILD_DIR([src/libmongoc/src/zlib-1.2.11/])
326+
AC_CONFIG_FILES([${ac_config_dir}/src/libmongoc/src/zlib-1.2.11/zconf.h])
299327
fi
300-
301-
dnl Apply any CFLAGS and LIBS from libbson calling AX_PTHREAD
302-
PHP_EVAL_INCLINE([$PTHREAD_CFLAGS])
303-
PHP_EVAL_LIBLINE([$PTHREAD_LIBS],[MONGODB_SHARED_LIBADD])
304328
fi
305329

306330
PHP_NEW_EXTENSION(mongodb, $PHP_MONGODB_SOURCES, $ext_shared,, $PHP_MONGODB_CFLAGS)
307331

308332
PHP_SUBST(MONGODB_SHARED_LIBADD)
309-
PHP_SUBST(EXTRA_LDFLAGS)
310333

311334
PHP_ADD_EXTENSION_DEP(mongodb, date)
312335
PHP_ADD_EXTENSION_DEP(mongodb, json)
@@ -325,10 +348,17 @@ if test "$PHP_MONGODB" != "no"; then
325348
PHP_ADD_BUILD_DIR(PHP_EXT_BUILDDIR(mongodb)[/src/MongoDB/Monitoring/])
326349
PHP_ADD_BUILD_DIR(PHP_EXT_BUILDDIR(mongodb)[/src/contrib/])
327350

351+
dnl Necessary to ensure that static builds include "-pthread" when linking
352+
if test "$ext_shared" != "yes"; then
353+
EXTRA_LDFLAGS_PROGRAM="$EXTRA_LDFLAGS_PROGRAM $EXTRA_LDFLAGS"
354+
fi
355+
328356
dnl This must come after PHP_NEW_EXTENSION, otherwise the srcdir won't be set
329357
PHP_ADD_MAKEFILE_FRAGMENT
330358

331-
AC_CONFIG_COMMANDS_POST([echo "
359+
AC_CONFIG_COMMANDS_POST([
360+
if test "$enable_static" = "no"; then
361+
echo "
332362
mongodb was configured with the following options:
333363
334364
Build configuration:
@@ -345,7 +375,9 @@ Build configuration:
345375
Please submit bugreports at:
346376
https://jira.mongodb.org/browse/PHPC
347377
348-
"])
378+
"
379+
fi
380+
])
349381
fi
350382

351383
dnl: vim: et sw=2

scripts/build/autotools/libbson/FindDependencies.m4

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,16 @@ AC_CHECK_FUNC(rand_r, [AC_SUBST(BSON_HAVE_RAND_R, 1)], [], [#include <stdlib.h>]
7878
# Check for pthreads. We might need to make this better to handle mingw,
7979
# but I actually think it is okay to just check for it even though we will
8080
# use win32 primatives.
81-
AX_PTHREAD([],
82-
[AC_MSG_ERROR([libbson requires pthreads on non-Windows platforms.])])
81+
AX_PTHREAD([
82+
PHP_MONGODB_BSON_CFLAGS="$PHP_MONGODB_BSON_CFLAGS $PTHREAD_CFLAGS"
83+
PHP_EVAL_LIBLINE([$PTHREAD_LIBS],[MONGODB_SHARED_LIBADD])
84+
85+
# PTHREAD_CFLAGS may come back as "-pthread", which should also be used when
86+
# linking. We can trust PHP_EVAL_LIBLINE to ignore other values.
87+
PHP_EVAL_LIBLINE([$PTHREAD_CFLAGS],[MONGODB_SHARED_LIBADD])
88+
],[
89+
AC_MSG_ERROR([libbson requires pthreads on non-Windows platforms.])
90+
])
8391

8492

8593
# The following is borrowed from the guile configure script.

scripts/build/autotools/libmongoc/CheckCompression.m4

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ found_zlib="no"
33
bundled_zlib="no"
44

55
PKG_CHECK_MODULES([PHP_MONGODB_SNAPPY],[snappy],[
6-
PHP_EVAL_INCLINE([$PHP_MONGODB_SNAPPY_CFLAGS])
6+
PHP_MONGODB_MONGOC_CFLAGS="$PHP_MONGODB_MONGOC_CFLAGS $PHP_MONGODB_SNAPPY_CFLAGS"
77
PHP_EVAL_LIBLINE([$PHP_MONGODB_SNAPPY_LIBS],[MONGODB_SHARED_LIBADD])
88
found_snappy="yes"
99
],[
@@ -23,7 +23,7 @@ PKG_CHECK_MODULES([PHP_MONGODB_SNAPPY],[snappy],[
2323
])
2424

2525
PKG_CHECK_MODULES([PHP_MONGODB_ZLIB],[zlib],[
26-
PHP_EVAL_INCLINE([$PHP_MONGODB_ZLIB_CFLAGS])
26+
PHP_MONGODB_MONGOC_CFLAGS="$PHP_MONGODB_MONGOC_CFLAGS $PHP_MONGODB_ZLIB_CFLAGS"
2727
PHP_EVAL_LIBLINE([$PHP_MONGODB_ZLIB_LIBS],[MONGODB_SHARED_LIBADD])
2828
found_zlib="yes"
2929
],[

scripts/build/autotools/libmongoc/CheckSSL.m4

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ AS_IF([test "$PHP_MONGODB_SSL" = "openssl" -o "$PHP_MONGODB_SSL" = "auto"],[
3030
found_openssl="no"
3131
3232
PKG_CHECK_MODULES([PHP_MONGODB_SSL],[openssl],[
33-
PHP_EVAL_INCLINE([$PHP_MONGODB_SSL_CFLAGS])
33+
PHP_MONGODB_MONGOC_CFLAGS="$PHP_MONGODB_MONGOC_CFLAGS $PHP_MONGODB_SSL_CFLAGS"
3434
PHP_EVAL_LIBLINE([$PHP_MONGODB_SSL_LIBS],[MONGODB_SHARED_LIBADD])
3535
PHP_MONGODB_SSL="openssl"
3636
found_openssl="yes"
@@ -115,7 +115,7 @@ AS_IF([test "$PHP_MONGODB_SSL" = "libressl" -o "$PHP_MONGODB_SSL" = "auto"],[
115115
found_libressl="no"
116116
117117
PKG_CHECK_MODULES([PHP_MONGODB_SSL],[libtls libcrypto],[
118-
PHP_EVAL_INCLINE([$PHP_MONGODB_SSL_CFLAGS])
118+
PHP_MONGODB_MONGOC_CFLAGS="$PHP_MONGODB_MONGOC_CFLAGS $PHP_MONGODB_SSL_CFLAGS"
119119
PHP_EVAL_LIBLINE([$PHP_MONGODB_SSL_LIBS],[MONGODB_SHARED_LIBADD])
120120
PHP_MONGODB_SSL="libressl"
121121
found_libressl="yes"

scripts/build/autotools/libmongoc/CheckSasl.m4

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ AS_IF([test "$PHP_MONGODB_SASL" = "cyrus" -o "$PHP_MONGODB_SASL" = "auto"],[
1919
found_cyrus="no"
2020
2121
PKG_CHECK_MODULES([PHP_MONGODB_SASL],[libsasl2],[
22-
PHP_EVAL_INCLINE([$PHP_MONGODB_SASL_CFLAGS])
22+
PHP_MONGODB_MONGOC_CFLAGS="$PHP_MONGODB_MONGOC_CFLAGS $PHP_MONGODB_SASL_CFLAGS"
2323
PHP_EVAL_LIBLINE([$PHP_MONGODB_SASL_LIBS],[MONGODB_SHARED_LIBADD])
2424
PHP_MONGODB_SASL="cyrus"
2525
found_cyrus="yes"
@@ -49,7 +49,7 @@ AS_IF([test "$PHP_MONGODB_SASL" = "gssapi" -o "$PHP_MONGODB_SASL" = "auto"],[
4949
found_gssapi="no"
5050
5151
PKG_CHECK_MODULES([PHP_MONGODB_SASL],[krb5-gssapi],[
52-
PHP_EVAL_INCLINE([$PHP_MONGODB_SASL_CFLAGS])
52+
PHP_MONGODB_MONGOC_CFLAGS="$PHP_MONGODB_MONGOC_CFLAGS $PHP_MONGODB_SASL_CFLAGS"
5353
PHP_EVAL_LIBLINE([$PHP_MONGODB_SASL_LIBS],[MONGODB_SHARED_LIBADD])
5454
PHP_MONGODB_SASL="gssapi"
5555
found_gssapi="yes"

scripts/build/autotools/libmongoc/FindDependencies.m4

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,16 @@ AC_CHECK_TYPE([socklen_t],
2323
[AC_SUBST(MONGOC_HAVE_SOCKLEN, 0)],
2424
[#include <sys/socket.h>])
2525

26-
dnl libbson already requires pthreads, so skip a redundant, optional check here
27-
dnl AX_PTHREAD
26+
# Check for pthreads. libmongoc's original FindDependencies.m4 script did not
27+
# require pthreads, but it does appear to be necessary on non-Windows platforms
28+
# based on mongoc-openssl.c and mongoc-thread-private.h.
29+
AX_PTHREAD([
30+
PHP_MONGODB_MONGOC_CFLAGS="$PHP_MONGODB_MONGOC_CFLAGS $PTHREAD_CFLAGS"
31+
PHP_EVAL_LIBLINE([$PTHREAD_LIBS],[MONGODB_SHARED_LIBADD])
32+
33+
# PTHREAD_CFLAGS may come back as "-pthread", which should also be used when
34+
# linking. We can trust PHP_EVAL_LIBLINE to ignore other values.
35+
PHP_EVAL_LIBLINE([$PTHREAD_CFLAGS],[MONGODB_SHARED_LIBADD])
36+
],[
37+
AC_MSG_ERROR([libmongoc requires pthreads on non-Windows platforms.])
38+
])
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
dnl
2+
dnl PHP_MONGODB_ADD_SOURCES(source-path, sources [, special-flags])
3+
dnl
4+
dnl Adds sources which are located relative to source-path. source-path should
5+
dnl be relative to the extension directory (i.e. PHP_EXT_DIR). special-flags
6+
dnl will be passed to the compiler.
7+
dnl
8+
dnl This macro will call PHP_ADD_SOURCES or PHP_ADD_SOURCES_X depending on
9+
dnl whether the extension is being built statically or as a shared module.
10+
dnl
11+
AC_DEFUN([PHP_MONGODB_ADD_SOURCES],[
12+
_src_path=PHP_EXT_DIR(mongodb)
13+
14+
dnl Join extension directory and source path
15+
case $_src_path in
16+
""[)] _src_path="$1" ;;
17+
*/[)] _src_path="$_src_path$1" ;;
18+
*[)] _src_path="$_src_path/$1" ;;
19+
esac
20+
21+
dnl Trim trailing slash from source path
22+
case $_src_path in
23+
*/[)] _src_path=${_src_path%?}
24+
esac
25+
26+
if test "$ext_shared" = "no"; then
27+
PHP_ADD_SOURCES($_src_path, [$2], [$3])
28+
else
29+
PHP_ADD_SOURCES_X($_src_path, [$2], [$3], shared_objects_mongodb, yes)
30+
fi
31+
])
32+
33+
dnl
34+
dnl PHP_MONGODB_ADD_INCLUDE(path)
35+
dnl
36+
dnl Adds an include path relative to the extension source directory (i.e.
37+
dnl PHP_EXT_SRCDIR).
38+
dnl
39+
AC_DEFUN([PHP_MONGODB_ADD_INCLUDE],[
40+
PHP_ADD_INCLUDE(PHP_EXT_SRCDIR(mongodb)[/][$1])
41+
])
42+
43+
dnl
44+
dnl PHP_MONGODB_ADD_BUILD_DIR(path)
45+
dnl
46+
dnl Adds a build directory relative to the extension build directory (i.e.
47+
dnl PHP_EXT_BUILDDIR).
48+
dnl
49+
AC_DEFUN([PHP_MONGODB_ADD_BUILD_DIR],[
50+
PHP_ADD_BUILD_DIR(PHP_EXT_BUILDDIR(mongodb)[/][$1])
51+
])

0 commit comments

Comments
 (0)