Skip to content

Commit eb267ab

Browse files
committed
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.
1 parent 4800539 commit eb267ab

File tree

2 files changed

+6
-102
lines changed

2 files changed

+6
-102
lines changed

acinclude.m4

Lines changed: 5 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -2231,117 +2231,21 @@ dnl Common setup macro for openssl
22312231
dnl
22322232
AC_DEFUN([PHP_SETUP_OPENSSL],[
22332233
found_openssl=no
2234-
unset OPENSSL_INCDIR
2235-
unset OPENSSL_LIBDIR
22362234
22372235
dnl Empty variable means 'no'
22382236
test -z "$PHP_OPENSSL" && PHP_OPENSSL=no
22392237
test -z "$PHP_IMAP_SSL" && PHP_IMAP_SSL=no
22402238
2241-
dnl Fallbacks for different configure options
2242-
if test "$PHP_OPENSSL" != "no"; then
2243-
PHP_OPENSSL_DIR=$PHP_OPENSSL
2244-
elif test "$PHP_IMAP_SSL" != "no"; then
2245-
PHP_OPENSSL_DIR=$PHP_IMAP_SSL
2246-
fi
2247-
2248-
dnl First try to find pkg-config
2249-
if test -z "$PKG_CONFIG"; then
2250-
AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
2251-
fi
2252-
2253-
dnl If pkg-config is found try using it
2254-
if test "$PHP_OPENSSL_DIR" = "yes" && test -x "$PKG_CONFIG" && $PKG_CONFIG --exists openssl; then
2255-
if $PKG_CONFIG --atleast-version=1.0.1 openssl; then
2256-
found_openssl=yes
2257-
OPENSSL_LIBS=`$PKG_CONFIG --libs openssl`
2258-
OPENSSL_INCS=`$PKG_CONFIG --cflags-only-I openssl`
2259-
OPENSSL_INCDIR=`$PKG_CONFIG --variable=includedir openssl`
2260-
else
2261-
AC_MSG_ERROR([OpenSSL version 1.0.1 or greater required.])
2262-
fi
2239+
if test "$PHP_OPENSSL" = "yes"; then
2240+
PKG_CHECK_MODULES([OPENSSL], [openssl >= 1.0.1], [found_openssl=yes],
2241+
[AC_MSG_ERROR([OpenSSL version 1.0.1 or greater required.])])
22632242
22642243
if test -n "$OPENSSL_LIBS"; then
22652244
PHP_EVAL_LIBLINE($OPENSSL_LIBS, $1)
22662245
fi
2267-
if test -n "$OPENSSL_INCS"; then
2268-
PHP_EVAL_INCLINE($OPENSSL_INCS)
2269-
fi
2270-
fi
2271-
2272-
dnl If pkg-config fails for some reason, revert to the old method
2273-
if test "$found_openssl" = "no"; then
2274-
2275-
if test "$PHP_OPENSSL_DIR" = "yes"; then
2276-
PHP_OPENSSL_DIR="/usr/local/ssl /usr/local /usr /usr/local/openssl"
2277-
fi
2278-
2279-
for i in $PHP_OPENSSL_DIR; do
2280-
if test -r $i/include/openssl/evp.h; then
2281-
OPENSSL_INCDIR=$i/include
2282-
fi
2283-
if test -r $i/$PHP_LIBDIR/libssl.a -o -r $i/$PHP_LIBDIR/libssl.$SHLIB_SUFFIX_NAME; then
2284-
OPENSSL_LIBDIR=$i/$PHP_LIBDIR
2285-
fi
2286-
test -n "$OPENSSL_INCDIR" && test -n "$OPENSSL_LIBDIR" && break
2287-
done
2288-
2289-
if test -z "$OPENSSL_INCDIR"; then
2290-
AC_MSG_ERROR([Cannot find OpenSSL's <evp.h>])
2291-
fi
2292-
2293-
if test -z "$OPENSSL_LIBDIR"; then
2294-
AC_MSG_ERROR([Cannot find OpenSSL's libraries])
2246+
if test -n "$OPENSSL_CFLAGS"; then
2247+
PHP_EVAL_INCLINE($OPENSSL_CFLAGS)
22952248
fi
2296-
2297-
old_CPPFLAGS=$CPPFLAGS
2298-
CPPFLAGS=-I$OPENSSL_INCDIR
2299-
AC_MSG_CHECKING([for OpenSSL version])
2300-
AC_EGREP_CPP(yes,[
2301-
#include <openssl/opensslv.h>
2302-
#if OPENSSL_VERSION_NUMBER >= 0x10001001L
2303-
yes
2304-
#endif
2305-
],[
2306-
AC_MSG_RESULT([>= 1.0.1])
2307-
],[
2308-
AC_MSG_ERROR([OpenSSL version 1.0.1 or greater required.])
2309-
])
2310-
CPPFLAGS=$old_CPPFLAGS
2311-
2312-
PHP_ADD_INCLUDE($OPENSSL_INCDIR)
2313-
2314-
PHP_CHECK_LIBRARY(crypto, CRYPTO_free, [
2315-
PHP_ADD_LIBRARY(crypto,,$1)
2316-
],[
2317-
AC_MSG_ERROR([libcrypto not found!])
2318-
],[
2319-
-L$OPENSSL_LIBDIR
2320-
])
2321-
2322-
old_LIBS=$LIBS
2323-
LIBS="$LIBS -lcrypto"
2324-
PHP_CHECK_LIBRARY(ssl, SSL_CTX_set_ssl_version, [
2325-
found_openssl=yes
2326-
],[
2327-
AC_MSG_ERROR([libssl not found!])
2328-
],[
2329-
-L$OPENSSL_LIBDIR
2330-
])
2331-
LIBS=$old_LIBS
2332-
PHP_ADD_LIBRARY(ssl,,$1)
2333-
PHP_ADD_LIBRARY(crypto,,$1)
2334-
2335-
PHP_ADD_LIBPATH($OPENSSL_LIBDIR, $1)
2336-
fi
2337-
2338-
if test "$found_openssl" = "yes"; then
2339-
dnl For apache 1.3.x static build
2340-
OPENSSL_INCDIR_OPT=-I$OPENSSL_INCDIR
2341-
AC_SUBST(OPENSSL_INCDIR_OPT)
2342-
2343-
ifelse([$2],[],:,[$2])
2344-
ifelse([$3],[],,[else $3])
23452249
fi
23462250
])
23472251

ext/openssl/config0.m4

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
dnl config.m4 for extension openssl
22

33
PHP_ARG_WITH(openssl, for OpenSSL support,
4-
[ --with-openssl[=DIR] Include OpenSSL support (requires OpenSSL >= 1.0.1)])
4+
[ --with-openssl Include OpenSSL support (requires OpenSSL >= 1.0.1)])
55

66
PHP_ARG_WITH(kerberos, for Kerberos support,
77
[ --with-kerberos[=DIR] OPENSSL: Include Kerberos support], no, no)

0 commit comments

Comments
 (0)