3712b31236acc66874aa2bc1c4b7dfae22d67935
[m6w6/ext-http] / config9.m4
1 dnl config.m4 for pecl/http
2 dnl $Id$
3 dnl vim: noet ts=1 sw=1
4
5 PHP_ARG_ENABLE([http], [whether to enable extended HTTP support],
6 [ --enable-http Enable extended HTTP support])
7 PHP_ARG_WITH([http-shared-deps], [whether to depend on extensions which have been built shared],
8 [ --with-http-shared-deps
9 HTTP: disable to not depend on extensions like hash,
10 iconv and session (when built shared)], $PHP_HTTP, $PHP_HTTP)
11 PHP_ARG_WITH([http-curl-requests], [whether to enable cURL HTTP request support],
12 [ --with-http-curl-requests[=LIBCURLDIR]
13 HTTP: with cURL request support], $PHP_HTTP, $PHP_HTTP)
14 PHP_ARG_WITH([http-curl-libevent], [whether to enable libevent support fur cURL],
15 [ --with-http-curl-libevent[=LIBEVENTDIR]
16 HTTP: libevent install directory], $PHP_HTTP_CURL_REQUESTS, "")
17 PHP_ARG_WITH([http-zlib-compression], [whether to enable zlib encodings support],
18 [ --with-http-zlib-compression[=LIBZDIR]
19 HTTP: with zlib encodings support], $PHP_HTTP, $PHP_HTTP)
20 PHP_ARG_WITH([http-magic-mime], [whether to enable response content type guessing],
21 [ --with-http-magic-mime[=LIBMAGICDIR]
22 HTTP: with magic mime response content type guessing], "no", "no")
23
24 if test "$PHP_HTTP" != "no"; then
25
26 ifdef([AC_PROG_EGREP], [
27 AC_PROG_EGREP
28 ], [
29 AC_CHECK_PROG(EGREP, egrep, egrep)
30 ])
31 ifdef([AC_PROG_SED], [
32 AC_PROG_SED
33 ], [
34 ifdef([LT_AC_PROG_SED], [
35 LT_AC_PROG_SED
36 ], [
37 AC_CHECK_PROG(SED, sed, sed)
38 ])
39 ])
40
41 if test "$PHP_HTTP_SHARED_DEPS" != "no"; then
42 AC_DEFINE([HTTP_SHARED_DEPS], [1], [ ])
43 else
44 AC_DEFINE([HTTP_SHARED_DEPS], [0], [ ])
45 fi
46
47 dnl
48 dnl HTTP_SHARED_DEP(name[, code-if-yes[, code-if-not]])
49 dnl
50 AC_DEFUN([HTTP_SHARED_DEP], [
51 extname=$1
52 haveext=$[HTTP_HAVE_EXT_]translit($1,a-z_-,A-Z__)
53
54 AC_MSG_CHECKING([whether to add a dependency on ext/$extname])
55 if test "$PHP_HTTP_SHARED_DEPS" = "no"; then
56 AC_MSG_RESULT([no])
57 $3
58 elif test "$haveext"; then
59 AC_MSG_RESULT([yes])
60 ifdef([PHP_ADD_EXTENSION_DEP], [
61 PHP_ADD_EXTENSION_DEP([http], $1, true)
62 ])
63 $2
64 else
65 AC_MSG_RESULT([no])
66 $3
67 fi
68 ])
69
70 dnl
71 dnl HTTP_HAVE_PHP_EXT(name[, code-if-yes[, code-if-not]])
72 dnl
73 AC_DEFUN([HTTP_HAVE_PHP_EXT], [
74 extname=$1
75 haveext=$[PHP_]translit($1,a-z_-,A-Z__)
76 ishared=$[PHP_]translit($1,a-z_-,A-Z__)_SHARED
77
78 AC_MSG_CHECKING([for ext/$extname support])
79 if test -x "$PHP_EXECUTABLE"; then
80 if test "`$PHP_EXECUTABLE -m | $EGREP ^$extname\$`" = "$extname"; then
81 [HTTP_HAVE_EXT_]translit($1,a-z_-,A-Z__)=1
82 AC_MSG_RESULT([yes])
83 $2
84 else
85 [HTTP_HAVE_EXT_]translit($1,a-z_-,A-Z__)=
86 AC_MSG_RESULT([no])
87 $3
88 fi
89 elif test "$haveext" != "no" && test "x$haveext" != "x"; then
90 [HTTP_HAVE_EXT_]translit($1,a-z_-,A-Z__)=1
91 AC_MSG_RESULT([yes])
92 $2
93 else
94 [HTTP_HAVE_EXT_]translit($1,a-z_-,A-Z__)=
95 AC_MSG_RESULT([no])
96 $3
97 fi
98 ])
99
100 dnl ----
101 dnl STDC
102 dnl ----
103 AC_CHECK_HEADERS([netdb.h unistd.h])
104 PHP_CHECK_FUNC(gethostname, nsl)
105 PHP_CHECK_FUNC(getdomainname, nsl)
106 PHP_CHECK_FUNC(getservbyport, nsl)
107 PHP_CHECK_FUNC(getservbyname, nsl)
108
109 dnl ----
110 dnl ZLIB
111 dnl ----
112 if test "$PHP_HTTP_ZLIB_COMPRESSION" != "no"; then
113 AC_MSG_CHECKING([for zlib.h])
114 ZLIB_DIR=
115 for i in "$PHP_HTTP_ZLIB_COMPRESSION" "$PHP_ZLIB_DIR" "$PHP_ZLIB" /usr/local /usr /opt; do
116 if test -f "$i/include/zlib.h"; then
117 ZLIB_DIR=$i
118 break;
119 fi
120 done
121 if test -z "$ZLIB_DIR"; then
122 AC_MSG_RESULT([not found])
123 AC_MSG_ERROR([could not find zlib.h])
124 else
125 AC_MSG_RESULT([found in $ZLIB_DIR])
126 AC_MSG_CHECKING([for zlib version >= 1.2.0.4])
127 ZLIB_VERSION=`$EGREP "define ZLIB_VERSION" $ZLIB_DIR/include/zlib.h | $SED -e 's/[[^0-9\.]]//g'`
128 AC_MSG_RESULT([$ZLIB_VERSION])
129 if test `echo $ZLIB_VERSION | $SED -e 's/[[^0-9]]/ /g' | $AWK '{print $1*1000000 + $2*10000 + $3*100 + $4}'` -lt 1020004; then
130 AC_MSG_ERROR([libz version greater or equal to 1.2.0.4 required])
131 else
132 PHP_ADD_INCLUDE($ZLIB_DIR/include)
133 PHP_ADD_LIBRARY_WITH_PATH(z, $ZLIB_DIR/$PHP_LIBDIR, HTTP_SHARED_LIBADD)
134 AC_DEFINE([HTTP_HAVE_ZLIB], [1], [Have zlib support])
135 fi
136 fi
137 fi
138
139 dnl ----
140 dnl CURL
141 dnl ----
142 if test "$PHP_HTTP_CURL_REQUESTS" != "no"; then
143 AC_MSG_CHECKING([for curl/curl.h])
144 CURL_DIR=
145 for i in "$PHP_HTTP_CURL_REQUESTS" /usr/local /usr /opt; do
146 if test -f "$i/include/curl/curl.h"; then
147 CURL_DIR=$i
148 break
149 fi
150 done
151 if test -z "$CURL_DIR"; then
152 AC_MSG_RESULT([not found])
153 AC_MSG_ERROR([could not find curl/curl.h])
154 else
155 AC_MSG_RESULT([found in $CURL_DIR])
156 fi
157
158 AC_MSG_CHECKING([for curl-config])
159 CURL_CONFIG=
160 for i in "$CURL_DIR/bin/curl-config" "$CURL_DIR/curl-config" `which curl-config`; do
161 if test -x "$i"; then
162 CURL_CONFIG=$i
163 break
164 fi
165 done
166 if test -z "$CURL_CONFIG"; then
167 AC_MSG_RESULT([not found])
168 AC_MSG_ERROR([could not find curl-config])
169 else
170 AC_MSG_RESULT([found: $CURL_CONFIG])
171 fi
172
173 dnl Debian stable has currently 7.13.2 (this is not a typo)
174 AC_MSG_CHECKING([for curl version >= 7.12.3])
175 CURL_VERSION=`$CURL_CONFIG --version | $SED -e 's/[[^0-9\.]]//g'`
176 AC_MSG_RESULT([$CURL_VERSION])
177 if test `echo $CURL_VERSION | $SED -e 's/[[^0-9]]/ /g' | $AWK '{print $1*10000 + $2*100 + $3}'` -lt 71203; then
178 AC_MSG_ERROR([libcurl version greater or equal to 7.12.3 required])
179 fi
180
181 AC_MSG_CHECKING([for SSL support in libcurl])
182 CURL_SSL=`$CURL_CONFIG --feature | $EGREP SSL`
183 if test "$CURL_SSL" = "SSL"; then
184 AC_MSG_RESULT([yes])
185 AC_DEFINE([HTTP_HAVE_SSL], [1], [ ])
186
187 save_CFLAGS="$CFLAGS"
188 CFLAGS="`$CURL_CONFIG --cflags`"
189 save_LDFLAGS="$LDFALGS"
190 LDFLAGS="`$CURL_CONFIG --libs` $ld_runpath_switch$CURL_DIR/$PHP_LIBDIR"
191
192 AC_CHECK_HEADER([openssl/crypto.h], [
193 AC_MSG_CHECKING([for openssl support in libcurl])
194 AC_TRY_RUN([
195 #include <curl/curl.h>
196 int main(int argc, char *argv[]) {
197 curl_version_info_data *data = curl_version_info(CURLVERSION_NOW);
198 if (data) {
199 if (data->ssl_version && *data->ssl_version) {
200 const char *ptr = data->ssl_version;
201 while(*ptr == ' ') ++ptr;
202 return strncasecmp(ptr, "OpenSSL", sizeof("OpenSSL")-1);
203 }
204 }
205 return 1;
206 }
207 ],[
208 AC_MSG_RESULT([yes])
209 AC_DEFINE([HTTP_HAVE_OPENSSL], [1], [ ])
210 ], [
211 AC_MSG_RESULT([no])
212 ], [
213 AC_MSG_RESULT([no])
214 ])
215 ])
216
217 AC_CHECK_HEADER([gcrypt.h], [
218 AC_MSG_CHECKING([for gnutls support in libcurl])
219 AC_TRY_RUN([
220 #include <curl/curl.h>
221 int main(int argc, char *argv[]) {
222 curl_version_info_data *data = curl_version_info(CURLVERSION_NOW);
223 if (data) {
224 if (data->ssl_version && *data->ssl_version) {
225 const char *ptr = data->ssl_version;
226 while(*ptr == ' ') ++ptr;
227 return strncasecmp(ptr, "GnuTLS", sizeof("GnuTLS")-1);
228 }
229 }
230 return 1;
231 }
232 ], [
233 AC_MSG_RESULT([yes])
234 AC_DEFINE([HTTP_HAVE_GNUTLS], [1], [ ])
235 ], [
236 AC_MSG_RESULT([no])
237 ], [
238 AC_MSG_RESULT([no])
239 ])
240 ])
241
242 CFLAGS="$save_CFLAGS"
243 LDFLAGS="$save_LDFLAGS"
244 else
245 AC_MSG_RESULT([no])
246 fi
247
248 AC_MSG_CHECKING([for bundled SSL CA info])
249 CURL_CAINFO=
250 for i in `$CURL_CONFIG --ca` "/etc/ssl/certs/ca-certificates.crt"; do
251 if test -f "$i"; then
252 CURL_CAINFO="$i"
253 break
254 fi
255 done
256 if test -z "$CURL_CAINFO"; then
257 AC_MSG_RESULT([not found])
258 else
259 AC_MSG_RESULT([$CURL_CAINFO])
260 AC_DEFINE_UNQUOTED([HTTP_CURL_CAINFO], ["$CURL_CAINFO"], [path to bundled SSL CA info])
261 fi
262
263 PHP_ADD_INCLUDE($CURL_DIR/include)
264 PHP_ADD_LIBRARY_WITH_PATH(curl, $CURL_DIR/$PHP_LIBDIR, HTTP_SHARED_LIBADD)
265 PHP_EVAL_LIBLINE($CURL_LIBS, HTTP_SHARED_LIBADD)
266 AC_DEFINE([HTTP_HAVE_CURL], [1], [Have cURL support])
267
268 PHP_CHECK_LIBRARY(curl, curl_share_strerror,
269 [AC_DEFINE([HAVE_CURL_SHARE_STRERROR], [1], [ ])], [ ],
270 [$CURL_LIBS -L$CURL_DIR/$PHP_LIBDIR]
271 )
272 PHP_CHECK_LIBRARY(curl, curl_multi_strerror,
273 [AC_DEFINE([HAVE_CURL_MULTI_STRERROR], [1], [ ])], [ ],
274 [$CURL_LIBS -L$CURL_DIR/$PHP_LIBDIR]
275 )
276 PHP_CHECK_LIBRARY(curl, curl_easy_strerror,
277 [AC_DEFINE([HAVE_CURL_EASY_STRERROR], [1], [ ])], [ ],
278 [$CURL_LIBS -L$CURL_DIR/$PHP_LIBDIR]
279 )
280 PHP_CHECK_LIBRARY(curl, curl_easy_reset,
281 [AC_DEFINE([HAVE_CURL_EASY_RESET], [1], [ ])], [ ],
282 [$CURL_LIBS -L$CURL_DIR/$PHP_LIBDIR]
283 )
284 dnl Debian suddenly (>=7.14.1-2) hides all symbols not starting with "curl"
285 PHP_CHECK_LIBRARY(curl, Curl_getFormData,
286 [AC_DEFINE([HAVE_CURL_GETFORMDATA], [1], [ ])], [ ],
287 [$CURL_LIBS -L$CURL_DIR/$PHP_LIBDIR]
288 )
289 dnl New API function which obsoletes use of Curl_getFormData (>=7.15.5)
290 PHP_CHECK_LIBRARY(curl, curl_formget,
291 [AC_DEFINE([HAVE_CURL_FORMGET], [1], [ ])], [ ],
292 [$CURL_LIBS -L$CURL_DIR/$PHP_LIBDIR]
293 )
294 PHP_CHECK_LIBRARY(curl, curl_multi_setopt,
295 [AC_DEFINE([HAVE_CURL_MULTI_SETOPT], [1], [ ])], [ ],
296 [$CURL_LIBS -L$CURL_DIR/$PHP_LIBDIR]
297 )
298 PHP_CHECK_LIBRARY(curl, curl_multi_timeout,
299 [AC_DEFINE([HAVE_CURL_MULTI_TIMEOUT], [1], [ ])], [ ],
300 [$CURL_LIBS -L$CURL_DIR/$PHP_LIBDIR]
301 )
302
303 dnl ----
304 dnl EVENT
305 dnl ----
306
307 if test "$PHP_HTTP_CURL_LIBEVENT" != "no"; then
308 AC_MSG_CHECKING([for event.h])
309 EVENT_DIR=
310 for i in "$PHP_HTTP_CURL_LIBEVENT" /usr/local /usr /opt; do
311 if test -f "$i/include/event.h"; then
312 EVENT_DIR=$i
313 break
314 fi
315 done
316 if test -z "$EVENT_DIR"; then
317 AC_MSG_RESULT([not found])
318 AC_MSG_WARN([continuing without libevent support])
319 else
320 AC_MSG_RESULT([found in $EVENT_DIR])
321
322 AC_MSG_CHECKING([for libevent version, roughly])
323 EVENT_VER="1.1b or lower"
324 if test -f "$EVENT_DIR/include/evhttp.h" && test -f "$EVENT_DIR/include/evdns.h"; then
325 if test -f "$EVENT_DIR/include/evrpc.h"; then
326 EVENT_VER="1.4 or greater"
327 else
328 EVENT_VER="1.2 or greater"
329 fi
330 fi
331 AC_DEFINE_UNQUOTED([HTTP_EVENT_VERSION], ["$EVENT_VER"], [ ])
332 AC_MSG_RESULT([$EVENT_VER])
333
334 AC_MSG_CHECKING([for libcurl version >= 7.16.0])
335 AC_MSG_RESULT([$CURL_VERSION])
336 if test `echo $CURL_VERSION | $SED -e 's/[[^0-9]]/ /g' | $AWK '{print $1*10000 + $2*100 + $3}'` -lt 71600; then
337 AC_MSG_WARN([libcurl version greater or equal to 7.16.0 required; continuing without libevent support])
338 else
339 PHP_ADD_INCLUDE($EVENT_DIR/include)
340 PHP_ADD_LIBRARY_WITH_PATH(event, $EVENT_DIR/$PHP_LIBDIR, HTTP_SHARED_LIBADD)
341 AC_DEFINE([HTTP_HAVE_EVENT], [1], [Have libevent support for cURL])
342 PHP_CHECK_LIBRARY(curl, curl_multi_socket_action,
343 [AC_DEFINE([HAVE_CURL_MULTI_SOCKET_ACTION], [1], [ ])], [ ],
344 [$CURL_LIBS -L$CURL_DIR/$PHP_LIBDIR]
345 )
346 fi
347 fi
348 fi
349 fi
350
351 dnl ----
352 dnl MAGIC
353 dnl ----
354 if test "$PHP_HTTP_MAGIC_MIME" != "no"; then
355 AC_MSG_CHECKING([for magic.h])
356 MAGIC_DIR=
357 for i in "$PHP_HTTP_MAGIC_MIME" /usr/local /usr /opt; do
358 if test -f "$i/include/magic.h"; then
359 MAGIC_DIR=$i
360 break
361 fi
362 done
363 if test -z "$MAGIC_DIR"; then
364 AC_MSG_RESULT([not found])
365 AC_MSG_ERROR([could not find magic.h])
366 else
367 AC_MSG_RESULT([found in $MAGIC_DIR])
368 fi
369
370 PHP_ADD_INCLUDE($MAGIC_DIR/include)
371 PHP_ADD_LIBRARY_WITH_PATH(magic, $MAGIC_DIR/$PHP_LIBDIR, HTTP_SHARED_LIBADD)
372 AC_DEFINE([HTTP_HAVE_MAGIC], [1], [Have magic mime support])
373 fi
374
375 dnl ----
376 dnl HASH
377 dnl ----
378 HTTP_HAVE_PHP_EXT([hash], [
379 AC_MSG_CHECKING([for php_hash.h])
380 HTTP_EXT_HASH_INCDIR=
381 for i in `echo $INCLUDES | $SED -e's/-I//g'` $abs_srcdir ../hash; do
382 if test -d $i; then
383 if test -f $i/php_hash.h; then
384 HTTP_EXT_HASH_INCDIR=$i
385 break
386 elif test -f $i/ext/hash/php_hash.h; then
387 HTTP_EXT_HASH_INCDIR=$i/ext/hash
388 break
389 fi
390 fi
391 done
392 if test -z "$HTTP_EXT_HASH_INCDIR"; then
393 AC_MSG_RESULT([not found])
394 else
395 AC_MSG_RESULT([$HTTP_EXT_HASH_INCDIR])
396 AC_DEFINE([HTTP_HAVE_PHP_HASH_H], [1], [Have ext/hash support])
397 PHP_ADD_INCLUDE([$HTTP_EXT_HASH_INCDIR])
398 fi
399 ])
400
401 dnl ----
402 dnl ICONV
403 dnl ----
404 HTTP_HAVE_PHP_EXT([iconv])
405
406 dnl ----
407 dnl SESSION
408 dnl ----
409 HTTP_HAVE_PHP_EXT([session])
410
411 dnl ----
412 dnl DONE
413 dnl ----
414 PHP_HTTP_SOURCES="missing.c http.c http_functions.c phpstr/phpstr.c \
415 http_util_object.c http_message_object.c http_request_object.c http_request_pool_api.c \
416 http_response_object.c http_exception_object.c http_requestpool_object.c \
417 http_api.c http_cache_api.c http_request_api.c http_request_info.c http_date_api.c \
418 http_headers_api.c http_message_api.c http_send_api.c http_url_api.c \
419 http_info_api.c http_request_method_api.c http_encoding_api.c \
420 http_filter_api.c http_request_body_api.c http_querystring_object.c \
421 http_deflatestream_object.c http_inflatestream_object.c http_cookie_api.c \
422 http_querystring_api.c http_request_datashare_api.c http_requestdatashare_object.c \
423 http_persistent_handle_api.c"
424
425 PHP_NEW_EXTENSION([http], $PHP_HTTP_SOURCES, $ext_shared)
426
427 dnl shared extension deps
428 HTTP_SHARED_DEP([hash])
429 HTTP_SHARED_DEP([iconv])
430 HTTP_SHARED_DEP([session])
431
432 PHP_ADD_BUILD_DIR($ext_builddir/phpstr, 1)
433 PHP_SUBST([HTTP_SHARED_LIBADD])
434
435 PHP_HTTP_HEADERS="php_http_std_defs.h php_http.h php_http_api.h php_http_cache_api.h \
436 php_http_date_api.h php_http_headers_api.h php_http_info_api.h php_http_message_api.h \
437 php_http_request_api.h php_http_request_method_api.h php_http_send_api.h php_http_url_api.h \
438 php_http_encoding_api.h phpstr/phpstr.h missing.h php_http_request_body_api.h \
439 php_http_exception_object.h php_http_message_object.h php_http_request_object.h \
440 php_http_requestpool_object.h php_http_response_object.h php_http_util_object.h \
441 php_http_querystring_object.h php_http_deflatestream_object.h php_http_inflatestream_object.h \
442 php_http_cookie_api.h php_http_querystring_api.h php_http_request_datashare_api.h php_http_requestdatashare_object.h \
443 php_http_persistent_handle_api.h"
444 ifdef([PHP_INSTALL_HEADERS], [
445 PHP_INSTALL_HEADERS(ext/http, $PHP_HTTP_HEADERS)
446 ], [
447 PHP_SUBST([PHP_HTTP_HEADERS])
448 PHP_ADD_MAKEFILE_FRAGMENT
449 ])
450
451 AC_DEFINE([HAVE_HTTP], [1], [Have extended HTTP support])
452 fi