Skip to content

Autotools: Refactor curl config.m4 #14948

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

Merged
merged 1 commit into from
Jul 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 30 additions & 32 deletions ext/curl/config.m4
Original file line number Diff line number Diff line change
Expand Up @@ -7,30 +7,26 @@ if test "$PHP_CURL" != "no"; then
PKG_CHECK_MODULES([CURL], [libcurl >= 7.61.0])
PKG_CHECK_VAR([CURL_FEATURES], [libcurl], [supported_features])

PHP_EVAL_LIBLINE($CURL_LIBS, CURL_SHARED_LIBADD)
PHP_EVAL_INCLINE($CURL_CFLAGS)
PHP_EVAL_LIBLINE([$CURL_LIBS], [CURL_SHARED_LIBADD])
PHP_EVAL_INCLINE([$CURL_CFLAGS])

AC_MSG_CHECKING([for SSL support in libcurl])
AS_CASE([$CURL_FEATURES],
[*SSL*], [
CURL_SSL=yes
AC_MSG_RESULT([yes])
], [
CURL_SSL=no
AC_MSG_RESULT([no])
])
AS_CASE([$CURL_FEATURES], [*SSL*], [CURL_SSL=yes], [CURL_SSL=no])
AC_MSG_RESULT([$CURL_SSL])

AS_IF([test "$PHP_THREAD_SAFETY" = yes && test "$CURL_SSL" = yes], [
save_LDFLAGS="$LDFLAGS"
LDFLAGS="$LDFLAGS $CURL_LIBS"
AS_IF([test "x$PHP_THREAD_SAFETY" = xyes && test "x$CURL_SSL" = xyes],
[AC_CACHE_CHECK([whether libcurl is linked against old OpenSSL < 1.1],
[php_cv_lib_curl_ssl], [
save_LIBS=$LIBS
save_CFLAGS=$CFLAGS
LIBS="$LIBS $CURL_SHARED_LIBADD"
CFLAGS="$CFLAGS $CURL_CFLAGS"

AC_CACHE_CHECK([for libcurl linked against old OpenSSL < 1.1],
[php_cv_lib_curl_ssl],
[AC_RUN_IFELSE([AC_LANG_PROGRAM([
AC_RUN_IFELSE([AC_LANG_PROGRAM([
#include <stdio.h>
#include <strings.h>
#include <curl/curl.h>
], [
], [
curl_version_info_data *data = curl_version_info(CURLVERSION_NOW);

if (data && data->ssl_version && *data->ssl_version) {
Expand Down Expand Up @@ -60,29 +56,31 @@ if test "$PHP_CURL" != "no"; then
/* No SSL support */
return 1;
])],
[php_cv_lib_curl_ssl=yes],
[php_cv_lib_curl_ssl=no],
[php_cv_lib_curl_ssl=no])])
[php_cv_lib_curl_ssl=yes],
[php_cv_lib_curl_ssl=no],
[php_cv_lib_curl_ssl=no])
LIBS=$save_LIBS
CFLAGS=$save_CFLAGS
])

AS_VAR_IF([php_cv_lib_curl_ssl], [yes], [
AC_DEFINE([HAVE_CURL_OLD_OPENSSL], [1], [Have cURL with old OpenSSL])
AC_DEFINE([HAVE_CURL_OLD_OPENSSL], [1],
[Define to 1 if libcurl is linked against old OpenSSL < 1.1.])
PHP_SETUP_OPENSSL([CURL_SHARED_LIBADD],
[AC_CHECK_HEADERS([openssl/crypto.h])])
])

LDFLAGS="$save_LDFLAGS"
])

PHP_CHECK_LIBRARY(curl,curl_easy_perform,
[
AC_DEFINE(HAVE_CURL,1,[ ])
],[
AC_MSG_ERROR(There is something wrong. Please check config.log for more information.)
],[
$CURL_LIBS
])
PHP_CHECK_LIBRARY([curl],
[curl_easy_perform],
[AC_DEFINE([HAVE_CURL], [1],
[Define to 1 if curl extension is available.])],
[AC_MSG_ERROR([The libcurl check failed. Please, check config.log for details.])],
[$CURL_LIBS])

PHP_NEW_EXTENSION(curl, interface.c multi.c share.c curl_file.c, $ext_shared)
PHP_NEW_EXTENSION([curl],
[interface.c multi.c share.c curl_file.c],
[$ext_shared])
PHP_INSTALL_HEADERS([ext/curl], [php_curl.h])
PHP_SUBST([CURL_SHARED_LIBADD])
fi
2 changes: 1 addition & 1 deletion ext/curl/config.w32
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ if (PHP_CURL != "no") {
CHECK_LIB("nghttp2.lib", "curl", PHP_CURL))
) {
EXTENSION("curl", "interface.c multi.c share.c curl_file.c");
AC_DEFINE('HAVE_CURL', 1, 'Have cURL library');
AC_DEFINE('HAVE_CURL', 1, 'Define to 1 if curl extension is available.');
ADD_FLAG("CFLAGS_CURL", "/D CURL_STATICLIB /D PHP_CURL_EXPORTS=1");
PHP_INSTALL_HEADERS("ext/curl", "php_curl.h");
} else {
Expand Down
Loading