xref: /php-src/ext/curl/config.m4 (revision dcdcb3cb)
1PHP_ARG_WITH([curl],
2  [for cURL support],
3  [AS_HELP_STRING([--with-curl],
4    [Include cURL support])])
5
6if test "$PHP_CURL" != "no"; then
7  PKG_CHECK_MODULES([CURL], [libcurl >= 7.61.0])
8  PKG_CHECK_VAR([CURL_FEATURES], [libcurl], [supported_features])
9
10  PHP_EVAL_LIBLINE([$CURL_LIBS], [CURL_SHARED_LIBADD])
11  PHP_EVAL_INCLINE([$CURL_CFLAGS])
12
13  AC_MSG_CHECKING([for SSL support in libcurl])
14  AS_CASE([$CURL_FEATURES], [*SSL*], [CURL_SSL=yes], [CURL_SSL=no])
15  AC_MSG_RESULT([$CURL_SSL])
16
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"
24
25      AC_RUN_IFELSE([AC_LANG_PROGRAM([
26#include <stdio.h>
27#include <strings.h>
28#include <curl/curl.h>
29], [
30  curl_version_info_data *data = curl_version_info(CURLVERSION_NOW);
31
32  if (data && data->ssl_version && *data->ssl_version) {
33    const char *ptr = data->ssl_version;
34
35    while(*ptr == ' ') ++ptr;
36    int major, minor;
37    if (sscanf(ptr, "OpenSSL/%d", &major) == 1) {
38      if (major >= 3) {
39        /* OpenSSL version 3 or later */
40        return 4;
41      }
42    }
43    if (sscanf(ptr, "OpenSSL/%d.%d", &major, &minor) == 2) {
44      if (major > 1 || (major == 1 && minor >= 1)) {
45        /* OpenSSL version 1.1 or later */
46        return 3;
47      }
48    }
49    if (strncasecmp(ptr, "OpenSSL", sizeof("OpenSSL")-1) == 0) {
50      /* Old OpenSSL version */
51      return 0;
52    }
53    /* Different SSL library */
54    return 2;
55  }
56  /* No SSL support */
57  return 1;
58])],
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    ])
65
66    AS_VAR_IF([php_cv_lib_curl_ssl], [yes], [
67      AC_DEFINE([HAVE_CURL_OLD_OPENSSL], [1],
68        [Define to 1 if libcurl is linked against old OpenSSL < 1.1.])
69      PHP_SETUP_OPENSSL([CURL_SHARED_LIBADD],
70        [AC_CHECK_HEADERS([openssl/crypto.h])])
71    ])
72  ])
73
74  PHP_CHECK_LIBRARY([curl],
75    [curl_easy_perform],
76    [AC_DEFINE([HAVE_CURL], [1],
77      [Define to 1 if the PHP extension 'curl' is available.])],
78    [AC_MSG_FAILURE([The libcurl check failed.])],
79    [$CURL_LIBS])
80
81  PHP_NEW_EXTENSION([curl],
82    [interface.c multi.c share.c curl_file.c],
83    [$ext_shared])
84  PHP_INSTALL_HEADERS([ext/curl], [php_curl.h])
85  PHP_SUBST([CURL_SHARED_LIBADD])
86fi
87