xref: /PHP-5.6/ext/curl/config.m4 (revision c6d977dd)
1dnl
2dnl $Id$
3dnl
4
5PHP_ARG_WITH(curl, for cURL support,
6[  --with-curl[=DIR]         Include cURL support])
7
8if test "$PHP_CURL" != "no"; then
9  if test -r $PHP_CURL/include/curl/easy.h; then
10    CURL_DIR=$PHP_CURL
11  else
12    AC_MSG_CHECKING(for cURL in default path)
13    for i in /usr/local /usr; do
14      if test -r $i/include/curl/easy.h; then
15        CURL_DIR=$i
16        AC_MSG_RESULT(found in $i)
17        break
18      fi
19    done
20  fi
21
22  if test -z "$CURL_DIR"; then
23    AC_MSG_RESULT(not found)
24    AC_MSG_ERROR(Please reinstall the libcurl distribution -
25    easy.h should be in <curl-dir>/include/curl/)
26  fi
27
28  CURL_CONFIG="curl-config"
29  AC_MSG_CHECKING(for cURL 7.10.5 or greater)
30
31  if ${CURL_DIR}/bin/curl-config --libs > /dev/null 2>&1; then
32    CURL_CONFIG=${CURL_DIR}/bin/curl-config
33  else
34    if ${CURL_DIR}/curl-config --libs > /dev/null 2>&1; then
35      CURL_CONFIG=${CURL_DIR}/curl-config
36    fi
37  fi
38
39  curl_version_full=`$CURL_CONFIG --version`
40  curl_version=`echo ${curl_version_full} | sed -e 's/libcurl //' | $AWK 'BEGIN { FS = "."; } { printf "%d", ($1 * 1000 + $2) * 1000 + $3;}'`
41  if test "$curl_version" -ge 7010005; then
42    AC_MSG_RESULT($curl_version_full)
43    CURL_LIBS=`$CURL_CONFIG --libs`
44  else
45    AC_MSG_ERROR(cURL version 7.10.5 or later is required to compile php with cURL support)
46  fi
47
48  PHP_ADD_INCLUDE($CURL_DIR/include)
49  PHP_EVAL_LIBLINE($CURL_LIBS, CURL_SHARED_LIBADD)
50  PHP_ADD_LIBRARY_WITH_PATH(curl, $CURL_DIR/$PHP_LIBDIR, CURL_SHARED_LIBADD)
51
52  AC_MSG_CHECKING([for SSL support in libcurl])
53  CURL_SSL=`$CURL_CONFIG --feature | $EGREP SSL`
54  if test "$CURL_SSL" = "SSL"; then
55    AC_MSG_RESULT([yes])
56    AC_DEFINE([HAVE_CURL_SSL], [1], [Have cURL with  SSL support])
57
58    save_CFLAGS="$CFLAGS"
59    CFLAGS="`$CURL_CONFIG --cflags`"
60
61    AC_PROG_CPP
62    AC_MSG_CHECKING([for openssl support in libcurl])
63    AC_TRY_RUN([
64#include <curl/curl.h>
65
66int main(int argc, char *argv[])
67{
68  curl_version_info_data *data = curl_version_info(CURLVERSION_NOW);
69
70  if (data && data->ssl_version && *data->ssl_version) {
71    const char *ptr = data->ssl_version;
72
73    while(*ptr == ' ') ++ptr;
74    return strncasecmp(ptr, "OpenSSL", sizeof("OpenSSL")-1);
75  }
76  return 1;
77}
78    ],[
79      AC_MSG_RESULT([yes])
80      AC_CHECK_HEADERS([openssl/crypto.h], [
81        AC_DEFINE([HAVE_CURL_OPENSSL], [1], [Have cURL with OpenSSL support])
82      ])
83    ], [
84      AC_MSG_RESULT([no])
85    ], [
86      AC_MSG_RESULT([no])
87    ])
88
89    AC_MSG_CHECKING([for gnutls support in libcurl])
90    AC_TRY_RUN([
91#include <curl/curl.h>
92
93int main(int argc, char *argv[])
94{
95  curl_version_info_data *data = curl_version_info(CURLVERSION_NOW);
96
97  if (data && data->ssl_version && *data->ssl_version) {
98    const char *ptr = data->ssl_version;
99
100    while(*ptr == ' ') ++ptr;
101    return strncasecmp(ptr, "GnuTLS", sizeof("GnuTLS")-1);
102  }
103  return 1;
104}
105], [
106      AC_MSG_RESULT([yes])
107      AC_CHECK_HEADER([gcrypt.h], [
108        AC_DEFINE([HAVE_CURL_GNUTLS], [1], [Have cURL with GnuTLS support])
109      ])
110    ], [
111      AC_MSG_RESULT([no])
112    ], [
113      AC_MSG_RESULT([no])
114    ])
115
116    CFLAGS="$save_CFLAGS"
117  else
118    AC_MSG_RESULT([no])
119  fi
120
121  PHP_CHECK_LIBRARY(curl,curl_easy_perform,
122  [
123    AC_DEFINE(HAVE_CURL,1,[ ])
124  ],[
125    AC_MSG_ERROR(There is something wrong. Please check config.log for more information.)
126  ],[
127    $CURL_LIBS -L$CURL_DIR/$PHP_LIBDIR
128  ])
129
130  PHP_CHECK_LIBRARY(curl,curl_easy_strerror,
131  [
132    AC_DEFINE(HAVE_CURL_EASY_STRERROR,1,[ ])
133  ],[],[
134    $CURL_LIBS -L$CURL_DIR/$PHP_LIBDIR
135  ])
136
137  PHP_CHECK_LIBRARY(curl,curl_multi_strerror,
138  [
139    AC_DEFINE(HAVE_CURL_MULTI_STRERROR,1,[ ])
140  ],[],[
141    $CURL_LIBS -L$CURL_DIR/$PHP_LIBDIR
142  ])
143
144  PHP_NEW_EXTENSION(curl, interface.c multi.c share.c curl_file.c, $ext_shared)
145  PHP_SUBST(CURL_SHARED_LIBADD)
146fi
147