1 dnl config.m4 for pecl/http
2 dnl $Id: config9.m4 242664 2007-09-18 19:13:37Z mike $
3 dnl vim: noet ts=4 sw=4
5 PHP_ARG_WITH([http], [whether to enable extended HTTP support],
6 [ --with-http Enable extended HTTP support])
7 PHP_ARG_WITH([http-zlib-dir], [],
8 [ --with-http-zlib-dir[=DIR] HTTP: where to find zlib], $PHP_HTTP, $PHP_HTTP)
9 PHP_ARG_WITH([http-libcurl-dir], [],
10 [ --with-http-libcurl-dir[=DIR] HTTP: where to find libcurl], $PHP_HTTP, $PHP_HTTP)
11 PHP_ARG_WITH([http-libevent-dir], [],
12 [ --with-http-libevent-dir[=DIR] HTTP: where to find libevent], $PHP_HTTP_LIBCURL_DIR, "")
14 if test "$PHP_HTTP" != "no"; then
16 HTTP_HAVE_A_REQUEST_LIB=false
18 ifdef([AC_PROG_EGREP], [
21 AC_CHECK_PROG(EGREP, egrep, egrep)
23 ifdef([AC_PROG_SED], [
26 ifdef([LT_AC_PROG_SED], [
29 AC_CHECK_PROG(SED, sed, sed)
35 if test "$PHP_HTTP_SHARED_DEPS" != "no"; then
36 AC_DEFINE([PHP_HTTP_SHARED_DEPS], [1], [ ])
38 AC_DEFINE([PHP_HTTP_SHARED_DEPS], [0], [ ])
42 dnl HTTP_SHARED_DEP(name[, code-if-yes[, code-if-not]])
44 AC_DEFUN([HTTP_SHARED_DEP], [
46 haveext=$[PHP_HTTP_HAVE_EXT_]translit($1,a-z_-,A-Z__)
48 AC_MSG_CHECKING([whether to add a dependency on ext/$extname])
49 if test "$PHP_HTTP_SHARED_DEPS" = "no"; then
52 elif test "$haveext"; then
54 AC_DEFINE([PHP_HTTP_HAVE_EXT_]translit($1,a-z_-,A-Z__), [1], [ ])
55 ifdef([PHP_ADD_EXTENSION_DEP], [
56 PHP_ADD_EXTENSION_DEP([http], $1, true)
66 dnl HTTP_HAVE_PHP_EXT(name[, code-if-yes[, code-if-not]])
68 AC_DEFUN([HTTP_HAVE_PHP_EXT], [
70 haveext=$[PHP_]translit($1,a-z_-,A-Z__)
72 AC_MSG_CHECKING([for ext/$extname support])
73 if test -x "$PHP_EXECUTABLE"; then
74 grepext=`$PHP_EXECUTABLE -m | $EGREP ^$extname\$`
75 if test "$grepext" = "$extname"; then
76 [PHP_HTTP_HAVE_EXT_]translit($1,a-z_-,A-Z__)=1
80 [PHP_HTTP_HAVE_EXT_]translit($1,a-z_-,A-Z__)=
84 elif test "$haveext" != "no" && test "x$haveext" != "x"; then
85 [PHP_HTTP_HAVE_EXT_]translit($1,a-z_-,A-Z__)=1
89 [PHP_HTTP_HAVE_EXT_]translit($1,a-z_-,A-Z__)=
99 AC_CHECK_HEADERS([netdb.h unistd.h])
100 PHP_CHECK_FUNC(gethostname, nsl)
101 PHP_CHECK_FUNC(getdomainname, nsl)
102 PHP_CHECK_FUNC(getservbyport, nsl)
103 PHP_CHECK_FUNC(getservbyport_r, nsl)
104 PHP_CHECK_FUNC(getservbyname, nsl)
105 PHP_CHECK_FUNC(getservbyname_r, nsl)
110 AC_MSG_CHECKING([for zlib.h])
112 for i in "$PHP_HTTP_ZLIB_DIR" "$PHP_ZLIB_DIR" "$PHP_ZLIB" /usr/local /usr /opt; do
113 if test -f "$i/include/zlib.h"; then
118 if test "x$ZLIB_DIR" = "x"; then
119 AC_MSG_RESULT([not found])
120 AC_MSG_ERROR([could not find zlib.h])
122 AC_MSG_RESULT([found in $ZLIB_DIR])
123 AC_MSG_CHECKING([for zlib version >= 1.2.0.4])
124 ZLIB_VERSION=`$EGREP "define ZLIB_VERSION" $ZLIB_DIR/include/zlib.h | $SED -e 's/[[^0-9\.]]//g'`
125 AC_MSG_RESULT([$ZLIB_VERSION])
126 if test `echo $ZLIB_VERSION | $SED -e 's/[[^0-9]]/ /g' | $AWK '{print $1*1000000 + $2*10000 + $3*100 + $4}'` -lt 1020004; then
127 AC_MSG_ERROR([zlib version greater or equal to 1.2.0.4 required])
129 PHP_ADD_INCLUDE($ZLIB_DIR/include)
130 PHP_ADD_LIBRARY_WITH_PATH(z, $ZLIB_DIR/$PHP_LIBDIR, HTTP_SHARED_LIBADD)
138 if test "$PHP_HTTP_LIBCURL_DIR" = "no"; then
139 AC_DEFINE([PHP_HTTP_HAVE_CURL], [0], [ ])
141 AC_MSG_CHECKING([for curl/curl.h])
143 for i in "$PHP_HTTP_LIBCURL_DIR" /usr/local /usr /opt; do
144 if test -f "$i/include/curl/curl.h"; then
149 if test "x$CURL_DIR" = "x"; then
150 AC_MSG_RESULT([not found])
152 AC_MSG_RESULT([found in $CURL_DIR])
154 AC_MSG_CHECKING([for curl-config])
156 for i in "$CURL_DIR/bin/curl-config" "$CURL_DIR/curl-config" `which curl-config`; do
157 if test -x "$i"; then
162 if test "x$CURL_CONFIG" = "x"; then
163 AC_MSG_RESULT([not found])
164 AC_MSG_ERROR([could not find curl-config])
166 AC_MSG_RESULT([found: $CURL_CONFIG])
169 dnl Debian stable has currently 7.18.2
170 AC_MSG_CHECKING([for curl version >= 7.18.2])
171 CURL_VERSION=`$CURL_CONFIG --version | $SED -e 's/[[^0-9\.]]//g'`
172 AC_MSG_RESULT([$CURL_VERSION])
173 if test `echo $CURL_VERSION | $SED -e 's/[[^0-9]]/ /g' | $AWK '{print $1*10000 + $2*100 + $3}'` -lt 71802; then
174 AC_MSG_ERROR([libcurl version greater or equal to 7.18.2 required])
181 save_INCLUDES="$INCLUDES"
185 save_CFLAGS="$CFLAGS"
186 CFLAGS=`$CURL_CONFIG --cflags`
187 save_LDFLAGS="$LDFLAGS"
188 LDFLAGS=`$CURL_CONFIG --libs`
189 LDFLAGS="$LDFLAGS $ld_runpath_switch$CURL_DIR/$PHP_LIBDIR"
191 AC_MSG_CHECKING([for SSL support in libcurl])
192 CURL_SSL=`$CURL_CONFIG --feature | $EGREP SSL`
193 if test "$CURL_SSL" = "SSL"; then
195 AC_DEFINE([PHP_HTTP_HAVE_SSL], [1], [ ])
197 AC_MSG_CHECKING([for openssl support in libcurl])
199 #include <curl/curl.h>
200 int main(int argc, char *argv[]) {
201 curl_version_info_data *data = curl_version_info(CURLVERSION_NOW);
202 if (data && data->ssl_version && *data->ssl_version) {
203 const char *ptr = data->ssl_version;
204 while(*ptr == ' ') ++ptr;
205 return strncasecmp(ptr, "OpenSSL", sizeof("OpenSSL")-1);
211 AC_CHECK_HEADER([openssl/crypto.h], [
212 AC_DEFINE([PHP_HTTP_HAVE_OPENSSL], [1], [ ])
221 AC_MSG_CHECKING([for gnutls support in libcurl])
223 #include <curl/curl.h>
224 int main(int argc, char *argv[]) {
225 curl_version_info_data *data = curl_version_info(CURLVERSION_NOW);
226 if (data && data->ssl_version && *data->ssl_version) {
227 const char *ptr = data->ssl_version;
228 while(*ptr == ' ') ++ptr;
229 return strncasecmp(ptr, "GnuTLS", sizeof("GnuTLS")-1);
235 AC_CHECK_HEADER([gcrypt.h], [
236 AC_DEFINE([PHP_HTTP_HAVE_GNUTLS], [1], [ ])
248 INCLUDES="$save_INCLUDES"
250 CFLAGS="$save_CFLAGS"
251 LDFLAGS="$save_LDFLAGS"
253 dnl end compile tests
255 AC_MSG_CHECKING([for bundled SSL CA info])
257 for i in `$CURL_CONFIG --ca` "/etc/ssl/certs/ca-certificates.crt"; do
258 if test -f "$i"; then
263 if test "x$CURL_CAINFO" = "x"; then
264 AC_MSG_RESULT([not found])
266 AC_MSG_RESULT([$CURL_CAINFO])
267 AC_DEFINE_UNQUOTED([PHP_HTTP_CURL_CAINFO], ["$CURL_CAINFO"], [path to bundled SSL CA info])
270 PHP_ADD_INCLUDE($CURL_DIR/include)
271 PHP_ADD_LIBRARY_WITH_PATH(curl, $CURL_DIR/$PHP_LIBDIR, HTTP_SHARED_LIBADD)
272 PHP_EVAL_LIBLINE(`$CURL_CONFIG --libs`, HTTP_SHARED_LIBADD)
273 if test "x$CURL_SSL" != "x"; then
274 PHP_ADD_LIBRARY_WITH_PATH([$CURL_SSL], $CURL_DIR/$PHP_LIBDIR, PHP_HTTP_SHARED_LIBADD)
276 AC_DEFINE([PHP_HTTP_HAVE_CURL], [1], [Have libcurl support])
277 HTTP_HAVE_A_REQUEST_LIB=true
285 if test "$PHP_HTTP_LIBEVENT_DIR" = "no"; then
286 AC_DEFINE([PHP_HTTP_HAVE_EVENT], [0], [ ])
288 HTTP_HAVE_PHP_EXT([event], [
289 AC_MSG_WARN([event support is incompatible with pecl/event; continuing without libevent support])
290 AC_DEFINE([PHP_HTTP_HAVE_EVENT], [0], [ ])
292 AC_MSG_CHECKING([for event2/event.h])
294 for i in "$PHP_HTTP_LIBEVENT_DIR" /usr/local /usr /opt; do
295 if test -f "$i/include/event.h"; then
300 if test "x$EVENT_DIR" = "x"; then
301 AC_MSG_RESULT([not found])
302 AC_MSG_WARN([continuing without libevent support])
303 AC_DEFINE([PHP_HTTP_HAVE_EVENT], [0], [ ])
305 AC_MSG_RESULT([found in $EVENT_DIR])
307 AC_MSG_CHECKING([for libevent version, roughly])
309 if test -f "$EVENT_DIR/include/event2/event.h"; then
310 EVENT_VER="`$EGREP _EVENT_VERSION $EVENT_DIR/include/event2/event-config.h | $AWK '{print $3}'`"
311 AC_DEFINE([PHP_HTTP_HAVE_EVENT2], [1], [ ])
313 AC_DEFINE([PHP_HTTP_HAVE_EVENT2], [0], [ ])
314 if test -f "$EVENT_DIR/include/evhttp.h" && test -f "$EVENT_DIR/include/evdns.h"; then
315 if test -f "$EVENT_DIR/include/evrpc.h"; then
316 EVENT_VER="1.4 or greater"
318 EVENT_VER="1.2 or greater"
321 EVENT_VER="1.1b or lower"
324 AC_DEFINE_UNQUOTED([PHP_HTTP_EVENT_VERSION], ["$EVENT_VER"], [ ])
325 AC_MSG_RESULT([$EVENT_VER])
327 PHP_ADD_INCLUDE($EVENT_DIR/include)
328 PHP_ADD_LIBRARY_WITH_PATH(event, $EVENT_DIR/$PHP_LIBDIR, HTTP_SHARED_LIBADD)
329 AC_DEFINE([PHP_HTTP_HAVE_EVENT], [1], [Have libevent support for cURL])
337 HTTP_HAVE_PHP_EXT([raphf], [
338 AC_MSG_CHECKING([for php_raphf.h])
339 HTTP_EXT_RAPHF_INCDIR=
340 for i in `echo $INCLUDES | $SED -e's/-I//g'` $abs_srcdir ../raphf; do
342 if test -f $i/php_raphf.h; then
343 HTTP_EXT_RAPHF_INCDIR=$i
345 elif test -f $i/ext/raphf/php_raphf.h; then
346 HTTP_EXT_RAPHF_INCDIR=$i/ext/raphf
351 if test "x$HTTP_EXT_RAPHF_INCDIR" = "x"; then
352 AC_MSG_ERROR([not found])
354 AC_MSG_RESULT([$HTTP_EXT_RAPHF_INCDIR])
355 AC_DEFINE([PHP_HTTP_HAVE_PHP_RAPHF_H], [1], [Have ext/raphf support])
356 PHP_ADD_INCLUDE([$HTTP_EXT_RAPHF_INCDIR])
363 HTTP_HAVE_PHP_EXT([propro], [
364 AC_MSG_CHECKING([for php_propro.h])
365 HTTP_EXT_PROPRO_INCDIR=
366 for i in `echo $INCLUDES | $SED -e's/-I//g'` $abs_srcdir ../propro; do
368 if test -f $i/php_propro.h; then
369 HTTP_EXT_PROPRO_INCDIR=$i
371 elif test -f $i/ext/propro/php_propro.h; then
372 HTTP_EXT_PROPRO_INCDIR=$i/ext/propro
377 if test "x$HTTP_EXT_PROPRO_INCDIR" = "x"; then
378 AC_MSG_ERROR([not found])
380 AC_MSG_RESULT([$HTTP_EXT_PROPRO_INCDIR])
381 AC_DEFINE([PHP_HTTP_HAVE_PHP_PROPRO_H], [1], [Have ext/propro support])
382 PHP_ADD_INCLUDE([$HTTP_EXT_PROPRO_INCDIR])
386 PHP_ARG_WITH([http-shared-deps], [whether to depend on extensions which have been built shared],
387 [ --without-http-shared-deps HTTP: do not depend on extensions like hash
388 and iconv (when they are built shared)], $PHP_HTTP, $PHP_HTTP)
392 HTTP_HAVE_PHP_EXT([hash], [
393 AC_MSG_CHECKING([for php_hash.h])
394 HTTP_EXT_HASH_INCDIR=
395 for i in `echo $INCLUDES | $SED -e's/-I//g'` $abs_srcdir ../hash; do
397 if test -f $i/php_hash.h; then
398 HTTP_EXT_HASH_INCDIR=$i
400 elif test -f $i/ext/hash/php_hash.h; then
401 HTTP_EXT_HASH_INCDIR=$i/ext/hash
406 if test "x$HTTP_EXT_HASH_INCDIR" = "x"; then
407 AC_MSG_RESULT([not found])
409 AC_MSG_RESULT([$HTTP_EXT_HASH_INCDIR])
410 AC_DEFINE([PHP_HTTP_HAVE_PHP_HASH_H], [1], [Have ext/hash support])
411 PHP_ADD_INCLUDE([$HTTP_EXT_HASH_INCDIR])
418 HTTP_HAVE_PHP_EXT([json])
424 HTTP_HAVE_PHP_EXT([iconv])
433 php_http_client_curl.c \
434 php_http_client_request.c \
435 php_http_client_response.c \
438 php_http_encoding.c \
440 php_http_env_request.c \
441 php_http_env_response.c \
443 php_http_exception.c \
445 php_http_header_parser.c \
448 php_http_message_body.c \
450 php_http_message_parser.c \
452 php_http_negotiate.c \
456 php_http_querystring.c \
461 PHP_NEW_EXTENSION([http], $PHP_HTTP_SOURCES, $ext_shared)
463 dnl shared extension deps
464 HTTP_SHARED_DEP([hash])
465 HTTP_SHARED_DEP([iconv])
466 HTTP_SHARED_DEP([json])
469 PHP_ADD_EXTENSION_DEP([http], [raphf], true)
470 PHP_ADD_EXTENSION_DEP([http], [propo], true)
472 PHP_SUBST([HTTP_SHARED_LIBADD])
477 php_http_curl_client.h \
478 php_http_curl_client_datashare.h \
479 php_http_client_datashare.h \
480 php_http_client_factory.h \
482 php_http_client_interface.h \
483 php_http_curl_client_pool.h \
484 php_http_client_pool.h \
485 php_http_client_request.h \
486 php_http_client_response.h \
489 php_http_encoding.h \
491 php_http_env_request.h \
492 php_http_env_response.h \
494 php_http_exception.h \
497 php_http_header_parser.h \
500 php_http_message_body.h \
502 php_http_message_parser.h \
504 php_http_negotiate.h \
508 php_http_querystring.h \
513 PHP_INSTALL_HEADERS(ext/http, $PHP_HTTP_HEADERS)
515 AC_DEFINE([HAVE_HTTP], [1], [Have extended HTTP support])