Skip to content

Commit 09d61b6

Browse files
authored
Autotools: Refactor curl config.m4 (#14948)
- CS synced - When checking for libcurl linked against old OpenSSL the LIBS can be used instead of LDFLAGS to put -lcurl to proper place. Also, flags manipulation variables are wrapped in the AC_CACHE_CHECK commands because there is also OpenSSL setup done later in the code which changes LDFLAGS, LIBS and/or CFLAGS. - CFLAGS added to the check to have edge case of -I flags of custom installation paths taken into consideration - All macro arguments quoted - SSL check simplified a bit - The HAVE_CURL symbol help text synced
1 parent 35f64bb commit 09d61b6

File tree

2 files changed

+31
-33
lines changed

2 files changed

+31
-33
lines changed

ext/curl/config.m4

Lines changed: 30 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -7,30 +7,26 @@ if test "$PHP_CURL" != "no"; then
77
PKG_CHECK_MODULES([CURL], [libcurl >= 7.61.0])
88
PKG_CHECK_VAR([CURL_FEATURES], [libcurl], [supported_features])
99

10-
PHP_EVAL_LIBLINE($CURL_LIBS, CURL_SHARED_LIBADD)
11-
PHP_EVAL_INCLINE($CURL_CFLAGS)
10+
PHP_EVAL_LIBLINE([$CURL_LIBS], [CURL_SHARED_LIBADD])
11+
PHP_EVAL_INCLINE([$CURL_CFLAGS])
1212

1313
AC_MSG_CHECKING([for SSL support in libcurl])
14-
AS_CASE([$CURL_FEATURES],
15-
[*SSL*], [
16-
CURL_SSL=yes
17-
AC_MSG_RESULT([yes])
18-
], [
19-
CURL_SSL=no
20-
AC_MSG_RESULT([no])
21-
])
14+
AS_CASE([$CURL_FEATURES], [*SSL*], [CURL_SSL=yes], [CURL_SSL=no])
15+
AC_MSG_RESULT([$CURL_SSL])
2216

23-
AS_IF([test "$PHP_THREAD_SAFETY" = yes && test "$CURL_SSL" = yes], [
24-
save_LDFLAGS="$LDFLAGS"
25-
LDFLAGS="$LDFLAGS $CURL_LIBS"
17+
AS_IF([test "x$PHP_THREAD_SAFETY" = xyes && test "x$CURL_SSL" = xyes],
18+
[AC_CACHE_CHECK([whether libcurl is linked against old OpenSSL < 1.1],
19+
[php_cv_lib_curl_ssl], [
20+
save_LIBS=$LIBS
21+
save_CFLAGS=$CFLAGS
22+
LIBS="$LIBS $CURL_SHARED_LIBADD"
23+
CFLAGS="$CFLAGS $CURL_CFLAGS"
2624
27-
AC_CACHE_CHECK([for libcurl linked against old OpenSSL < 1.1],
28-
[php_cv_lib_curl_ssl],
29-
[AC_RUN_IFELSE([AC_LANG_PROGRAM([
25+
AC_RUN_IFELSE([AC_LANG_PROGRAM([
3026
#include <stdio.h>
3127
#include <strings.h>
3228
#include <curl/curl.h>
33-
], [
29+
], [
3430
curl_version_info_data *data = curl_version_info(CURLVERSION_NOW);
3531
3632
if (data && data->ssl_version && *data->ssl_version) {
@@ -60,29 +56,31 @@ if test "$PHP_CURL" != "no"; then
6056
/* No SSL support */
6157
return 1;
6258
])],
63-
[php_cv_lib_curl_ssl=yes],
64-
[php_cv_lib_curl_ssl=no],
65-
[php_cv_lib_curl_ssl=no])])
59+
[php_cv_lib_curl_ssl=yes],
60+
[php_cv_lib_curl_ssl=no],
61+
[php_cv_lib_curl_ssl=no])
62+
LIBS=$save_LIBS
63+
CFLAGS=$save_CFLAGS
64+
])
6665
6766
AS_VAR_IF([php_cv_lib_curl_ssl], [yes], [
68-
AC_DEFINE([HAVE_CURL_OLD_OPENSSL], [1], [Have cURL with old OpenSSL])
67+
AC_DEFINE([HAVE_CURL_OLD_OPENSSL], [1],
68+
[Define to 1 if libcurl is linked against old OpenSSL < 1.1.])
6969
PHP_SETUP_OPENSSL([CURL_SHARED_LIBADD],
7070
[AC_CHECK_HEADERS([openssl/crypto.h])])
7171
])
72-
73-
LDFLAGS="$save_LDFLAGS"
7472
])
7573

76-
PHP_CHECK_LIBRARY(curl,curl_easy_perform,
77-
[
78-
AC_DEFINE(HAVE_CURL,1,[ ])
79-
],[
80-
AC_MSG_ERROR(There is something wrong. Please check config.log for more information.)
81-
],[
82-
$CURL_LIBS
83-
])
74+
PHP_CHECK_LIBRARY([curl],
75+
[curl_easy_perform],
76+
[AC_DEFINE([HAVE_CURL], [1],
77+
[Define to 1 if curl extension is available.])],
78+
[AC_MSG_ERROR([The libcurl check failed. Please, check config.log for details.])],
79+
[$CURL_LIBS])
8480

85-
PHP_NEW_EXTENSION(curl, interface.c multi.c share.c curl_file.c, $ext_shared)
81+
PHP_NEW_EXTENSION([curl],
82+
[interface.c multi.c share.c curl_file.c],
83+
[$ext_shared])
8684
PHP_INSTALL_HEADERS([ext/curl], [php_curl.h])
8785
PHP_SUBST([CURL_SHARED_LIBADD])
8886
fi

ext/curl/config.w32

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ if (PHP_CURL != "no") {
2626
CHECK_LIB("nghttp2.lib", "curl", PHP_CURL))
2727
) {
2828
EXTENSION("curl", "interface.c multi.c share.c curl_file.c");
29-
AC_DEFINE('HAVE_CURL', 1, 'Have cURL library');
29+
AC_DEFINE('HAVE_CURL', 1, 'Define to 1 if curl extension is available.');
3030
ADD_FLAG("CFLAGS_CURL", "/D CURL_STATICLIB /D PHP_CURL_EXPORTS=1");
3131
PHP_INSTALL_HEADERS("ext/curl", "php_curl.h");
3232
} else {

0 commit comments

Comments
 (0)