From b1a669010a0e4fd3b92440d55b07e068ce6d9db9 Mon Sep 17 00:00:00 2001 From: Jeremy Mikola Date: Tue, 9 Jan 2018 20:37:51 -0500 Subject: [PATCH 01/19] Do not ignore nested "build" directories --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 6df556723..8d560aa31 100644 --- a/.gitignore +++ b/.gitignore @@ -6,7 +6,7 @@ acinclude.m4 aclocal.m4 autom4te.cache -build +/build config.guess config.h config.h.in From 8af9175353c0c8e15a53fc0d6e31236e80a8a2bc Mon Sep 17 00:00:00 2001 From: Jeremy Mikola Date: Thu, 11 Jan 2018 18:16:09 -0500 Subject: [PATCH 02/19] Fix conditional for whether extension is enabled --- config.m4 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.m4 b/config.m4 index 2c95209a4..99e019cdf 100644 --- a/config.m4 +++ b/config.m4 @@ -83,7 +83,7 @@ AC_DEFUN([PHP_BSON_CLOCK], fi ]) -if test "$MONGODB" != "no"; then +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;}'` From 274a4442f1f92865f7d33e9f5fa62e9fd41eceb3 Mon Sep 17 00:00:00 2001 From: Jeremy Mikola Date: Sat, 13 Jan 2018 02:19:26 -0500 Subject: [PATCH 03/19] Use single equal sign for test comparisons The double equal operator is a Bash-specific alias --- config.m4 | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/config.m4 b/config.m4 index 99e019cdf..5b416b918 100644 --- a/config.m4 +++ b/config.m4 @@ -226,7 +226,7 @@ if test "$PHP_MONGODB" != "no"; then [ --with-libmongoc Use system libmongoc], no, no) if test "$PHP_LIBBSON" != "no"; then - if test "$PHP_LIBMONGOC" == "no"; then + if test "$PHP_LIBMONGOC" = "no"; then AC_MSG_ERROR(Cannot use system libbson and bundled libmongoc) fi @@ -264,7 +264,7 @@ if test "$PHP_MONGODB" != "no"; then AC_MSG_RESULT(...) if test "$PHP_LIBMONGOC" != "no"; then - if test "$PHP_LIBBSON" == "no"; then + if test "$PHP_LIBBSON" = "no"; then AC_MSG_ERROR(Cannot use system libmongoc and bundled libbson) fi @@ -434,7 +434,7 @@ if test "$PHP_MONGODB" != "no"; then PHP_ADD_BUILD_DIR([$ext_builddir/src/MongoDB/Exception/]) PHP_ADD_BUILD_DIR([$ext_builddir/src/MongoDB/Monitoring/]) PHP_ADD_BUILD_DIR([$ext_builddir/src/contrib/]) - if test "$PHP_LIBMONGOC" == "no"; then + if test "$PHP_LIBMONGOC" = "no"; then PHP_ADD_INCLUDE([$ext_srcdir/src/libmongoc/src/mongoc/]) PHP_ADD_BUILD_DIR([$ext_builddir/src/libmongoc/src/mongoc/]) if test "x$with_zlib" = "xbundled"; then @@ -442,7 +442,7 @@ if test "$PHP_MONGODB" != "no"; then PHP_ADD_BUILD_DIR([$ext_srcdir/src/libmongoc/src/zlib-1.2.11/]) fi fi - if test "$PHP_LIBBSON" == "no"; then + if test "$PHP_LIBBSON" = "no"; then m4_include(src/libbson/build/autotools/CheckAtomics.m4) m4_include(src/libbson/build/autotools/FindDependencies.m4) m4_include(src/libbson/build/autotools/m4/ac_compile_check_sizeof.m4) @@ -485,7 +485,7 @@ if test "$PHP_MONGODB" != "no"; then AC_SUBST(BSON_HAVE_SNPRINTF, 0) fi - if test "$PHP_LIBMONGOC" == "no"; then + if test "$PHP_LIBMONGOC" = "no"; then backup_srcdir=${srcdir} srcdir=${srcdir}/src/libmongoc/ m4_include(src/libmongoc/build/autotools/Versions.m4) @@ -502,7 +502,7 @@ if test "$PHP_MONGODB" != "no"; then AC_OUTPUT($srcdir/src/libmongoc/src/zlib-1.2.11/zconf.h) fi fi - if test "$PHP_LIBBSON" == "no"; then + if test "$PHP_LIBBSON" = "no"; then backup_srcdir=${srcdir} srcdir=${srcdir}/src/libbson/ m4_include(src/libbson/build/autotools/Versions.m4) From d679bfe152fabcbd885160438d6dcf0d246a23ab Mon Sep 17 00:00:00 2001 From: Jeremy Mikola Date: Sat, 13 Jan 2018 02:17:07 -0500 Subject: [PATCH 04/19] PHPC-888: Support additional TLS libraries for bundled libmongoc --- config.m4 | 31 +--- scripts/build/autotools/CheckHost.m4 | 54 +++++++ scripts/build/autotools/CheckSSL.m4 | 215 +++++++++++++++++++++++++++ scripts/build/autotools/m4/pkg.m4 | 199 +++++++++++++++++++++++++ 4 files changed, 471 insertions(+), 28 deletions(-) create mode 100644 scripts/build/autotools/CheckHost.m4 create mode 100644 scripts/build/autotools/CheckSSL.m4 create mode 100644 scripts/build/autotools/m4/pkg.m4 diff --git a/config.m4 b/config.m4 index 5b416b918..7f8abc97d 100644 --- a/config.m4 +++ b/config.m4 @@ -1,10 +1,6 @@ dnl config.m4 for extension mongodb PHP_ARG_ENABLE(mongodb, whether to enable mongodb support, [ --enable-mongodb Enable mongodb support]) -PHP_ARG_WITH(openssl-dir, OpenSSL dir for mongodb, -[ --with-openssl-dir[=DIR] openssl install prefix], yes, no) -PHP_ARG_WITH(system-ciphers, whether to use system default cipher list instead of hardcoded value, -[ --with-system-ciphers OPENSSL: Use system default cipher list instead of hardcoded value], no, no) dnl borrowed from libmongoc configure.ac dnl AS_VAR_COPY is available in AC 2.64 and on, but we only require 2.60. @@ -297,20 +293,10 @@ if test "$PHP_MONGODB" != "no"; then PHP_ADD_SOURCES_X(PHP_EXT_DIR(mongodb)[src/libmongoc/src/mongoc], $PHP_MONGODB_MONGOC_SOURCES, $PHP_MONGODB_MONGOC_CFLAGS, shared_objects_mongodb, yes) - AC_SUBST(MONGOC_ENABLE_CRYPTO, 0) - AC_SUBST(MONGOC_ENABLE_SSL, 0) - AC_SUBST(MONGOC_ENABLE_CRYPTO_LIBCRYPTO, 0) - AC_SUBST(MONGOC_ENABLE_SSL_OPENSSL, 0) - AC_SUBST(MONGOC_HAVE_ASN1_STRING_GET0_DATA, 0) + m4_include(scripts/build/autotools/m4/pkg.m4) - PHP_SETUP_OPENSSL(MONGODB_SHARED_LIBADD, [ - AC_SUBST(MONGOC_ENABLE_CRYPTO, 1) - AC_SUBST(MONGOC_ENABLE_SSL, 1) - AC_SUBST(MONGOC_ENABLE_CRYPTO_LIBCRYPTO, 1) - AC_SUBST(MONGOC_ENABLE_SSL_OPENSSL, 1) - - AC_CHECK_DECLS([ASN1_STRING_get0_data], [AC_SUBST(MONGOC_HAVE_ASN1_STRING_GET0_DATA, 1)], [AC_SUBST(MONGOC_HAVE_ASN1_STRING_GET0_DATA, 0)], [[#include ]]) - ]) + m4_include(scripts/build/autotools/CheckHost.m4) + m4_include(scripts/build/autotools/CheckSSL.m4) if test "$PHP_SYSTEM_CIPHERS" != "no"; then AC_SUBST(MONGOC_ENABLE_CRYPTO_SYSTEM_PROFILE, 1) @@ -318,23 +304,12 @@ if test "$PHP_MONGODB" != "no"; then AC_SUBST(MONGOC_ENABLE_CRYPTO_SYSTEM_PROFILE, 0) fi - dnl TODO: Support building with Secure Transport on OSX - AC_SUBST(MONGOC_ENABLE_SSL_SECURE_TRANSPORT, 0) - AC_SUBST(MONGOC_ENABLE_CRYPTO_COMMON_CRYPTO, 0) - - dnl Secure Channel only applies to Windows - AC_SUBST(MONGOC_ENABLE_SSL_SECURE_CHANNEL, 0) - AC_SUBST(MONGOC_ENABLE_CRYPTO_CNG, 0) - - AC_SUBST(MONGOC_ENABLE_SSL_LIBRESSL, 0) - AC_SUBST(MONGOC_NO_AUTOMATIC_GLOBALS, 1) AC_CHECK_TYPE([socklen_t], [AC_SUBST(MONGOC_HAVE_SOCKLEN, 1)], [AC_SUBST(MONGOC_HAVE_SOCKLEN, 0)], [#include ]) with_snappy=auto with_zlib=auto - m4_include(src/libmongoc/build/autotools/m4/pkg.m4) m4_include(src/libmongoc/build/autotools/CheckSnappy.m4) m4_include(src/libmongoc/build/autotools/CheckZlib.m4) diff --git a/scripts/build/autotools/CheckHost.m4 b/scripts/build/autotools/CheckHost.m4 new file mode 100644 index 000000000..a5b7fa835 --- /dev/null +++ b/scripts/build/autotools/CheckHost.m4 @@ -0,0 +1,54 @@ +AC_CANONICAL_HOST + +os_win32=no +os_netbsd=no +os_freebsd=no +os_openbsd=no +os_hpux=no +os_linux=no +os_solaris=no +os_darwin=no +os_gnu=no + +case "$host" in + *-mingw*|*-*-cygwin*) + os_win32=yes + TARGET_OS=windows + ;; + *-*-*netbsd*) + os_netbsd=yes + ARGET_OS=unix + ;; + *-*-*freebsd*) + os_freebsd=yes + TARGET_OS=unix + ;; + *-*-*openbsd*) + os_openbsd=yes + TARGET_OS=unix + ;; + *-*-hpux*) + os_hpux=yes + TARGET_OS=unix + ;; + *-*-linux*) + os_linux=yes + os_gnu=yes + TARGET_OS=unix + ;; + *-*-solaris*) + os_solaris=yes + TARGET_OS=unix + ;; + *-*-darwin*) + os_darwin=yes + TARGET_OS=unix + ;; + gnu*|k*bsd*-gnu*) + os_gnu=yes + TARGET_OS=unix + ;; + *) + AC_MSG_WARN([*** Please add $host to configure.ac checks!]) + ;; +esac diff --git a/scripts/build/autotools/CheckSSL.m4 b/scripts/build/autotools/CheckSSL.m4 new file mode 100644 index 000000000..ab9bf52a7 --- /dev/null +++ b/scripts/build/autotools/CheckSSL.m4 @@ -0,0 +1,215 @@ +PHP_ARG_WITH([mongodb-ssl], + [whether to enable crypto and TLS], + [AS_HELP_STRING([--with-mongodb-ssl=@<:@auto/no/openssl/libressl/darwin@:>@], + [MongoDB: Enable TLS connections and SCRAM-SHA-1 authentication [default=auto]])], + [auto], + [no]) + +PHP_ARG_ENABLE([mongodb-crypto-system-profile], + [whether to use system crypto profile], + [AC_HELP_STRING([--enable-mongodb-crypto-system-profile], + [MongoDB: Use system crypto profile (OpenSSL only) [default=no]])], + [no], + [no]) + +PHP_ARG_WITH([openssl-dir], + [deprecated option for OpenSSL library path], + [AC_HELP_STRING([--with-openssl-dir=@<:@auto/DIR@:>@], + [MongoDB: OpenSSL library path (deprecated for pkg-config) [default=auto]])], + [auto], + [no]) + +PHP_ARG_WITH([system-ciphers], + [deprecated option for whether to use system crypto profile], + AC_HELP_STRING([--enable-system-ciphers], + [MongoDB: whether to use system crypto profile (deprecated for --enable-mongodb-crypto-system-profile) [default=no]]), + [no], + [no]) + +AS_IF([test "$PHP_MONGODB_SSL" = "openssl" -o "$PHP_MONGODB_SSL" = "auto"],[ + found_openssl="no" + + PKG_CHECK_MODULES([PHP_MONGODB_SSL],[openssl],[ + PHP_EVAL_INCLINE([$PHP_MONGODB_SSL_CFLAGS]) + PHP_EVAL_LIBLINE([$PHP_MONGODB_SSL_LIBS],[MONGODB_SHARED_LIBADD]) + PHP_MONGODB_SSL="openssl" + found_openssl="yes" + + old_CFLAGS="$CFLAGS" + CFLAGS="$PHP_MONGODB_SSL_CFLAGS $CFLAGS" + + AC_CHECK_DECLS([ASN1_STRING_get0_data], + [have_ASN1_STRING_get0_data="yes"], + [have_ASN1_STRING_get0_data="no"], + [[#include ]]) + + CFLAGS="$old_CFLAGS" + ],[ + unset OPENSSL_INCDIR + unset OPENSSL_LIBDIR + + dnl Use a list of directories from PHP_SETUP_OPENSSL by default. + dnl Support documented "auto" and older, undocumented "yes" options + if test "$PHP_OPENSSL_DIR" = "auto" -o "$PHP_OPENSSL_DIR" = "yes"; then + PHP_OPENSSL_DIR="/usr/local/ssl /usr/local /usr /usr/local/openssl" + fi + + for i in $PHP_OPENSSL_DIR; do + if test -r $i/include/openssl/evp.h; then + OPENSSL_INCDIR="$i/include" + fi + if test -r $i/$PHP_LIBDIR/libssl.a -o -r $i/$PHP_LIBDIR/libssl.$SHLIB_SUFFIX_NAME; then + OPENSSL_LIBDIR="$i/$PHP_LIBDIR" + fi + test -n "$OPENSSL_INCDIR" && test -n "$OPENSSL_LIBDIR" && break + done + + if test -n "$OPENSSL_LIBDIR"; then + OPENSSL_LIBDIR_LDFLAG="-L$OPENSSL_LIBDIR" + fi + + PHP_CHECK_LIBRARY([crypto], + [EVP_DigestInit_ex], + [have_crypto_lib="yes"], + [have_crypto_lib="no"], + [$OPENSSL_LIBDIR_LDFLAG]) + PHP_CHECK_LIBRARY([ssl], + [SSL_library_init], + [have_ssl_lib="yes"], + [have_ssl_lib="no"], + [$OPENSSL_LIBDIR_LDFLAG -lcrypto]) + + if test "$have_ssl_lib" = "yes" -a "$have_crypto_lib" = "yes"; then + PHP_ADD_LIBRARY([ssl],,[MONGODB_SHARED_LIBADD]) + PHP_ADD_LIBRARY([crypto],,[MONGODB_SHARED_LIBADD]) + + if test -n "$OPENSSL_LIBDIR"; then + PHP_ADD_LIBPATH([$OPENSSL_LIBDIR],[MONGODB_SHARED_LIBADD]) + fi + + if test -n "$OPENSSL_INCDIR"; then + PHP_ADD_INCLUDE($OPENSSL_INCDIR) + fi + + old_CFLAGS="$CFLAGS" + CFLAGS="-I$OPENSSL_INCDIR $CFLAGS" + + AC_CHECK_DECLS([ASN1_STRING_get0_data], + [have_ASN1_STRING_get0_data="yes"], + [have_ASN1_STRING_get0_data="no"], + [[#include ]]) + + CFLAGS="$old_CFLAGS" + + PHP_MONGODB_SSL="openssl" + found_openssl="yes" + fi + ]) + + if test "$PHP_MONGODB_SSL" = "openssl" -a "$found_openssl" != "yes"; then + AC_MSG_ERROR([OpenSSL libraries and development headers could not be found]) + fi +]) + +AS_IF([test "$PHP_MONGODB_SSL" = "libressl" -o "$PHP_MONGODB_SSL" = "auto"],[ + found_libressl="no" + + PKG_CHECK_MODULES([PHP_MONGODB_SSL],[libtls libcrypto],[ + PHP_EVAL_INCLINE([$PHP_MONGODB_SSL_CFLAGS]) + PHP_EVAL_LIBLINE([$PHP_MONGODB_SSL_LIBS],[MONGODB_SHARED_LIBADD]) + PHP_MONGODB_SSL="libressl" + found_libressl="yes" + ],[ + PHP_CHECK_LIBRARY([crypto], + [EVP_DigestInit_ex], + [have_crypto_lib="yes"], + [have_crypto_lib="no"]) + PHP_CHECK_LIBRARY([tls], + [tls_init], + [have_ssl_lib="yes"], + [have_ssl_lib="no"], + [-lcrypto]) + + if test "$have_ssl_lib" = "yes" -a "$have_crypto_lib" = "yes"; then + PHP_ADD_LIBRARY([tls],,[MONGODB_SHARED_LIBADD]) + PHP_ADD_LIBRARY([crypto],,[MONGODB_SHARED_LIBADD]) + PHP_MONGODB_SSL="libressl" + found_libressl="yes" + fi + ]) + + if test "$PHP_MONGODB_SSL" = "libressl" -a "$found_libressl" != "yes"; then + AC_MSG_ERROR([LibreSSL libraries and development headers could not be found]) + fi +]) + +AS_IF([test "$PHP_MONGODB_SSL" = "darwin" -o \( "$PHP_MONGODB_SSL" = "auto" -a "$os_darwin" = "yes" \)],[ + dnl PHP_FRAMEWORKS is only used for SAPI builds, so use MONGODB_SHARED_LIBADD for shared builds + if test "$ext_shared" = "yes"; then + MONGODB_SHARED_LIBADD="-framework Security -framework CoreFoundation $MONGODB_SHARED_LIBADD" + else + PHP_ADD_FRAMEWORK([Security]) + PHP_ADD_FRAMEWORK([CoreFoundation]) + fi + PHP_MONGODB_SSL="darwin" +]) + +AS_IF([test "$PHP_MONGODB_SSL" = "auto"],[ + PHP_MONGODB_SSL="no" +]) + +AC_MSG_CHECKING([which TLS library to use]) +AC_MSG_RESULT([$PHP_MONGODB_SSL]) + +dnl Disable Windows SSL and crypto +AC_SUBST(MONGOC_ENABLE_SSL_SECURE_CHANNEL, 0) +AC_SUBST(MONGOC_ENABLE_CRYPTO_CNG, 0) + +if test "$PHP_MONGODB_SSL" = "openssl" -o "$PHP_MONGODB_SSL" = "libressl" -o "$PHP_MONGODB_SSL" = "darwin"; then + AC_SUBST(MONGOC_ENABLE_SSL, 1) + AC_SUBST(MONGOC_ENABLE_CRYPTO, 1) + if test "$PHP_MONGODB_SSL" = "darwin"; then + AC_SUBST(MONGOC_ENABLE_SSL_OPENSSL, 0) + AC_SUBST(MONGOC_ENABLE_SSL_LIBRESSL, 0) + AC_SUBST(MONGOC_ENABLE_SSL_SECURE_TRANSPORT, 1) + AC_SUBST(MONGOC_ENABLE_CRYPTO_LIBCRYPTO, 0) + AC_SUBST(MONGOC_ENABLE_CRYPTO_COMMON_CRYPTO, 1) + elif test "$PHP_MONGODB_SSL" = "openssl"; then + AC_SUBST(MONGOC_ENABLE_SSL_OPENSSL, 1) + AC_SUBST(MONGOC_ENABLE_SSL_LIBRESSL, 0) + AC_SUBST(MONGOC_ENABLE_SSL_SECURE_TRANSPORT, 0) + AC_SUBST(MONGOC_ENABLE_CRYPTO_LIBCRYPTO, 1) + AC_SUBST(MONGOC_ENABLE_CRYPTO_COMMON_CRYPTO, 0) + elif test "$PHP_MONGODB_SSL" = "libressl"; then + AC_SUBST(MONGOC_ENABLE_SSL_OPENSSL, 0) + AC_SUBST(MONGOC_ENABLE_SSL_LIBRESSL, 1) + AC_SUBST(MONGOC_ENABLE_SSL_SECURE_TRANSPORT, 0) + AC_SUBST(MONGOC_ENABLE_CRYPTO_LIBCRYPTO, 1) + AC_SUBST(MONGOC_ENABLE_CRYPTO_COMMON_CRYPTO, 0) + fi +else + AC_SUBST(MONGOC_ENABLE_SSL, 0) + AC_SUBST(MONGOC_ENABLE_SSL_LIBRESSL, 0) + AC_SUBST(MONGOC_ENABLE_SSL_OPENSSL, 0) + AC_SUBST(MONGOC_ENABLE_SSL_SECURE_TRANSPORT, 0) + AC_SUBST(MONGOC_ENABLE_CRYPTO, 0) + AC_SUBST(MONGOC_ENABLE_CRYPTO_LIBCRYPTO, 0) + AC_SUBST(MONGOC_ENABLE_CRYPTO_COMMON_CRYPTO, 0) +fi + +if test "x$have_ASN1_STRING_get0_data" = "xyes"; then + AC_SUBST(MONGOC_HAVE_ASN1_STRING_GET0_DATA, 1) +else + AC_SUBST(MONGOC_HAVE_ASN1_STRING_GET0_DATA, 0) +fi + +dnl Also consider the deprecated --enable-system-ciphers option +if test "$PHP_MONGODB_CRYPTO_SYSTEM_PROFILE" = "yes" -o "$PHP_SYSTEM_CIPHERS" = "yes"; then + if test "$PHP_MONGODB_SSL" = "openssl"; then + AC_SUBST(MONGOC_ENABLE_CRYPTO_SYSTEM_PROFILE, 1) + else + AC_MSG_ERROR([System crypto profile is only available with OpenSSL]) + fi +else + AC_SUBST(MONGOC_ENABLE_CRYPTO_SYSTEM_PROFILE, 0) +fi diff --git a/scripts/build/autotools/m4/pkg.m4 b/scripts/build/autotools/m4/pkg.m4 new file mode 100644 index 000000000..f26f84c9a --- /dev/null +++ b/scripts/build/autotools/m4/pkg.m4 @@ -0,0 +1,199 @@ +# pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*- +# serial 1 (pkg-config-0.24) +# +# Copyright © 2004 Scott James Remnant . +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +# PKG_PROG_PKG_CONFIG([MIN-VERSION]) +# ---------------------------------- +AC_DEFUN([PKG_PROG_PKG_CONFIG], +[m4_pattern_forbid([^_?PKG_[A-Z_]+$]) +m4_pattern_allow([^PKG_CONFIG(_(PATH|LIBDIR|SYSROOT_DIR|ALLOW_SYSTEM_(CFLAGS|LIBS)))?$]) +m4_pattern_allow([^PKG_CONFIG_(DISABLE_UNINSTALLED|TOP_BUILD_DIR|DEBUG_SPEW)$]) +AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility]) +AC_ARG_VAR([PKG_CONFIG_PATH], [directories to add to pkg-config's search path]) +AC_ARG_VAR([PKG_CONFIG_LIBDIR], [path overriding pkg-config's built-in search path]) + +if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then + AC_PATH_TOOL([PKG_CONFIG], [pkg-config]) +fi +if test -n "$PKG_CONFIG"; then + _pkg_min_version=m4_default([$1], [0.9.0]) + AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version]) + if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then + AC_MSG_RESULT([yes]) + else + AC_MSG_RESULT([no]) + PKG_CONFIG="" + fi +fi[]dnl +])# PKG_PROG_PKG_CONFIG + +# PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) +# +# Check to see whether a particular set of modules exists. Similar +# to PKG_CHECK_MODULES(), but does not set variables or print errors. +# +# Please remember that m4 expands AC_REQUIRE([PKG_PROG_PKG_CONFIG]) +# only at the first occurence in configure.ac, so if the first place +# it's called might be skipped (such as if it is within an "if", you +# have to call PKG_CHECK_EXISTS manually +# -------------------------------------------------------------- +AC_DEFUN([PKG_CHECK_EXISTS], +[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl +if test -n "$PKG_CONFIG" && \ + AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then + m4_default([$2], [:]) +m4_ifvaln([$3], [else + $3])dnl +fi]) + +# _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES]) +# --------------------------------------------- +m4_define([_PKG_CONFIG], +[if test -n "$$1"; then + pkg_cv_[]$1="$$1" + elif test -n "$PKG_CONFIG"; then + PKG_CHECK_EXISTS([$3], + [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes ], + [pkg_failed=yes]) + else + pkg_failed=untried +fi[]dnl +])# _PKG_CONFIG + +# _PKG_SHORT_ERRORS_SUPPORTED +# ----------------------------- +AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED], +[AC_REQUIRE([PKG_PROG_PKG_CONFIG]) +if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then + _pkg_short_errors_supported=yes +else + _pkg_short_errors_supported=no +fi[]dnl +])# _PKG_SHORT_ERRORS_SUPPORTED + + +# PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND], +# [ACTION-IF-NOT-FOUND]) +# +# +# Note that if there is a possibility the first call to +# PKG_CHECK_MODULES might not happen, you should be sure to include an +# explicit call to PKG_PROG_PKG_CONFIG in your configure.ac +# +# +# -------------------------------------------------------------- +AC_DEFUN([PKG_CHECK_MODULES], +[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl +AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl +AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl + +pkg_failed=no +AC_MSG_CHECKING([for $1]) + +_PKG_CONFIG([$1][_CFLAGS], [cflags], [$2]) +_PKG_CONFIG([$1][_LIBS], [libs], [$2]) + +m4_define([_PKG_TEXT], [Alternatively, you may set the environment variables $1[]_CFLAGS +and $1[]_LIBS to avoid the need to call pkg-config. +See the pkg-config man page for more details.]) + +if test $pkg_failed = yes; then + AC_MSG_RESULT([no]) + _PKG_SHORT_ERRORS_SUPPORTED + if test $_pkg_short_errors_supported = yes; then + $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "$2" 2>&1` + else + $1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "$2" 2>&1` + fi + # Put the nasty error message in config.log where it belongs + echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD + + m4_default([$4], [AC_MSG_ERROR( +[Package requirements ($2) were not met: + +$$1_PKG_ERRORS + +Consider adjusting the PKG_CONFIG_PATH environment variable if you +installed software in a non-standard prefix. + +_PKG_TEXT])[]dnl + ]) +elif test $pkg_failed = untried; then + AC_MSG_RESULT([no]) + m4_default([$4], [AC_MSG_FAILURE( +[The pkg-config script could not be found or is too old. Make sure it +is in your PATH or set the PKG_CONFIG environment variable to the full +path to pkg-config. + +_PKG_TEXT + +To get pkg-config, see .])[]dnl + ]) +else + $1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS + $1[]_LIBS=$pkg_cv_[]$1[]_LIBS + AC_MSG_RESULT([yes]) + $3 +fi[]dnl +])# PKG_CHECK_MODULES + + +# PKG_INSTALLDIR(DIRECTORY) +# ------------------------- +# Substitutes the variable pkgconfigdir as the location where a module +# should install pkg-config .pc files. By default the directory is +# $libdir/pkgconfig, but the default can be changed by passing +# DIRECTORY. The user can override through the --with-pkgconfigdir +# parameter. +AC_DEFUN([PKG_INSTALLDIR], +[m4_pushdef([pkg_default], [m4_default([$1], ['${libdir}/pkgconfig'])]) +m4_pushdef([pkg_description], + [pkg-config installation directory @<:@]pkg_default[@:>@]) +AC_ARG_WITH([pkgconfigdir], + [AS_HELP_STRING([--with-pkgconfigdir], pkg_description)],, + [with_pkgconfigdir=]pkg_default) +AC_SUBST([pkgconfigdir], [$with_pkgconfigdir]) +m4_popdef([pkg_default]) +m4_popdef([pkg_description]) +]) dnl PKG_INSTALLDIR + + +# PKG_NOARCH_INSTALLDIR(DIRECTORY) +# ------------------------- +# Substitutes the variable noarch_pkgconfigdir as the location where a +# module should install arch-independent pkg-config .pc files. By +# default the directory is $datadir/pkgconfig, but the default can be +# changed by passing DIRECTORY. The user can override through the +# --with-noarch-pkgconfigdir parameter. +AC_DEFUN([PKG_NOARCH_INSTALLDIR], +[m4_pushdef([pkg_default], [m4_default([$1], ['${datadir}/pkgconfig'])]) +m4_pushdef([pkg_description], + [pkg-config arch-independent installation directory @<:@]pkg_default[@:>@]) +AC_ARG_WITH([noarch-pkgconfigdir], + [AS_HELP_STRING([--with-noarch-pkgconfigdir], pkg_description)],, + [with_noarch_pkgconfigdir=]pkg_default) +AC_SUBST([noarch_pkgconfigdir], [$with_noarch_pkgconfigdir]) +m4_popdef([pkg_default]) +m4_popdef([pkg_description]) +]) dnl PKG_NOARCH_INSTALLDIR From 16fe17c6670b71c70d44607cb8eb38b80895aae7 Mon Sep 17 00:00:00 2001 From: Jeremy Mikola Date: Wed, 17 Jan 2018 14:45:27 -0500 Subject: [PATCH 05/19] Remove old API key for Coveralls This was originally added in dcd732c485a97c76edaec0e2d7290d3560676d82 and should have been removed when @bjori's coverity hook was removed in 5309c172820df3f08982fd7061704496eae3aad7. --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index d203b29ec..9d1ce1e3b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,7 +17,6 @@ env: - MONGODB_ORCHESTRATION_REPO="git+git://github.com/mongodb/mongo-orchestration@master" - MONGODB_ORCHESTRATION_PRESETS_ROOT=`pwd` - secure: "Dofd9NvXIKEat1PMiia3RQgNsJLaKtzZRf9rM4MsqFaBQPbJmVWPANJkayJPcK+l8pLxHyzzH7WqxML+SlBhBTHdJB++1woXxoVwm+sDdwSye6e+eXc3/zRUxb7zyItBZcvVp2tIJpx5kXJb+CoUQakbfWEQQFk4xrOF0R56+8Y=" - - secure: "pfGVPucvgcgcefhtzAVeejlpOtn4TnAqJSTM8mJkBl36KdU9P7hMuD3czQ4drWgzZ373/VT5UVhLu/HNsdbW0YBTeqPKJ4YNjqVVLytI8xT7y2Lw9l+I7o93j98TMgAoo8nVRmp/E4D6yutbKK1eddrcmf899R1iJbw8v8d1Ht8=" before_install: - sudo pip install --upgrade cpp-coveralls From 0e686fd9f08a51d9ba6f49f874e1b553f83c8c83 Mon Sep 17 00:00:00 2001 From: Jeremy Mikola Date: Wed, 17 Jan 2018 15:00:38 -0500 Subject: [PATCH 06/19] Remove old Mongo Orchestration artifacts These lines were originally added before 1.0 when a local Mongo Orchestration process was used to create the test environments (see: PHPC-128). --- .travis.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 9d1ce1e3b..a3f0bb00a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,14 +13,10 @@ env: global: - TEST_PHP_ARGS="-q -s output.txt -g XFAIL,FAIL,BORK,WARN,LEAK,SKIP -x --show-diff" - REPORT_EXIT_STATUS=1 - - MONGODB_ORCHESTRATION="http://localhost:8889" - - MONGODB_ORCHESTRATION_REPO="git+git://github.com/mongodb/mongo-orchestration@master" - - MONGODB_ORCHESTRATION_PRESETS_ROOT=`pwd` - secure: "Dofd9NvXIKEat1PMiia3RQgNsJLaKtzZRf9rM4MsqFaBQPbJmVWPANJkayJPcK+l8pLxHyzzH7WqxML+SlBhBTHdJB++1woXxoVwm+sDdwSye6e+eXc3/zRUxb7zyItBZcvVp2tIJpx5kXJb+CoUQakbfWEQQFk4xrOF0R56+8Y=" before_install: - sudo pip install --upgrade cpp-coveralls - - sudo pip install ${MONGODB_ORCHESTRATION_REPO} - sudo apt-get update - sudo apt-get install gdb valgrind - sudo apt-get install cdbs debhelper build-essential python-lxml From 28c717be477ac53782b16464986454ad191eadf4 Mon Sep 17 00:00:00 2001 From: Jeremy Mikola Date: Thu, 18 Jan 2018 11:00:05 -0500 Subject: [PATCH 07/19] Do not ignore files within .travis.scripts/ If a directory is excluded, a negation on the files within it (e.g. "!dir/*") has no effect. Since .travis.scripts/ is excluded by ".*", we need to negate the directory itself to ensure the files within are tracked. --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 8d560aa31..565c36408 100644 --- a/.gitignore +++ b/.gitignore @@ -49,7 +49,7 @@ php.ini !.github/ !tests/utils/*.php !.travis.yml -!.travis.scripts/* +!.travis.scripts/ !scripts From 83f333065e7f64371138d6f7565e896c936696b6 Mon Sep 17 00:00:00 2001 From: Jeremy Mikola Date: Thu, 18 Jan 2018 14:21:06 -0500 Subject: [PATCH 08/19] LibreSSL cannot extract username subject from X509 certs --- .../standalone-x509-extract_username-001.phpt | 1 + .../standalone-x509-extract_username-002.phpt | 1 + tests/utils/tools.php | 20 +++++++++++++++++++ 3 files changed, 22 insertions(+) diff --git a/tests/connect/standalone-x509-extract_username-001.phpt b/tests/connect/standalone-x509-extract_username-001.phpt index d5502e7fc..25901fcab 100644 --- a/tests/connect/standalone-x509-extract_username-001.phpt +++ b/tests/connect/standalone-x509-extract_username-001.phpt @@ -2,6 +2,7 @@ Connect to MongoDB with SSL and X509 auth and username retrieved from cert --SKIPIF-- + --FILE-- + --FILE-- ')); + + if (preg_match($pattern, $info, $matches) !== 1) { + exit('skip Could not determine SSL library'); + } + + if (!in_array($matches[1], $libs)) { + exit('skip Needs SSL library ' . implode(', ', $libs) . ', but found ' . $matches[1]); + } +} + function CLEANUP($uri, $dbname = DATABASE_NAME, $collname = COLLECTION_NAME) { try { $manager = new MongoDB\Driver\Manager($uri); From 61d4ffbd1827174cdb17cc46d63b24ad02f82ed7 Mon Sep 17 00:00:00 2001 From: Jeremy Mikola Date: Thu, 18 Jan 2018 15:31:18 -0500 Subject: [PATCH 09/19] Coveralls API token is not needed for public projects This was last updated in 90a64b43c9ad8e9e8f297f6f937f9e450ac57ffb when the project was hosted in the 10gen-labs groups. --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index a3f0bb00a..b93626b20 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,7 +13,6 @@ env: global: - TEST_PHP_ARGS="-q -s output.txt -g XFAIL,FAIL,BORK,WARN,LEAK,SKIP -x --show-diff" - REPORT_EXIT_STATUS=1 - - secure: "Dofd9NvXIKEat1PMiia3RQgNsJLaKtzZRf9rM4MsqFaBQPbJmVWPANJkayJPcK+l8pLxHyzzH7WqxML+SlBhBTHdJB++1woXxoVwm+sDdwSye6e+eXc3/zRUxb7zyItBZcvVp2tIJpx5kXJb+CoUQakbfWEQQFk4xrOF0R56+8Y=" before_install: - sudo pip install --upgrade cpp-coveralls From df9c278d3715370ff1bb20b3827763f2bc742b30 Mon Sep 17 00:00:00 2001 From: Jeremy Mikola Date: Thu, 18 Jan 2018 16:36:38 -0500 Subject: [PATCH 10/19] Make core and diff debugging more portable --- .travis.scripts/debug-core.sh | 9 +++++++-- .travis.scripts/debug-diff.sh | 15 +++++++++++++++ .travis.scripts/debug-script.sh | 19 ------------------- .travis.yml | 4 ++-- 4 files changed, 24 insertions(+), 23 deletions(-) create mode 100755 .travis.scripts/debug-diff.sh delete mode 100755 .travis.scripts/debug-script.sh diff --git a/.travis.scripts/debug-core.sh b/.travis.scripts/debug-core.sh index ed167cf93..4e9026652 100755 --- a/.travis.scripts/debug-core.sh +++ b/.travis.scripts/debug-core.sh @@ -1,5 +1,10 @@ #!/bin/sh -PHP=/home/travis/.phpenv/versions/`php -r 'echo PHP_VERSION;'`/bin/php -echo "backtrace full" | gdb $PHP $1 +if [ "${TRAVIS_OS_NAME}" != "osx" ]; then + # https://www.ics.uci.edu/~pattis/common/handouts/macmingweclipse/allexperimental/mac-gdb-install.html + echo "Cannot debug core files on macOS: ${1}" + exit 1 +fi +PHP_BINARY=`which php` +gdb -batch -ex "bt full" -ex "quit" "${PHP_BINARY}" "${1}" diff --git a/.travis.scripts/debug-diff.sh b/.travis.scripts/debug-diff.sh new file mode 100755 index 000000000..e20009c33 --- /dev/null +++ b/.travis.scripts/debug-diff.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +EXP=`echo $1 | sed 's/.diff$/.exp/'` +OUT=`echo $1 | sed 's/.diff$/.out/'` +SEP="--------------------------------------------------------------------------------" + +echo $EXP +echo $SEP +cat $EXP; echo +echo $SEP; echo + +echo $OUT +echo $SEP +cat $OUT; echo +echo $SEP; echo diff --git a/.travis.scripts/debug-script.sh b/.travis.scripts/debug-script.sh deleted file mode 100755 index 9f66723ba..000000000 --- a/.travis.scripts/debug-script.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/sh - -EXP=`echo $1 | sed 's/diff/exp/'` -OUT=`echo $1 | sed 's/diff/out/'` - -echo "FILE $1" - -echo $EXP -echo "======" -cat $EXP -echo "======" - -echo $OUT -echo "======" -cat $OUT -echo "======" - -echo - diff --git a/.travis.yml b/.travis.yml index b93626b20..12d6e0427 100644 --- a/.travis.yml +++ b/.travis.yml @@ -33,5 +33,5 @@ after_success: - make coveralls after_failure: - - find . -name \*core\* -exec ./.travis.scripts/debug-core.sh {} \; - - find . -name \*diff -exec ./.travis.scripts/debug-script.sh {} \; + - find . -name 'core*' -exec .travis.scripts/debug-core.sh {} \; + - find . -name '*.diff' -exec .travis.scripts/debug-diff.sh {} \; From d4e998f6a535fbbd97fc4c2dcfc6a3f8256c687f Mon Sep 17 00:00:00 2001 From: Jeremy Mikola Date: Thu, 18 Jan 2018 21:26:40 -0500 Subject: [PATCH 11/19] Add macOS environments to build matrix --- .travis.scripts/before_install.sh | 26 ++++++++++++++ .travis.scripts/before_script.sh | 21 +++++++++++ .travis.scripts/compile.sh | 42 ---------------------- .travis.yml | 58 +++++++++++++++++++++++++------ 4 files changed, 94 insertions(+), 53 deletions(-) create mode 100755 .travis.scripts/before_install.sh create mode 100755 .travis.scripts/before_script.sh delete mode 100755 .travis.scripts/compile.sh diff --git a/.travis.scripts/before_install.sh b/.travis.scripts/before_install.sh new file mode 100755 index 000000000..9feb7ea5a --- /dev/null +++ b/.travis.scripts/before_install.sh @@ -0,0 +1,26 @@ +#!/bin/sh + +if [ "${TRAVIS_OS_NAME}" = "linux" ]; then + # https://github.com/eddyxu/cpp-coveralls#linux + pip install --user cpp-coveralls +fi + +if [ "${TRAVIS_OS_NAME}" = "osx" ]; then + brew update + brew upgrade + + brew tap homebrew/homebrew-php + brew install "${PHP_VERSION}" + + # http://brewformulas.org/Lcov + brew install lcov + + # https://github.com/eddyxu/cpp-coveralls#os-x + brew install pyenv + eval "$(pyenv init -)" + pyenv install 2.7.6 + pyenv global 2.7.6 + pyenv rehash + pip install cpp-coveralls + pyenv rehash +fi diff --git a/.travis.scripts/before_script.sh b/.travis.scripts/before_script.sh new file mode 100755 index 000000000..30f6f76fc --- /dev/null +++ b/.travis.scripts/before_script.sh @@ -0,0 +1,21 @@ +#!/bin/sh + +CONFIGURE_OPTS="--enable-developer-flags --enable-coverage" + +if [ -n "${SSL_VERSION}" ]; then + CONFIGURE_OPTS="${CONFIGURE_OPTS} --with-mongodb-ssl=${SSL_VERSION}" +fi + +phpize +./configure ${CONFIGURE_OPTS} +make all -j4 +make install + +# Use latest run-tests.php, as older versions don't report a non-zero exit code for failures +wget -O run-tests.php https://raw.githubusercontent.com/php/php-src/master/run-tests.php + +# Add the extension to php.ini +echo "extension=mongodb.so" >> `php --ini | grep "Loaded Configuration" | sed -e "s|.*:\s*||"` + +# Predefine the test server +echo '{"STANDALONE": "mongodb:\/\/127.0.0.1:27017"}' > /tmp/PHONGO-SERVERS.json diff --git a/.travis.scripts/compile.sh b/.travis.scripts/compile.sh deleted file mode 100755 index ccc49f29b..000000000 --- a/.travis.scripts/compile.sh +++ /dev/null @@ -1,42 +0,0 @@ -#!/bin/bash -trap abort_on_failure ERR - -LCOV_VERSION=1.11 - - -abort_on_failure () { - echo "Last command failed, exising" - exit 42; -} - -build_lcov() { - mkdir tmp-lcov - pushd tmp-lcov - wget -O lcov.tar.gz http://downloads.sourceforge.net/ltp/lcov-${LCOV_VERSION}.tar.gz - tar zxf lcov.tar.gz --strip-components=1 - sudo make install - popd -} -build_lcov - -phpize -./configure --enable-developer-flags --enable-coverage -make all -j4 -sudo make install -echo "Use the most-up-to-date run-tests.. old ones like 5.3 don't report failure exit codes" -wget -O run-tests.php https://raw.githubusercontent.com/php/php-src/master/run-tests.php - - - -rm -rf tmp-lcov tmp # coveralls may pick it up and lie about our coverage - -echo "extension=mongodb.so" >> `php --ini | grep "Loaded Configuration" | sed -e "s|.*:\s*||"` - -MONGO=`which mongo` -mongod --version -ls $MONGO* -pwd - - -# Predefine the test server -echo '{"STANDALONE": "mongodb:\/\/127.0.0.1:27017"}' > /tmp/PHONGO-SERVERS.json diff --git a/.travis.yml b/.travis.yml index 12d6e0427..679e48a58 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,10 +1,49 @@ language: php -php: - - 7.2 - - 7.1 - - 7.0 - - 5.6 - - 5.5 + +addons: + apt: + packages: + - gdb + - lcov + +matrix: + include: + - os: linux + dist: trusty + sudo: required + php: 5.5 + - os: linux + dist: trusty + sudo: required + php: 5.6 + - os: linux + dist: trusty + sudo: required + php: 7.0 + - os: linux + dist: trusty + sudo: required + php: 7.1 + - os: linux + dist: trusty + sudo: required + php: 7.2 + - os: osx + osx_image: xcode8.3 + language: generic + env: + - PHP_VERSION: php56 + - os: osx + osx_image: xcode9.2 + language: generic + env: + - PHP_VERSION: php72 + - os: osx + osx_image: xcode9.2 + language: generic + env: + - PHP_VERSION: php72 + - SSL_VERSION: darwin services: - mongodb @@ -15,16 +54,13 @@ env: - REPORT_EXIT_STATUS=1 before_install: - - sudo pip install --upgrade cpp-coveralls - - sudo apt-get update - - sudo apt-get install gdb valgrind - - sudo apt-get install cdbs debhelper build-essential python-lxml + - .travis.scripts/before_install.sh - php -r 'if ( ! ($f = php_ini_loaded_file())) { $f = PHP_CONFIG_FILE_PATH . "/php.ini"; } file_put_contents($f, "variables_order=EGPCS\n", FILE_APPEND); $a = file($f, FILE_IGNORE_NEW_LINES); var_dump($a[count($a)-1]);' before_script: - ulimit -a - ulimit -c unlimited || true - - "./.travis.scripts/compile.sh" + - .travis.scripts/before_script.sh script: - make test From 071f90baccad246e25647afb3f92a1c45f46a1a6 Mon Sep 17 00:00:00 2001 From: Jeremy Mikola Date: Fri, 19 Jan 2018 13:25:12 -0500 Subject: [PATCH 12/19] Upgrading run-tests.php is no longer necessary PHP 5.4 was the last version where run-tests.php failed to report a non-zero exit code after a failure. Since the extension requires 5.5+, we can rely on any existing run-tests.php file. --- .travis.scripts/before_script.sh | 3 --- 1 file changed, 3 deletions(-) diff --git a/.travis.scripts/before_script.sh b/.travis.scripts/before_script.sh index 30f6f76fc..a9555b40a 100755 --- a/.travis.scripts/before_script.sh +++ b/.travis.scripts/before_script.sh @@ -11,9 +11,6 @@ phpize make all -j4 make install -# Use latest run-tests.php, as older versions don't report a non-zero exit code for failures -wget -O run-tests.php https://raw.githubusercontent.com/php/php-src/master/run-tests.php - # Add the extension to php.ini echo "extension=mongodb.so" >> `php --ini | grep "Loaded Configuration" | sed -e "s|.*:\s*||"` From 40cbec3ee796b6cc400428abf19d2acb92e7d351 Mon Sep 17 00:00:00 2001 From: Jeremy Mikola Date: Fri, 19 Jan 2018 13:30:35 -0500 Subject: [PATCH 13/19] Remove macOS environments from build matrix Travis' backlog for macOS builds is quite high, and the environments also do not support MongoDB. We can revisit adding these environments down the line when the infrastructure has improved and we sort out explicit installation of MongoDB versions (see: PHPLIB-299). Note: a macOS build with Secure Channel was manually tested in mongodb/mongo-php-driver#736. --- .travis.yml | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/.travis.yml b/.travis.yml index 679e48a58..3e24d0598 100644 --- a/.travis.yml +++ b/.travis.yml @@ -28,22 +28,6 @@ matrix: dist: trusty sudo: required php: 7.2 - - os: osx - osx_image: xcode8.3 - language: generic - env: - - PHP_VERSION: php56 - - os: osx - osx_image: xcode9.2 - language: generic - env: - - PHP_VERSION: php72 - - os: osx - osx_image: xcode9.2 - language: generic - env: - - PHP_VERSION: php72 - - SSL_VERSION: darwin services: - mongodb From fe7ee68a4dfc5d794bae4d978dfd1d439291ded7 Mon Sep 17 00:00:00 2001 From: Jeremy Mikola Date: Fri, 19 Jan 2018 13:35:51 -0500 Subject: [PATCH 14/19] PHPC-1003: Use container environment for Travis builds --- .travis.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 3e24d0598..69e4007db 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,23 +10,23 @@ matrix: include: - os: linux dist: trusty - sudo: required + sudo: false php: 5.5 - os: linux dist: trusty - sudo: required + sudo: false php: 5.6 - os: linux dist: trusty - sudo: required + sudo: false php: 7.0 - os: linux dist: trusty - sudo: required + sudo: false php: 7.1 - os: linux dist: trusty - sudo: required + sudo: false php: 7.2 services: From 0f8598f0f9c373d9f4a40cdfba88af9906b63ac0 Mon Sep 17 00:00:00 2001 From: Derick Rethans Date: Mon, 22 Jan 2018 10:47:15 +0000 Subject: [PATCH 15/19] Use AC_HELP_STRING for PHP_ARG_ENABLE in config.m4 --- config.m4 | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/config.m4 b/config.m4 index 7f8abc97d..44af8c00f 100644 --- a/config.m4 +++ b/config.m4 @@ -1,6 +1,8 @@ dnl config.m4 for extension mongodb -PHP_ARG_ENABLE(mongodb, whether to enable mongodb support, -[ --enable-mongodb Enable mongodb support]) +PHP_ARG_ENABLE([mongodb], + [whether to enable MongoDB support], + [AC_HELP_STRING([--enable-mongodb], + [Enable MongoDB support])]) dnl borrowed from libmongoc configure.ac dnl AS_VAR_COPY is available in AC 2.64 and on, but we only require 2.60. @@ -88,8 +90,12 @@ if test "$PHP_MONGODB" != "no"; then AC_MSG_ERROR([not supported. Need a PHP version >= 5.5.0 (found $PHP_MONGODB_FOUND_VERSION)]) fi - PHP_ARG_ENABLE(developer-flags, whether to enable developer build flags, - [ --enable-developer-flags Enable developer flags],, no) + PHP_ARG_ENABLE([developer-flags], + [whether to enable developer build flags], + [AC_HELP_STRING([--enable-developer-flags], + [MongoDB: Enable developer flags])], + [], + [no]) if test "$PHP_DEVELOPER_FLAGS" = "yes"; then dnl Warn about functions which might be candidates for format attributes @@ -140,8 +146,12 @@ if test "$PHP_MONGODB" != "no"; then fi - PHP_ARG_ENABLE(coverage, whether to enable code coverage, - [ --enable-coverage Enable developer code coverage information],, no) + PHP_ARG_ENABLE([coverage], + [whether to enable code coverage], + [AC_HELP_STRING([--enable-coverage], + [MongoDB: Enable developer code coverage information])], + [], + [no]) if test "$PHP_COVERAGE" = "yes"; then PHP_CHECK_GCC_ARG(-fprofile-arcs, COVERAGE_CFLAGS="$COVERAGE_CFLAGS -fprofile-arcs") @@ -217,9 +227,9 @@ if test "$PHP_MONGODB" != "no"; then " PHP_ARG_WITH(libbson, whether to use system libbson, - [ --with-libbson Use system libbson], no, no) + [ --with-libbson MongoDB: Use system libbson], no, no) PHP_ARG_WITH(libmongoc, whether to use system libmongoc, - [ --with-libmongoc Use system libmongoc], no, no) + [ --with-libmongoc MongoDB: Use system libmongoc], no, no) if test "$PHP_LIBBSON" != "no"; then if test "$PHP_LIBMONGOC" = "no"; then @@ -326,7 +336,7 @@ if test "$PHP_MONGODB" != "no"; then PHP_ARG_WITH(mongodb-sasl, for Cyrus SASL support, - [ --with-mongodb-sasl[=DIR] mongodb: Include Cyrus SASL support], auto, no) + [ --with-mongodb-sasl[=DIR] MongoDB: Include Cyrus SASL support], auto, no) AC_SUBST(MONGOC_ENABLE_SASL, 0) AC_SUBST(MONGOC_HAVE_SASL_CLIENT_DONE, 0) From c2988bb9a7329ad160b8cc6019ae688084bbb953 Mon Sep 17 00:00:00 2001 From: Derick Rethans Date: Mon, 22 Jan 2018 10:55:09 +0000 Subject: [PATCH 16/19] PHPC-888: Make sure you can only select "darwin" on macOS --- scripts/build/autotools/CheckSSL.m4 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scripts/build/autotools/CheckSSL.m4 b/scripts/build/autotools/CheckSSL.m4 index ab9bf52a7..f100585c5 100644 --- a/scripts/build/autotools/CheckSSL.m4 +++ b/scripts/build/autotools/CheckSSL.m4 @@ -144,6 +144,9 @@ AS_IF([test "$PHP_MONGODB_SSL" = "libressl" -o "$PHP_MONGODB_SSL" = "auto"],[ ]) AS_IF([test "$PHP_MONGODB_SSL" = "darwin" -o \( "$PHP_MONGODB_SSL" = "auto" -a "$os_darwin" = "yes" \)],[ + if test "$os_darwin" = "no"; then + AC_MSG_ERROR([Darwin SSL is only supported on macOS]) + fi dnl PHP_FRAMEWORKS is only used for SAPI builds, so use MONGODB_SHARED_LIBADD for shared builds if test "$ext_shared" = "yes"; then MONGODB_SHARED_LIBADD="-framework Security -framework CoreFoundation $MONGODB_SHARED_LIBADD" From 0002e2d37c9cf4dcc6cfa8406725910c42111c8e Mon Sep 17 00:00:00 2001 From: Derick Rethans Date: Mon, 22 Jan 2018 11:05:52 +0000 Subject: [PATCH 17/19] Move crypto system profile flags below OpenSSL detection This makes for more chronological configure output --- scripts/build/autotools/CheckSSL.m4 | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/scripts/build/autotools/CheckSSL.m4 b/scripts/build/autotools/CheckSSL.m4 index f100585c5..e45bdd94c 100644 --- a/scripts/build/autotools/CheckSSL.m4 +++ b/scripts/build/autotools/CheckSSL.m4 @@ -5,13 +5,6 @@ PHP_ARG_WITH([mongodb-ssl], [auto], [no]) -PHP_ARG_ENABLE([mongodb-crypto-system-profile], - [whether to use system crypto profile], - [AC_HELP_STRING([--enable-mongodb-crypto-system-profile], - [MongoDB: Use system crypto profile (OpenSSL only) [default=no]])], - [no], - [no]) - PHP_ARG_WITH([openssl-dir], [deprecated option for OpenSSL library path], [AC_HELP_STRING([--with-openssl-dir=@<:@auto/DIR@:>@], @@ -19,13 +12,6 @@ PHP_ARG_WITH([openssl-dir], [auto], [no]) -PHP_ARG_WITH([system-ciphers], - [deprecated option for whether to use system crypto profile], - AC_HELP_STRING([--enable-system-ciphers], - [MongoDB: whether to use system crypto profile (deprecated for --enable-mongodb-crypto-system-profile) [default=no]]), - [no], - [no]) - AS_IF([test "$PHP_MONGODB_SSL" = "openssl" -o "$PHP_MONGODB_SSL" = "auto"],[ found_openssl="no" @@ -206,6 +192,20 @@ else AC_SUBST(MONGOC_HAVE_ASN1_STRING_GET0_DATA, 0) fi +PHP_ARG_ENABLE([mongodb-crypto-system-profile], + [whether to use system crypto profile], + [AC_HELP_STRING([--enable-mongodb-crypto-system-profile], + [MongoDB: Use system crypto profile (OpenSSL only) [default=no]])], + [no], + [no]) + +PHP_ARG_WITH([system-ciphers], + [deprecated option for whether to use system crypto profile], + AC_HELP_STRING([--enable-system-ciphers], + [MongoDB: whether to use system crypto profile (deprecated for --enable-mongodb-crypto-system-profile) [default=no]]), + [no], + [no]) + dnl Also consider the deprecated --enable-system-ciphers option if test "$PHP_MONGODB_CRYPTO_SYSTEM_PROFILE" = "yes" -o "$PHP_SYSTEM_CIPHERS" = "yes"; then if test "$PHP_MONGODB_SSL" = "openssl"; then From 6f9bd6e842b341dadd430c6e6295bd3431d79244 Mon Sep 17 00:00:00 2001 From: Jeremy Mikola Date: Mon, 22 Jan 2018 11:57:17 -0500 Subject: [PATCH 18/19] Document "no" defaults for PHP_ARG_ENABLE flags in config.m4 --- config.m4 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/config.m4 b/config.m4 index 44af8c00f..7bcafdfde 100644 --- a/config.m4 +++ b/config.m4 @@ -93,8 +93,8 @@ if test "$PHP_MONGODB" != "no"; then PHP_ARG_ENABLE([developer-flags], [whether to enable developer build flags], [AC_HELP_STRING([--enable-developer-flags], - [MongoDB: Enable developer flags])], - [], + [MongoDB: Enable developer flags [default=no]])], + [no], [no]) if test "$PHP_DEVELOPER_FLAGS" = "yes"; then @@ -149,8 +149,8 @@ if test "$PHP_MONGODB" != "no"; then PHP_ARG_ENABLE([coverage], [whether to enable code coverage], [AC_HELP_STRING([--enable-coverage], - [MongoDB: Enable developer code coverage information])], - [], + [MongoDB: Enable developer code coverage information [default=no]])], + [no], [no]) if test "$PHP_COVERAGE" = "yes"; then From 82516b394a69ea6715bcee7e4d3fc965edb8e877 Mon Sep 17 00:00:00 2001 From: Jeremy Mikola Date: Mon, 22 Jan 2018 11:59:16 -0500 Subject: [PATCH 19/19] Use AC_HELP_STRING for PHP_ARG_WITH in config.m4 This also documents "yes" values for the libbson/libmongoc parameters, and the "auto" default for SASL. --- config.m4 | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/config.m4 b/config.m4 index 7bcafdfde..d90743625 100644 --- a/config.m4 +++ b/config.m4 @@ -226,10 +226,18 @@ if test "$PHP_MONGODB" != "no"; then src/MongoDB/Monitoring/functions.c \ " - PHP_ARG_WITH(libbson, whether to use system libbson, - [ --with-libbson MongoDB: Use system libbson], no, no) - PHP_ARG_WITH(libmongoc, whether to use system libmongoc, - [ --with-libmongoc MongoDB: Use system libmongoc], no, no) + PHP_ARG_WITH([libbson], + [whether to use system libbson], + [AS_HELP_STRING([--with-libbson=@<:@yes/no@:>@], + [MongoDB: Use system libbson [default=no]])], + [no], + [no]) + PHP_ARG_WITH([libmongoc], + [whether to use system libmongoc], + [AS_HELP_STRING([--with-libmongoc=@<:@yes/no@:>@], + [MongoDB: Use system libmongoc [default=no]])], + [no], + [no]) if test "$PHP_LIBBSON" != "no"; then if test "$PHP_LIBMONGOC" = "no"; then @@ -335,8 +343,12 @@ if test "$PHP_MONGODB" != "no"; then fi - PHP_ARG_WITH(mongodb-sasl, for Cyrus SASL support, - [ --with-mongodb-sasl[=DIR] MongoDB: Include Cyrus SASL support], auto, no) + PHP_ARG_WITH([mongodb-sasl], + [for Cyrus SASL support], + [AC_HELP_STRING([--with-mongodb-sasl=@<:@auto/no/DIR@:>@], + [MongoDB: Cyrus SASL support [default=auto]])], + [auto], + [no]) AC_SUBST(MONGOC_ENABLE_SASL, 0) AC_SUBST(MONGOC_HAVE_SASL_CLIENT_DONE, 0)