xref: /PHP-8.0/ext/curl/config.m4 (revision 85b5dc47)
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.29.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  case "$CURL_FEATURES" in
15    *SSL*)
16      CURL_SSL=yes
17      AC_MSG_RESULT([yes])
18      ;;
19    *)
20      CURL_SSL=no
21      AC_MSG_RESULT([no])
22      ;;
23  esac
24
25  if test "$CURL_SSL" = yes; then
26    save_LDFLAGS="$LDFLAGS"
27    LDFLAGS="$LDFLAGS $CURL_LIBS"
28
29    AC_MSG_CHECKING([for libcurl linked against old openssl])
30    AC_RUN_IFELSE([AC_LANG_SOURCE([[
31#include <strings.h>
32#include <curl/curl.h>
33
34int main(int argc, char *argv[])
35{
36  curl_version_info_data *data = curl_version_info(CURLVERSION_NOW);
37
38  if (data && data->ssl_version && *data->ssl_version) {
39    const char *ptr = data->ssl_version;
40
41    while(*ptr == ' ') ++ptr;
42    if (strncasecmp(ptr, "OpenSSL/1.1", sizeof("OpenSSL/1.1")-1) == 0) {
43      /* New OpenSSL version */
44      return 3;
45    }
46    if (strncasecmp(ptr, "OpenSSL", sizeof("OpenSSL")-1) == 0) {
47      /* Old OpenSSL version */
48      return 0;
49    }
50    /* Different SSL library */
51    return 2;
52  }
53  /* No SSL support */
54  return 1;
55}
56    ]])],[
57      AC_MSG_RESULT([yes])
58      AC_DEFINE([HAVE_CURL_OLD_OPENSSL], [1], [Have cURL with old OpenSSL])
59      PKG_CHECK_MODULES([OPENSSL], [openssl], [
60        PHP_EVAL_LIBLINE($OPENSSL_LIBS, CURL_SHARED_LIBADD)
61        PHP_EVAL_INCLINE($OPENSSL_CFLAGS)
62        AC_CHECK_HEADERS([openssl/crypto.h])
63      ], [])
64    ], [
65      AC_MSG_RESULT([no])
66    ], [
67      AC_MSG_RESULT([no])
68    ])
69
70    LDFLAGS="$save_LDFLAGS"
71  else
72    AC_MSG_RESULT([no])
73  fi
74
75  PHP_CHECK_LIBRARY(curl,curl_easy_perform,
76  [
77    AC_DEFINE(HAVE_CURL,1,[ ])
78  ],[
79    AC_MSG_ERROR(There is something wrong. Please check config.log for more information.)
80  ],[
81    $CURL_LIBS
82  ])
83
84  PHP_NEW_EXTENSION(curl, interface.c multi.c share.c curl_file.c, $ext_shared)
85  PHP_INSTALL_HEADERS([ext/curl], [php_curl.h])
86  PHP_SUBST(CURL_SHARED_LIBADD)
87fi
88