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, "")
13 PHP_ARG_WITH([http-libidn-dir], [],
14 [ --with-http-libidn-dir=[=DIR] HTTP: where to find libidn], $PHP_HTTP_LIBCURL_DIR, "")
16 if test "$PHP_HTTP" != "no"; then
18 HTTP_HAVE_A_REQUEST_LIB=false
20 ifdef([AC_PROG_EGREP], [
23 AC_CHECK_PROG(EGREP, egrep, egrep)
25 ifdef([AC_PROG_SED], [
28 ifdef([LT_AC_PROG_SED], [
31 AC_CHECK_PROG(SED, sed, sed)
37 if test "$PHP_HTTP_SHARED_DEPS" != "no"; then
38 AC_DEFINE([PHP_HTTP_SHARED_DEPS], [1], [ ])
40 AC_DEFINE([PHP_HTTP_SHARED_DEPS], [0], [ ])
44 dnl HTTP_SHARED_DEP(name[, code-if-yes[, code-if-not]])
46 AC_DEFUN([HTTP_SHARED_DEP], [
48 haveext=$[PHP_HTTP_HAVE_EXT_]translit($1,a-z_-,A-Z__)
50 AC_MSG_CHECKING([whether to add a dependency on ext/$extname])
51 if test "$PHP_HTTP_SHARED_DEPS" = "no"; then
54 elif test "$haveext"; then
56 AC_DEFINE([PHP_HTTP_HAVE_EXT_]translit($1,a-z_-,A-Z__), [1], [ ])
57 ifdef([PHP_ADD_EXTENSION_DEP], [
58 PHP_ADD_EXTENSION_DEP([http], $1, true)
68 dnl HTTP_HAVE_PHP_EXT(name[, code-if-yes[, code-if-not]])
70 AC_DEFUN([HTTP_HAVE_PHP_EXT], [
72 haveext=$[PHP_]translit($1,a-z_-,A-Z__)
73 AC_MSG_CHECKING([for ext/$extname support])
74 if test -x "$PHP_EXECUTABLE"; then
75 grepext=`$PHP_EXECUTABLE -m | $EGREP ^$extname\$`
76 if test "$grepext" = "$extname"; then
77 [PHP_HTTP_HAVE_EXT_]translit($1,a-z_-,A-Z__)=1
81 [PHP_HTTP_HAVE_EXT_]translit($1,a-z_-,A-Z__)=
85 elif test "$haveext" != "no" && test "x$haveext" != "x"; then
86 [PHP_HTTP_HAVE_EXT_]translit($1,a-z_-,A-Z__)=1
90 [PHP_HTTP_HAVE_EXT_]translit($1,a-z_-,A-Z__)=
102 dnl getdomainname() is declared in netdb.h on some platforms: AIX, OSF
103 AC_CHECK_HEADERS([netdb.h unistd.h wchar.h wctype.h arpa/inet.h])
104 PHP_CHECK_FUNC(gethostname, nsl)
105 PHP_CHECK_FUNC(getdomainname, nsl)
106 PHP_CHECK_FUNC(mbrtowc)
107 PHP_CHECK_FUNC(mbtowc)
108 PHP_CHECK_FUNC(iswalnum)
109 PHP_CHECK_FUNC(inet_pton)
115 AC_MSG_CHECKING([for idna.h])
117 for i in "$PHP_HTTP_LIBIDN_DIR" "$IDN_DIR" /usr/local /usr /opt; do
118 if test -f "$i/include/idna.h"; then
123 if test "x$IDNA_DIR" = "x"; then
124 AC_MSG_RESULT([not found])
127 AC_CHECK_HEADERS(unicode/uidna.h)
128 PHP_CHECK_FUNC(uidna_IDNToASCII, icucore);;
131 AC_MSG_RESULT([found in $IDNA_DIR])
132 AC_DEFINE([PHP_HTTP_HAVE_IDN], [1], [Have libidn support])
133 PHP_ADD_INCLUDE($IDNA_DIR/include)
134 PHP_ADD_LIBRARY_WITH_PATH(idn, $IDNA_DIR/$PHP_LIBDIR, HTTP_SHARED_LIBADD)
140 AC_MSG_CHECKING([for zlib.h])
142 for i in "$PHP_HTTP_ZLIB_DIR" "$PHP_ZLIB_DIR" "$PHP_ZLIB" /usr/local /usr /opt; do
143 if test -f "$i/include/zlib.h"; then
148 if test "x$ZLIB_DIR" = "x"; then
149 AC_MSG_RESULT([not found])
150 AC_MSG_ERROR([could not find zlib.h])
152 AC_MSG_RESULT([found in $ZLIB_DIR])
153 AC_MSG_CHECKING([for zlib version >= 1.2.0.4])
154 ZLIB_VERSION=`$EGREP "define ZLIB_VERSION" $ZLIB_DIR/include/zlib.h | $SED -e 's/[[^0-9\.]]//g'`
155 AC_MSG_RESULT([$ZLIB_VERSION])
156 if test `echo $ZLIB_VERSION | $SED -e 's/[[^0-9]]/ /g' | $AWK '{print $1*1000000 + $2*10000 + $3*100 + $4}'` -lt 1020004; then
157 AC_MSG_ERROR([zlib version greater or equal to 1.2.0.4 required])
159 PHP_ADD_INCLUDE($ZLIB_DIR/include)
160 PHP_ADD_LIBRARY_WITH_PATH(z, $ZLIB_DIR/$PHP_LIBDIR, HTTP_SHARED_LIBADD)
168 if test "$PHP_HTTP_LIBCURL_DIR" = "no"; then
169 AC_DEFINE([PHP_HTTP_HAVE_CURL], [0], [ ])
171 AC_MSG_CHECKING([for curl/curl.h])
173 for i in "$PHP_HTTP_LIBCURL_DIR" /usr/local /usr /opt; do
174 if test -f "$i/include/curl/curl.h"; then
179 if test "x$CURL_DIR" = "x"; then
180 AC_MSG_RESULT([not found])
182 AC_MSG_RESULT([found in $CURL_DIR])
184 AC_MSG_CHECKING([for curl-config])
186 for i in "$CURL_DIR/bin/curl-config" "$CURL_DIR/curl-config" `which curl-config`; do
187 if test -x "$i"; then
192 if test "x$CURL_CONFIG" = "x"; then
193 AC_MSG_RESULT([not found])
194 AC_MSG_ERROR([could not find curl-config])
196 AC_MSG_RESULT([found: $CURL_CONFIG])
201 dnl Debian wheezy: 7.26.0
202 dnl Debian sqeeze: 7.21.0
203 dnl Debian ancient 7.18.2
204 AC_MSG_CHECKING([for curl version >= 7.18.2])
205 CURL_VERSION=`$CURL_CONFIG --version | $SED -e 's/[[^0-9\.]]//g'`
206 AC_MSG_RESULT([$CURL_VERSION])
207 if test `echo $CURL_VERSION | $SED -e 's/[[^0-9]]/ /g' | $AWK '{print $1*10000 + $2*100 + $3}'` -lt 71802; then
208 AC_MSG_ERROR([libcurl version greater or equal to 7.18.2 required])
211 AC_MSG_CHECKING([for HTTP2 support in libcurl])
212 if $CURL_CONFIG --features | $EGREP -q HTTP2; then
214 AC_DEFINE([PHP_HTTP_HAVE_HTTP2], [1], [ ])
223 save_INCLUDES="$INCLUDES"
227 save_CFLAGS="$CFLAGS"
228 CFLAGS="$CFLAGS `$CURL_CONFIG --cflags`"
229 save_LDFLAGS="$LDFLAGS"
230 LDFLAGS="$ld_runpath_switch$CURL_DIR/$PHP_LIBDIR"
232 AC_MSG_CHECKING([for SSL support in libcurl])
233 CURL_SSL=`$CURL_CONFIG --feature | $EGREP SSL`
235 if test "$CURL_SSL" = "SSL"; then
237 AC_DEFINE([PHP_HTTP_HAVE_SSL], [1], [ ])
239 AC_MSG_CHECKING([for openssl support in libcurl])
241 #include <curl/curl.h>
242 int main(int argc, char *argv[]) {
243 curl_version_info_data *data = curl_version_info(CURLVERSION_NOW);
244 if (data && data->ssl_version && *data->ssl_version) {
245 const char *ptr = data->ssl_version;
246 while(*ptr == ' ') ++ptr;
247 return strncasecmp(ptr, "OpenSSL", sizeof("OpenSSL")-1);
253 AC_CHECK_HEADER([openssl/ssl.h], [
254 AC_CHECK_HEADER([openssl/crypto.h], [
255 AC_DEFINE([PHP_HTTP_HAVE_OPENSSL], [1], [ ])
256 CURL_SSL_LIBS="ssl crypto"
265 AC_MSG_CHECKING([for gnutls support in libcurl])
267 #include <curl/curl.h>
268 int main(int argc, char *argv[]) {
269 curl_version_info_data *data = curl_version_info(CURLVERSION_NOW);
270 if (data && data->ssl_version && *data->ssl_version) {
271 const char *ptr = data->ssl_version;
272 while(*ptr == ' ') ++ptr;
273 return strncasecmp(ptr, "GnuTLS", sizeof("GnuTLS")-1);
279 AC_CHECK_HEADER([gnutls.h], [
280 AC_CHECK_HEADER([gcrypt.h], [
281 AC_DEFINE([PHP_HTTP_HAVE_GNUTLS], [1], [ ])
282 CURL_SSL_LIBS="gnutls gcrypt"
294 AC_MSG_CHECKING([for ares support in libcurl])
296 #include <curl/curl.h>
297 int main(int argc, char *argv[]) {
298 curl_version_info_data *data = curl_version_info(CURLVERSION_NOW);
299 if (data && data->ares && data->ares_num0) {
306 AC_DEFINE([PHP_HTTP_HAVE_ARES], [1], [ ])
313 AC_MSG_CHECKING([whether CURLOPT_TLSAUTH_TYPE expects CURL_TLSAUTH_SRP or literal "SRP"])
315 #include <curl/curl.h>
316 int main(int argc, char *argv[]) {
317 CURL *ch = curl_easy_init();
318 return curl_easy_setopt(ch, CURLOPT_TLSAUTH_TYPE, CURL_TLSAUTH_SRP);
321 AC_MSG_RESULT([CURL_TLSAUTH_SRP])
322 AC_DEFINE([PHP_HTTP_CURL_TLSAUTH_SRP], [CURL_TLSAUTH_SRP], [ ])
323 AC_DEFINE([PHP_HTTP_CURL_TLSAUTH_DEF], [CURL_TLSAUTH_NONE], [ ])
326 #include <curl/curl.h>
327 int main(int argc, char *argv[]) {
328 CURL *ch = curl_easy_init();
329 return curl_easy_setopt(ch, CURLOPT_TLSAUTH_TYPE, "SRP");
332 AC_MSG_RESULT(["SRP"])
333 AC_DEFINE([PHP_HTTP_CURL_TLSAUTH_SRP], ["SRP"], [ ])
334 AC_DEFINE([PHP_HTTP_CURL_TLSAUTH_DEF], [""], [ ])
336 AC_MSG_RESULT([neither])
338 AC_MSG_RESULT([neither])
341 AC_MSG_RESULT([neither])
344 INCLUDES="$save_INCLUDES"
346 CFLAGS="$save_CFLAGS"
347 LDFLAGS="$save_LDFLAGS"
349 if test -n "$CURL_SSL_LIBS"; then
350 for CURL_SSL_LIB in $CURL_SSL_LIBS; do
351 PHP_ADD_LIBRARY_WITH_PATH([$CURL_SSL_LIB], $CURL_DIR/$PHP_LIBDIR, PHP_HTTP_SHARED_LIBADD)
355 dnl end compile tests
357 AC_MSG_CHECKING([for bundled SSL CA info])
359 for i in `$CURL_CONFIG --ca` "/etc/ssl/certs/ca-certificates.crt" "/etc/ssl/certs/ca-bundle.crt"; do
360 if test -f "$i"; then
365 if test "x$CURL_CAINFO" = "x"; then
366 AC_MSG_RESULT([not found])
368 AC_MSG_RESULT([$CURL_CAINFO])
369 AC_DEFINE_UNQUOTED([PHP_HTTP_CURL_CAINFO], ["$CURL_CAINFO"], [path to bundled SSL CA info])
372 PHP_ADD_INCLUDE($CURL_DIR/include)
373 PHP_ADD_LIBRARY_WITH_PATH(curl, $CURL_DIR/$PHP_LIBDIR, HTTP_SHARED_LIBADD)
374 PHP_EVAL_LIBLINE(`$CURL_CONFIG --libs`, HTTP_SHARED_LIBADD)
375 AC_DEFINE([PHP_HTTP_HAVE_CURL], [1], [Have libcurl support])
376 HTTP_HAVE_A_REQUEST_LIB=true
384 if test "$PHP_HTTP_LIBEVENT_DIR" = "no"; then
385 AC_DEFINE([PHP_HTTP_HAVE_EVENT], [0], [ ])
387 AC_MSG_CHECKING([for event2/event.h])
389 for i in "$PHP_HTTP_LIBEVENT_DIR" /usr/local /usr /opt; do
390 if test -f "$i/include/event.h"; then
395 if test "x$EVENT_DIR" = "x"; then
396 AC_MSG_RESULT([not found])
397 AC_MSG_WARN([continuing without libevent support])
398 AC_DEFINE([PHP_HTTP_HAVE_EVENT], [0], [ ])
400 AC_MSG_RESULT([found in $EVENT_DIR])
402 AC_MSG_CHECKING([for libevent version, roughly])
404 if test -f "$EVENT_DIR/include/event2/event.h"; then
405 EVENT_VER="`$AWK '/_EVENT_VERSION/ {gsub(/\"/,\"\",$3); print $3}' < $EVENT_DIR/include/event2/event-config.h`"
406 AC_DEFINE([PHP_HTTP_HAVE_EVENT2], [1], [ ])
408 AC_DEFINE([PHP_HTTP_HAVE_EVENT2], [0], [ ])
409 if test -f "$EVENT_DIR/include/evhttp.h" && test -f "$EVENT_DIR/include/evdns.h"; then
410 if test -f "$EVENT_DIR/include/evrpc.h"; then
411 EVENT_VER="1.4 or greater"
413 EVENT_VER="1.2 or greater"
416 EVENT_VER="1.1b or lower"
419 AC_DEFINE_UNQUOTED([PHP_HTTP_EVENT_VERSION], ["$EVENT_VER"], [ ])
420 AC_MSG_RESULT([$EVENT_VER])
422 PHP_ADD_INCLUDE($EVENT_DIR/include)
423 PHP_ADD_LIBRARY_WITH_PATH(event, $EVENT_DIR/$PHP_LIBDIR, HTTP_SHARED_LIBADD)
424 AC_DEFINE([PHP_HTTP_HAVE_EVENT], [1], [Have libevent support for cURL])
431 HTTP_HAVE_PHP_EXT([raphf], [
432 AC_MSG_CHECKING([for php_raphf.h])
433 HTTP_EXT_RAPHF_INCDIR=
434 for i in `echo $INCLUDES | $SED -e's/-I//g'` $abs_srcdir ../raphf; do
436 if test -f $i/php_raphf.h; then
437 HTTP_EXT_RAPHF_INCDIR=$i
439 elif test -f $i/ext/raphf/php_raphf.h; then
440 HTTP_EXT_RAPHF_INCDIR=$i/ext/raphf
445 if test "x$HTTP_EXT_RAPHF_INCDIR" = "x"; then
446 AC_MSG_ERROR([not found])
448 AC_MSG_RESULT([$HTTP_EXT_RAPHF_INCDIR])
449 AC_DEFINE([PHP_HTTP_HAVE_PHP_RAPHF_H], [1], [Have ext/raphf support])
450 PHP_ADD_INCLUDE([$HTTP_EXT_RAPHF_INCDIR])
453 AC_MSG_ERROR([Please install pecl/raphf and activate extension=raphf.$SHLIB_DL_SUFFIX_NAME in your php.ini])
459 HTTP_HAVE_PHP_EXT([propro], [
460 AC_MSG_CHECKING([for php_propro.h])
461 HTTP_EXT_PROPRO_INCDIR=
462 for i in `echo $INCLUDES | $SED -e's/-I//g'` $abs_srcdir ../propro; do
464 if test -f $i/php_propro.h; then
465 HTTP_EXT_PROPRO_INCDIR=$i
467 elif test -f $i/ext/propro/php_propro.h; then
468 HTTP_EXT_PROPRO_INCDIR=$i/ext/propro
473 if test "x$HTTP_EXT_PROPRO_INCDIR" = "x"; then
474 AC_MSG_ERROR([not found])
476 AC_MSG_RESULT([$HTTP_EXT_PROPRO_INCDIR])
477 AC_DEFINE([PHP_HTTP_HAVE_PHP_PROPRO_H], [1], [Have ext/propro support])
478 PHP_ADD_INCLUDE([$HTTP_EXT_PROPRO_INCDIR])
481 AC_MSG_ERROR([Please install pecl/propro and activate extension=propro.$SHLIB_DL_SUFFIX_NAME in your php.ini])
484 PHP_ARG_WITH([http-shared-deps], [whether to depend on extensions which have been built shared],
485 [ --without-http-shared-deps HTTP: do not depend on extensions like hash
486 and iconv (when they are built shared)], $PHP_HTTP, $PHP_HTTP)
490 HTTP_HAVE_PHP_EXT([hash], [
491 AC_MSG_CHECKING([for php_hash.h])
492 HTTP_EXT_HASH_INCDIR=
493 for i in `echo $INCLUDES | $SED -e's/-I//g'` $abs_srcdir ../hash; do
495 if test -f $i/php_hash.h; then
496 HTTP_EXT_HASH_INCDIR=$i
498 elif test -f $i/ext/hash/php_hash.h; then
499 HTTP_EXT_HASH_INCDIR=$i/ext/hash
504 if test "x$HTTP_EXT_HASH_INCDIR" = "x"; then
505 AC_MSG_RESULT([not found])
507 AC_MSG_RESULT([$HTTP_EXT_HASH_INCDIR])
508 AC_DEFINE([PHP_HTTP_HAVE_PHP_HASH_H], [1], [Have ext/hash support])
509 PHP_ADD_INCLUDE([$HTTP_EXT_HASH_INCDIR])
516 HTTP_HAVE_PHP_EXT([iconv])
525 php_http_client_curl.c \
526 php_http_client_request.c \
527 php_http_client_response.c \
530 php_http_encoding.c \
532 php_http_env_request.c \
533 php_http_env_response.c \
535 php_http_exception.c \
537 php_http_header_parser.c \
540 php_http_message_body.c \
542 php_http_message_parser.c \
544 php_http_negotiate.c \
548 php_http_querystring.c \
552 PHP_NEW_EXTENSION([http], $PHP_HTTP_SOURCES, $ext_shared)
554 dnl shared extension deps
555 HTTP_SHARED_DEP([hash])
556 HTTP_SHARED_DEP([iconv])
559 PHP_ADD_EXTENSION_DEP([http], [raphf], true)
560 PHP_ADD_EXTENSION_DEP([http], [propro], true)
562 PHP_SUBST([HTTP_SHARED_LIBADD])
567 php_http_curl_client.h \
568 php_http_curl_client_datashare.h \
569 php_http_client_datashare.h \
570 php_http_client_factory.h \
572 php_http_client_interface.h \
573 php_http_curl_client_pool.h \
574 php_http_client_pool.h \
575 php_http_client_request.h \
576 php_http_client_response.h \
579 php_http_encoding.h \
581 php_http_env_request.h \
582 php_http_env_response.h \
584 php_http_exception.h \
587 php_http_header_parser.h \
590 php_http_message_body.h \
592 php_http_message_parser.h \
594 php_http_negotiate.h \
598 php_http_querystring.h \
599 php_http_response_codes.h \
604 PHP_INSTALL_HEADERS(ext/http, $PHP_HTTP_HEADERS)
606 AC_DEFINE([HAVE_HTTP], [1], [Have extended HTTP support])
607 if $HTTP_HAVE_A_REQUEST_LIB; then
608 AC_DEFINE([PHP_HTTP_HAVE_CLIENT], [1], [Have HTTP client support])