xref: /php-src/ext/curl/config.m4 (revision 5433f02e)
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],
15    [*SSL*], [
16      CURL_SSL=yes
17      AC_MSG_RESULT([yes])
18    ], [
19      CURL_SSL=no
20      AC_MSG_RESULT([no])
21    ])
22
23  AS_IF([test "$PHP_THREAD_SAFETY" = yes && test "$CURL_SSL" = yes], [
24    save_LDFLAGS="$LDFLAGS"
25    LDFLAGS="$LDFLAGS $CURL_LIBS"
26
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([
30#include <stdio.h>
31#include <strings.h>
32#include <curl/curl.h>
33      ], [
34  curl_version_info_data *data = curl_version_info(CURLVERSION_NOW);
35
36  if (data && data->ssl_version && *data->ssl_version) {
37    const char *ptr = data->ssl_version;
38
39    while(*ptr == ' ') ++ptr;
40    int major, minor;
41    if (sscanf(ptr, "OpenSSL/%d", &major) == 1) {
42      if (major >= 3) {
43        /* OpenSSL version 3 or later */
44        return 4;
45      }
46    }
47    if (sscanf(ptr, "OpenSSL/%d.%d", &major, &minor) == 2) {
48      if (major > 1 || (major == 1 && minor >= 1)) {
49        /* OpenSSL version 1.1 or later */
50        return 3;
51      }
52    }
53    if (strncasecmp(ptr, "OpenSSL", sizeof("OpenSSL")-1) == 0) {
54      /* Old OpenSSL version */
55      return 0;
56    }
57    /* Different SSL library */
58    return 2;
59  }
60  /* No SSL support */
61  return 1;
62])],
63    [php_cv_lib_curl_ssl=yes],
64    [php_cv_lib_curl_ssl=no],
65    [php_cv_lib_curl_ssl=no])])
66
67    AS_VAR_IF([php_cv_lib_curl_ssl], [yes], [
68      AC_DEFINE([HAVE_CURL_OLD_OPENSSL], [1], [Have cURL with old OpenSSL])
69      PHP_SETUP_OPENSSL([CURL_SHARED_LIBADD],
70        [AC_CHECK_HEADERS([openssl/crypto.h])])
71    ])
72
73    LDFLAGS="$save_LDFLAGS"
74  ])
75
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  ])
84
85  PHP_NEW_EXTENSION(curl, interface.c multi.c share.c curl_file.c, $ext_shared)
86  PHP_INSTALL_HEADERS([ext/curl], [php_curl.h])
87  PHP_SUBST(CURL_SHARED_LIBADD)
88fi
89