From: Eli Schwartz Date: Wed, 7 Nov 2018 19:24:23 +0000 (-0500) Subject: ext/openssl: port to pkg-config macro and consistently require its use X-Git-Tag: php-7.4.0alpha1~1237 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=fe8fdfa3bd588d80ce60f6b3848058239e0a760f;p=php ext/openssl: port to pkg-config macro and consistently require its use openssl 0.9.8 in July 2005 first added pkg-config support, which is earlier than the minimum supported version for php. This should therefore be uiversally supported. --- diff --git a/acinclude.m4 b/acinclude.m4 index 7562c4987b..21f44980f6 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -2197,115 +2197,18 @@ dnl Common setup macro for openssl dnl AC_DEFUN([PHP_SETUP_OPENSSL],[ found_openssl=no - unset OPENSSL_INCDIR - unset OPENSSL_LIBDIR dnl Empty variable means 'no' test -z "$PHP_OPENSSL" && PHP_OPENSSL=no test -z "$PHP_IMAP_SSL" && PHP_IMAP_SSL=no - dnl Fallbacks for different configure options if test "$PHP_OPENSSL" != "no"; then - PHP_OPENSSL_DIR=$PHP_OPENSSL - elif test "$PHP_IMAP_SSL" != "no"; then - PHP_OPENSSL_DIR=$PHP_IMAP_SSL - fi - - dnl First try to find pkg-config - if test -z "$PKG_CONFIG"; then - AC_PATH_PROG(PKG_CONFIG, pkg-config, no) - fi - - dnl If pkg-config is found try using it - if test "$PHP_OPENSSL_DIR" = "yes" && test -x "$PKG_CONFIG" && $PKG_CONFIG --exists openssl; then - if $PKG_CONFIG --atleast-version=1.0.1 openssl; then - found_openssl=yes - OPENSSL_LIBS=`$PKG_CONFIG --libs openssl` - OPENSSL_INCS=`$PKG_CONFIG --cflags-only-I openssl` - OPENSSL_INCDIR=`$PKG_CONFIG --variable=includedir openssl` - else - AC_MSG_ERROR([OpenSSL version 1.0.1 or greater required.]) - fi - - if test -n "$OPENSSL_LIBS"; then - PHP_EVAL_LIBLINE($OPENSSL_LIBS, $1) - fi - if test -n "$OPENSSL_INCS"; then - PHP_EVAL_INCLINE($OPENSSL_INCS) - fi - fi - - dnl If pkg-config fails for some reason, revert to the old method - if test "$found_openssl" = "no"; then - - if test "$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 -z "$OPENSSL_INCDIR"; then - AC_MSG_ERROR([Cannot find OpenSSL's ]) - fi - - if test -z "$OPENSSL_LIBDIR"; then - AC_MSG_ERROR([Cannot find OpenSSL's libraries]) - fi - - old_CPPFLAGS=$CPPFLAGS - CPPFLAGS=-I$OPENSSL_INCDIR - AC_MSG_CHECKING([for OpenSSL version]) - AC_EGREP_CPP(yes,[ -#include -#if OPENSSL_VERSION_NUMBER >= 0x10001001L - yes -#endif - ],[ - AC_MSG_RESULT([>= 1.0.1]) - ],[ - AC_MSG_ERROR([OpenSSL version 1.0.1 or greater required.]) - ]) - CPPFLAGS=$old_CPPFLAGS - - PHP_ADD_INCLUDE($OPENSSL_INCDIR) - - PHP_CHECK_LIBRARY(crypto, CRYPTO_free, [ - PHP_ADD_LIBRARY(crypto,,$1) - ],[ - AC_MSG_ERROR([libcrypto not found!]) - ],[ - -L$OPENSSL_LIBDIR - ]) - - old_LIBS=$LIBS - LIBS="$LIBS -lcrypto" - PHP_CHECK_LIBRARY(ssl, SSL_CTX_set_ssl_version, [ - found_openssl=yes - ],[ - AC_MSG_ERROR([libssl not found!]) - ],[ - -L$OPENSSL_LIBDIR - ]) - LIBS=$old_LIBS - PHP_ADD_LIBRARY(ssl,,$1) - PHP_ADD_LIBRARY(crypto,,$1) - - PHP_ADD_LIBPATH($OPENSSL_LIBDIR, $1) + PKG_CHECK_MODULES([OPENSSL], [openssl >= 1.0.1], [found_openssl=yes]) fi if test "$found_openssl" = "yes"; then - dnl For apache 1.3.x static build - OPENSSL_INCDIR_OPT=-I$OPENSSL_INCDIR - AC_SUBST(OPENSSL_INCDIR_OPT) - + PHP_EVAL_LIBLINE($OPENSSL_LIBS, $1) + PHP_EVAL_INCLINE($OPENSSL_CFLAGS) ifelse([$2],[],:,[$2]) ifelse([$3],[],,[else $3]) fi diff --git a/ext/openssl/config0.m4 b/ext/openssl/config0.m4 index a707ea525e..3b5836f1f8 100644 --- a/ext/openssl/config0.m4 +++ b/ext/openssl/config0.m4 @@ -1,7 +1,7 @@ dnl config.m4 for extension openssl PHP_ARG_WITH(openssl, for OpenSSL support, -[ --with-openssl[=DIR] Include OpenSSL support (requires OpenSSL >= 1.0.1)]) +[ --with-openssl Include OpenSSL support (requires OpenSSL >= 1.0.1)]) PHP_ARG_WITH(kerberos, for Kerberos support, [ --with-kerberos[=DIR] OPENSSL: Include Kerberos support], no, no)