2 dnl PECL_HAVE_LIBCURL_FEATURE(feature[, code-if-yes[, code-if-no]])
4 dnl Checks $CURL_CONFIG --feature.
5 dnl Defines PHP_<PECL_NAME>_HAVE_LIBCURL_<FEATURE>
7 AC_DEFUN([PECL_HAVE_LIBCURL_FEATURE], [dnl
8 AC_REQUIRE([PECL_PROG_EGREP])dnl
9 AC_CACHE_CHECK([for $1 feature in libcurl], PECL_CACHE_VAR([HAVE_LIBCURL_FEATURE_$1]), [
10 if $CURL_CONFIG --feature | $EGREP -q $1; then
11 PECL_CACHE_VAR([HAVE_LIBCURL_FEATURE_$1])=yes
13 PECL_CACHE_VAR([HAVE_LIBCURL_FEATURE_$1])=no
16 PECL_VAR([HAVE_LIBCURL_FEATURE_$1])=$PECL_CACHE_VAR([HAVE_LIBCURL_FEATURE_$1])
17 if $PECL_VAR([HAVE_LIBCURL_FEATURE_$1]); then
18 PECL_DEFINE([HAVE_LIBCURL_$1])
25 dnl PECL_HAVE_LIBCURL_PROTOCOL(protocol[, code-if-yes[, code-if-no]])
27 AC_DEFUN([PECL_HAVE_LIBCURL_PROTOCOL], [
28 AC_CACHE_CHECK([for $1 protocol in libcurl], PECL_CACHE_VAR([HAVE_LIBCURL_PROTOCOL_$1]), [
29 if $CURL_CONFIG --protocols | $EGREP -q $1; then
30 PECL_CACHE_VAR([HAVE_LIBCURL_PROTOCOL_$1])=yes
32 PECL_CACHE_VAR([HAVE_LIBCURL_PROTOCOL_$1])=no
35 PECL_VAR([HAVE_LIBCURL_PROTOCOL_$1])=$PECL_CACHE_VAR([HAVE_LIBCURL_PROTOCOL_$1])
36 if $PECL_VAR([HAVE_LIBCURL_PROTOCOL_$1]); then
37 PECL_DEFINE([HAVE_LIBCURL_$1])
44 dnl PECL_HAVE_LIBCURL_SSLLIB(ssllib-name, headers, libs)
46 AC_DEFUN([PECL_HAVE_LIBCURL_SSLLIB], [
47 if test -z "$PECL_VAR([LIBCURL_SSLLIB])"; then
48 AC_CACHE_CHECK([for $1 providing SSL in libcurl], PECL_CACHE_VAR([HAVE_LIBCURL_$1]), [
51 #include <curl/curl.h>
52 int main(int argc, char *argv[]) {
53 curl_version_info_data *data = curl_version_info(CURLVERSION_NOW);
54 if (data && data->ssl_version && *data->ssl_version) {
55 const char *ptr = data->ssl_version;
56 while(*ptr == ' ') ++ptr;
57 return strncasecmp(ptr, "$1", sizeof("$1")-1);
62 PECL_CACHE_VAR([HAVE_LIBCURL_$1])=yes
64 PECL_CACHE_VAR([HAVE_LIBCURL_$1])=no
67 PECL_VAR([HAVE_LIBCURL_$1])=$PECL_CACHE_VAR([HAVE_LIBCURL_$1])
68 if $PECL_VAR([HAVE_LIBCURL_$1]); then
69 PECL_VAR([LIBCURL_SSLLIB])="$1"
70 PECL_DEFINE([HAVE_LIBCURL_$1])
71 m4_foreach_w(header, $2, [AC_CHECK_HEADER(header,, [
72 PECL_VAR([HAVE_LIBCURL_$1])=false
75 if $PECL_VAR([HAVE_LIBCURL_$1]); then
76 m4_foreach_w(lib, $3, [
77 PHP_ADD_LIBRARY(lib, true, [AS_TR_CPP(PECL_NAME[_SHARED_LIBADD])])
85 dnl PECL_HAVE_LIBCURL_SSL
87 AC_DEFUN([PECL_HAVE_LIBCURL_SSL], [dnl
88 AC_REQUIRE([PECL_HAVE_LIBCURL_CA])dnl
89 PECL_HAVE_LIBCURL_FEATURE([SSL], [
90 PECL_HAVE_LIBCURL_SSLLIB([OpenSSL], [openssl/ssl.h openssl/crypto.h], [ssl crypto])
91 PECL_HAVE_LIBCURL_SSLLIB([GnuTLS], [gnutls/gnutls.h gcrypt.h], [gnutls gcrypt])
92 PECL_HAVE_LIBCURL_SSLLIB([NSS])
93 PECL_HAVE_LIBCURL_SSLLIB([SecureTransport])
94 PECL_HAVE_LIBCURL_SSLLIB([GSKit])
95 PECL_HAVE_LIBCURL_SSLLIB([PolarSSL])
96 PECL_HAVE_LIBCURL_SSLLIB([WolfSSL])
97 PECL_HAVE_LIBCURL_SSLLIB([mbedTLS])
98 PECL_HAVE_LIBCURL_SSLLIB([axTLS])
100 case "$PECL_VAR([LIBCURL_SSLLIB])" in
101 OpenSSL|GnuTLS|PolarSSL)
102 PECL_DEFINE([HAVE_LIBCURL_CAPATH])
103 PECL_DEFINE([HAVE_LIBCURL_CAINFO])
106 AC_CACHE_CHECK([whether NSS PEM is available], [PECL_CACHE_VAR([HAVE_LIBCURL_NSSPEM])], [
107 PECL_SAVE_ENV([LIBS], [NSSPEM])
108 LIBS="$LIBS -lnsspem"
109 AC_TRY_LINK([], [(void)0;], [
110 PECL_CACHE_VAR([HAVE_LIBCURL_NSSPEM])=yes
112 PECL_CACHE_VAR([HAVE_LIBCURL_NSSPEM])=no
114 PECL_RESTORE_ENV([LIBS], [NSSPEM])
116 if $PECL_CACHE_VAR([HAVE_LIBCURL_NSSPEM]); then
117 PECL_DEFINE([HAVE_LIBCURL_CAINFO])
119 PECL_DEFINE([HAVE_LIBCURL_CAINFO], [0])
121 PECL_DEFINE([HAVE_LIBCURL_CAPATH], [0])
124 PECL_DEFINE([HAVE_LIBCURL_CAPATH], [0])
125 PECL_DEFINE([HAVE_LIBCURL_CAINFO], [0])
129 PECL_HAVE_CONST([curl/curl.h], [CURLOPT_TLSAUTH_TYPE], int, [
130 AC_CACHE_CHECK([whether CURLOPT_TLSAUTH_TYPE expects CURL_TLSAUTH_SRP], PECL_CACHE_VAR([LIBCURL_TLSAUTH_SRP]), [
131 PECL_CACHE_VAR([LIBCURL_TLSAUTH_SRP])=
133 #include <curl/curl.h>
134 int main(int argc, char *argv[]) {
135 CURL *ch = curl_easy_init();
136 return curl_easy_setopt(ch, CURLOPT_TLSAUTH_TYPE, CURL_TLSAUTH_SRP);
139 PECL_CACHE_VAR([LIBCURL_TLSAUTH_SRP])=yes
142 #include <curl/curl.h>
143 int main(int argc, char *argv[]) {
144 CURL *ch = curl_easy_init();
145 return curl_easy_setopt(ch, CURLOPT_TLSAUTH_TYPE, "SRP");
148 PECL_CACHE_VAR([LIBCURL_TLSAUTH_SRP])=no
152 if test -n "$PECL_CACHE_VAR([LIBCURL_TLSAUTH_SRP])"; then
153 PECL_DEFINE([HAVE_LIBCURL_TLSAUTH_TYPE])
154 if $PECL_CACHE_VAR([LIBCURL_TLSAUTH_SRP]); then
155 PECL_DEFINE([LIBCURL_TLSAUTH_SRP], [CURL_TLSAUTH_SRP])
156 PECL_DEFINE([LIBCURL_TLSAUTH_DEF], [CURL_TLSAUTH_NONE])
158 PECL_DEFINE([LIBCURL_TLSAUTH_SRP], ["SRP"])
159 PECL_DEFINE([LIBCURL_TLSAUTH_DEF], [""])
166 dnl PECL_HAVE_LIBCURL_ARES
168 AC_DEFUN([PECL_HAVE_LIBCURL_ARES], [
169 AC_CACHE_CHECK([for c-ares providing AsynchDNS in libcurl], PECL_CACHE_VAR([HAVE_LIBCURL_ARES]), [
171 #include <curl/curl.h>
172 int main(int argc, char *argv[]) {
173 curl_version_info_data *data = curl_version_info(CURLVERSION_NOW);
174 if (data && data->ares && data->ares_num) {
180 PECL_CACHE_VAR([HAVE_LIBCURL_ARES])=yes
182 PECL_CACHE_VAR([HAVE_LIBCURL_ARES])=no
185 PECL_VAR([HAVE_LIBCURL_ARES])=$PECL_CACHE_VAR([HAVE_LIBCURL_ARES])
186 if $PECL_VAR([HAVE_LIBCURL_ARES]); then
187 PECL_DEFINE([HAVE_LIBCURL_ARES])
191 dnl PECL_HAVE_LIBCURL_CA
193 dnl Checks for any installed default CA path/info with PECL_CHECK_CA providing curl's ca config.
194 dnl Defines shell vars PHP_<PECL_NAME>_LIBCURL_CAPATH and PHP_<PECL_NAME>_LIBCURL_CAINFO
195 dnl additionally to those defined in PECL_CHECK_CA.
197 AC_DEFUN([PECL_HAVE_LIBCURL_CA], [
198 CURL_CONFIG_CA=$($CURL_CONFIG --ca)
199 if test -z "$CURL_CONFIG_CA"; then
200 CURL_CONFIG_CA=$($CURL_CONFIG --configure | $EGREP -o -- "--with-ca@<:@^\'@:>@*" | $SED 's/.*=//')
202 PECL_CHECK_CA($CURL_CONFIG_CA, $CURL_CONFIG_CA)
203 PECL_VAR([LIBCURL_CAPATH])=$PECL_VAR([CAPATH])
204 PECL_VAR([LIBCURL_CAINFO])=$PECL_VAR([CAINFO])
207 dnl PECL_CHECK_LIBCURL(search-dir[, min-version])
209 dnl Defines shell var $CURL_CONFIG (false if curl-config could not be found).
211 dnl Calls PECL_CHECK_CONFIG(libcurl ...) for its tests.
212 dnl Call PECL_CHECK_DONE(libcurl[, success]) yourself when you're done
213 dnl with any subtests. This is IMPORTANT!
215 AC_DEFUN([PECL_CHECK_LIBCURL], [dnl
216 AC_REQUIRE([PECL_PROG_SED])dnl
217 AC_REQUIRE([PECL_PROG_EGREP])dnl
218 AC_PATH_PROG([CURL_CONFIG], [curl-config], false, [$1/bin:$PATH:/usr/local/bin])
219 PECL_CHECK_CONFIG(libcurl, $CURL_CONFIG,
220 [--version | $SED -e 's/@<:@^0-9\.@:>@//g'],
222 [--libs | $EGREP -o -- '(^|\s)-L@<:@^ @:>@* ?' | xargs],
223 [--libs | $EGREP -o -- '(^|\s)-l@<:@^ @:>@* ?' | xargs]dnl
226 PECL_HAVE_VERSION([libcurl], [$2])