-
Notifications
You must be signed in to change notification settings - Fork 7.9k
[WIP] Migrate more checks to the pkg-config macro #3654
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
941a1da
5e81cf6
d79ef88
708d739
aa93cc0
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 |
---|---|---|
|
@@ -2231,115 +2231,21 @@ 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 "$PHP_OPENSSL" = "yes"; then | ||
PKG_CHECK_MODULES([OPENSSL], [openssl >= 1.0.1], [found_openssl=yes], | ||
[AC_MSG_ERROR([OpenSSL version 1.0.1 or greater required.])]) | ||
|
||
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" | ||
if test -n "$OPENSSL_CFLAGS"; then | ||
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 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. That's convenient. :) |
||
PHP_EVAL_INCLINE($OPENSSL_CFLAGS) | ||
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 <evp.h>]) | ||
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 <openssl/opensslv.h> | ||
#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) | ||
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) | ||
|
||
ifelse([$2],[],:,[$2]) | ||
ifelse([$3],[],,[else $3]) | ||
fi | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,21 +11,10 @@ PHP_ARG_WITH(pcre-jit,,[ --with-pcre-jit Enable PCRE JIT functionality | |
|
||
if test "$PHP_PCRE_REGEX" != "yes" && test "$PHP_PCRE_REGEX" != "no"; then | ||
|
||
# FIXME: don't define "I'm not bundled" as only versions installed in /usr | ||
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 sure what the best way to do this is. PCRE is always present and should default to the bundled lib. Maybe replace the existing |
||
if test "$PHP_PCRE_REGEX" = "/usr"; then | ||
if test -z "$PKG_CONFIG"; then | ||
AC_PATH_PROG(PKG_CONFIG, pkg-config, no) | ||
fi | ||
if test -x "$PKG_CONFIG"; then | ||
AC_MSG_CHECKING(for PCRE2 10.30 or greater) | ||
if $PKG_CONFIG --atleast-version 10.30 libpcre2-8; then | ||
PCRE2_VER=`$PKG_CONFIG --modversion libpcre2-8` | ||
AC_MSG_RESULT($PCRE2_VER) | ||
else | ||
AC_MSG_ERROR(PCRE2 version 10.30 or later is required to compile php with PCRE2 support) | ||
fi | ||
PCRE2_LIB=`$PKG_CONFIG --libs libpcre2-8` | ||
PCRE2_INC=`$PKG_CONFIG --cflags libpcre2-8` | ||
fi | ||
PKG_CHECK_MODULES([PCRE2], [libpcre2-8 >= 10.30], , | ||
AC_MSG_ERROR(PCRE2 version 10.30 or later is required to compile php with PCRE2 support)) | ||
fi | ||
|
||
dnl PCRE2 in a non standard prefix should still have its config tool. | ||
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. The 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. So this would automatically try to find the system version, then fallback on bundled code only if the system one isn't found? 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. There's two level of checks there, first for yes/no, then for 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. And then it ignores the argument entirely? I'm thinking it's best to check for "external" here. Or... yes would look for external libraries and fall back on the bundled one, external/internal could force one or the other. If we want to get fancy, that is. |
||
|
@@ -41,13 +30,13 @@ PHP_ARG_WITH(pcre-jit,,[ --with-pcre-jit Enable PCRE JIT functionality | |
AC_MSG_RESULT($PCRE2_VER) | ||
fi | ||
PCRE2_LIB=`$PCRE2_CONF --libs8` | ||
PCRE2_INC=`$PCRE2_CONF --cflags` | ||
PCRE2_CFLAGS=`$PCRE2_CONF --cflags` | ||
else | ||
AC_MSG_ERROR(Couldn't find pcre2-config) | ||
fi | ||
fi | ||
|
||
PHP_EVAL_INCLINE($PCRE2_INC) | ||
PHP_EVAL_INCLINE($PCRE2_CFLAGS) | ||
PHP_EVAL_LIBLINE($PCRE2_LIB) | ||
AC_DEFINE(PCRE2_CODE_UNIT_WIDTH, 8, [ ]) | ||
AC_DEFINE(HAVE_PCRE, 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.
Something I missed before... PHP_SETUP_OPENSSL is also used in places where openssl is an optional extension, while this will make it a hard error. This should be using $2 and $3 as the success/failure actions.