xref: /PHP-7.2/ext/curl/config.m4 (revision 902d39a3)
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 -z "$PKG_CONFIG"; then
10    AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
11  fi
12
13  if test -x "$PKG_CONFIG"; then
14    dnl using pkg-config output
15
16    AC_MSG_CHECKING(for libcurl.pc)
17    if test "$PHP_CURL" = "yes" -o "$PHP_CURL" = "/usr"; then
18      PKNAME=libcurl
19      AC_MSG_RESULT(using default path)
20    elif test -r $PHP_CURL/$PHP_LIBDIR/pkgconfig/libcurl.pc; then
21      PKNAME=$PHP_CURL/$PHP_LIBDIR/pkgconfig/libcurl.pc
22      AC_MSG_RESULT(using $PKNAME)
23    elif test -r $PHP_CURL/lib/pkgconfig/libcurl.pc; then
24      PKNAME=$PHP_CURL/lib/pkgconfig/libcurl.pc
25      AC_MSG_RESULT(using $PKNAME)
26    else
27      AC_MSG_RESULT(not found)
28      AC_MSG_WARN(Could not find libcurl.pc. Try without $PHP_CURL or set PKG_CONFIG_PATH)
29    fi
30  fi
31
32  if test -n "$PKNAME"; then
33    AC_MSG_CHECKING(for cURL 7.10.5 or greater)
34    if $PKG_CONFIG --atleast-version 7.10.5 $PKNAME; then
35      curl_version_full=`$PKG_CONFIG --modversion $PKNAME`
36      AC_MSG_RESULT($curl_version_full)
37    else
38      AC_MSG_ERROR(cURL version 7.10.5 or later is required to compile php with cURL support)
39    fi
40
41    CURL_LIBS=`$PKG_CONFIG --libs   $PKNAME`
42    CURL_INCL=`$PKG_CONFIG --cflags $PKNAME`
43    CURL_SSL=`$PKG_CONFIG --variable=supported_features $PKNAME| $EGREP SSL`
44  else
45    dnl fallback to old vay, using curl-config
46    AC_MSG_WARN(Fallback: search for curl headers and curl-config)
47
48    if test -r $PHP_CURL/include/curl/easy.h; then
49      CURL_DIR=$PHP_CURL
50    else
51      AC_MSG_CHECKING(for cURL in default path)
52      for i in /usr/local /usr; do
53        if test -r $i/include/curl/easy.h; then
54          CURL_DIR=$i
55          AC_MSG_RESULT(found in $i)
56          break
57        fi
58      done
59    fi
60
61    if test -z "$CURL_DIR"; then
62      AC_MSG_RESULT(not found)
63      AC_MSG_ERROR(Please reinstall the libcurl distribution -
64      easy.h should be in <curl-dir>/include/curl/)
65    fi
66
67    CURL_CONFIG="curl-config"
68    AC_MSG_CHECKING(for cURL 7.10.5 or greater)
69
70    if ${CURL_DIR}/bin/curl-config --libs > /dev/null 2>&1; then
71      CURL_CONFIG=${CURL_DIR}/bin/curl-config
72    else
73      if ${CURL_DIR}/curl-config --libs > /dev/null 2>&1; then
74        CURL_CONFIG=${CURL_DIR}/curl-config
75      fi
76    fi
77
78    curl_version_full=`$CURL_CONFIG --version`
79    curl_version=`echo ${curl_version_full} | sed -e 's/libcurl //' | $AWK 'BEGIN { FS = "."; } { printf "%d", ($1 * 1000 + $2) * 1000 + $3;}'`
80    if test "$curl_version" -ge 7010005; then
81      AC_MSG_RESULT($curl_version_full)
82      CURL_LIBS=`$CURL_CONFIG --libs`
83      CURL_INCL=`$CURL_CONFIG --cflags`
84      CURL_SSL=`$CURL_CONFIG --feature | $EGREP SSL`
85    else
86      AC_MSG_ERROR(cURL version 7.10.5 or later is required to compile php with cURL support)
87    fi
88  fi
89
90  dnl common stuff (pkg-config / curl-config)
91
92  PHP_EVAL_LIBLINE($CURL_LIBS, CURL_SHARED_LIBADD)
93  PHP_EVAL_INCLINE($CURL_INCL, CURL_SHARED_LIBADD)
94
95  AC_MSG_CHECKING([for SSL support in libcurl])
96  if test -n "$CURL_SSL"; then
97    AC_MSG_RESULT([yes])
98    AC_DEFINE([HAVE_CURL_SSL], [1], [Have cURL with  SSL support])
99
100    save_CFLAGS="$CFLAGS"
101    CFLAGS=$CURL_INCL
102    save_LDFLAGS="$LDFLAGS"
103    LDFLAGS=$CURL_LIBS
104
105    AC_PROG_CPP
106    AC_MSG_CHECKING([for openssl support in libcurl])
107    AC_TRY_RUN([
108#include <strings.h>
109#include <curl/curl.h>
110
111int main(int argc, char *argv[])
112{
113  curl_version_info_data *data = curl_version_info(CURLVERSION_NOW);
114
115  if (data && data->ssl_version && *data->ssl_version) {
116    const char *ptr = data->ssl_version;
117
118    while(*ptr == ' ') ++ptr;
119    return strncasecmp(ptr, "OpenSSL", sizeof("OpenSSL")-1);
120  }
121  return 1;
122}
123    ],[
124      AC_MSG_RESULT([yes])
125      AC_CHECK_HEADERS([openssl/crypto.h], [
126        AC_DEFINE([HAVE_CURL_OPENSSL], [1], [Have cURL with OpenSSL support])
127      ])
128    ], [
129      AC_MSG_RESULT([no])
130    ], [
131      AC_MSG_RESULT([no])
132    ])
133
134    AC_MSG_CHECKING([for gnutls support in libcurl])
135    AC_TRY_RUN([
136#include <strings.h>
137#include <curl/curl.h>
138
139int main(int argc, char *argv[])
140{
141  curl_version_info_data *data = curl_version_info(CURLVERSION_NOW);
142
143  if (data && data->ssl_version && *data->ssl_version) {
144    const char *ptr = data->ssl_version;
145
146    while(*ptr == ' ') ++ptr;
147    return strncasecmp(ptr, "GnuTLS", sizeof("GnuTLS")-1);
148  }
149  return 1;
150}
151], [
152      AC_MSG_RESULT([yes])
153      AC_CHECK_HEADER([gcrypt.h], [
154        AC_DEFINE([HAVE_CURL_GNUTLS], [1], [Have cURL with GnuTLS support])
155      ])
156    ], [
157      AC_MSG_RESULT([no])
158    ], [
159      AC_MSG_RESULT([no])
160    ])
161
162    CFLAGS="$save_CFLAGS"
163    LDFLAGS="$save_LDFLAGS"
164  else
165    AC_MSG_RESULT([no])
166  fi
167
168  PHP_CHECK_LIBRARY(curl,curl_easy_perform,
169  [
170    AC_DEFINE(HAVE_CURL,1,[ ])
171  ],[
172    AC_MSG_ERROR(There is something wrong. Please check config.log for more information.)
173  ],[
174    $CURL_LIBS
175  ])
176
177  PHP_CHECK_LIBRARY(curl,curl_easy_strerror,
178  [
179    AC_DEFINE(HAVE_CURL_EASY_STRERROR,1,[ ])
180  ],[],[
181    $CURL_LIBS
182  ])
183
184  PHP_CHECK_LIBRARY(curl,curl_multi_strerror,
185  [
186    AC_DEFINE(HAVE_CURL_MULTI_STRERROR,1,[ ])
187  ],[],[
188    $CURL_LIBS
189  ])
190
191  PHP_NEW_EXTENSION(curl, interface.c multi.c share.c curl_file.c, $ext_shared)
192  PHP_SUBST(CURL_SHARED_LIBADD)
193fi
194