add CURLOPT_HTTP09_ALLOWED
[m6w6/ext-http] / autoconf / pecl / libcurl.m4
1 dnl
2 dnl PECL_HAVE_LIBCURL_FEATURE(feature[, code-if-yes[, code-if-no]])
3 dnl
4 dnl Checks $CURL_CONFIG --feature.
5 dnl Defines PHP_<PECL_NAME>_HAVE_LIBCURL_<FEATURE>
6 dnl
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
12 else
13 PECL_CACHE_VAR([HAVE_LIBCURL_FEATURE_$1])=no
14 fi
15 ])
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])
19 $2
20 else
21 ifelse([$3],,:,[$3])
22 fi
23 ])
24 dnl
25 dnl PECL_HAVE_LIBCURL_PROTOCOL(protocol[, code-if-yes[, code-if-no]])
26 dnl
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
31 else
32 PECL_CACHE_VAR([HAVE_LIBCURL_PROTOCOL_$1])=no
33 fi
34 ])
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])
38 $2
39 else
40 ifelse([$3],,:,[$3])
41 fi
42 ])
43 dnl
44 dnl PECL_HAVE_LIBCURL_SSLLIB(ssllib-name, headers, libs)
45 dnl
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]), [
49 AC_TRY_RUN([
50 #include <strings.h>
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);
58 }
59 return 1;
60 }
61 ], [
62 PECL_CACHE_VAR([HAVE_LIBCURL_$1])=yes
63 ], [
64 PECL_CACHE_VAR([HAVE_LIBCURL_$1])=no
65 ])
66 ])
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
73 ])])
74 ifelse([$3],,,[
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])])
78 ])
79 fi
80 ])
81 fi
82 fi
83 ])
84 dnl
85 dnl PECL_HAVE_LIBCURL_SSL
86 dnl
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])
99
100 case "$PECL_VAR([LIBCURL_SSLLIB])" in
101 OpenSSL|GnuTLS|PolarSSL)
102 PECL_DEFINE([HAVE_LIBCURL_CAPATH])
103 PECL_DEFINE([HAVE_LIBCURL_CAINFO])
104 ;;
105 NSS)
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
111 ], [
112 PECL_CACHE_VAR([HAVE_LIBCURL_NSSPEM])=no
113 ])
114 PECL_RESTORE_ENV([LIBS], [NSSPEM])
115 ])
116 if $PECL_CACHE_VAR([HAVE_LIBCURL_NSSPEM]); then
117 PECL_DEFINE([HAVE_LIBCURL_CAINFO])
118 else
119 PECL_DEFINE([HAVE_LIBCURL_CAINFO], [0])
120 fi
121 PECL_DEFINE([HAVE_LIBCURL_CAPATH], [0])
122 ;;
123 *)
124 PECL_DEFINE([HAVE_LIBCURL_CAPATH], [0])
125 PECL_DEFINE([HAVE_LIBCURL_CAINFO], [0])
126 ;;
127 esac
128
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])=
132 AC_TRY_RUN([
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);
137 }
138 ], [
139 PECL_CACHE_VAR([LIBCURL_TLSAUTH_SRP])=yes
140 ], [
141 AC_TRY_RUN([
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");
146 }
147 ], [
148 PECL_CACHE_VAR([LIBCURL_TLSAUTH_SRP])=no
149 ])
150 ])
151 ])
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])
157 else
158 PECL_DEFINE([LIBCURL_TLSAUTH_SRP], ["SRP"])
159 PECL_DEFINE([LIBCURL_TLSAUTH_DEF], [""])
160 fi
161 fi
162 ])
163 ])
164 ])
165 dnl
166 dnl PECL_HAVE_LIBCURL_ARES
167 dnl
168 AC_DEFUN([PECL_HAVE_LIBCURL_ARES], [
169 AC_CACHE_CHECK([for c-ares providing AsynchDNS in libcurl], PECL_CACHE_VAR([HAVE_LIBCURL_ARES]), [
170 AC_TRY_RUN([
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) {
175 return 0;
176 }
177 return 1;
178 }
179 ], [
180 PECL_CACHE_VAR([HAVE_LIBCURL_ARES])=yes
181 ], [
182 PECL_CACHE_VAR([HAVE_LIBCURL_ARES])=no
183 ])
184 ])
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])
188 fi
189 ])
190 dnl
191 dnl PECL_HAVE_LIBCURL_CA
192 dnl
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.
196 dnl
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/.*=//')
201 fi
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])
205 ])
206 dnl
207 dnl PECL_CHECK_LIBCURL(search-dir[, min-version])
208 dnl
209 dnl Defines shell var $CURL_CONFIG (false if curl-config could not be found).
210 dnl
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!
214 dnl
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'],
221 [--cflags],
222 [--libs | $EGREP -o -- '(^|\s)-L@<:@^ @:>@* ?' | xargs],
223 [--libs | $EGREP -o -- '(^|\s)-l@<:@^ @:>@* ?' | xargs]dnl
224 )
225 ifelse([$2],,,[
226 PECL_HAVE_VERSION([libcurl], [$2])
227 ])
228 ])