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__)=
101 dnl getdomainname() is declared in netdb.h on some platforms: AIX, OSF
102 AC_CHECK_HEADERS([netdb.h unistd.h wchar.h wctype.h langinfo.h])
103 PHP_CHECK_FUNC(gethostname, nsl)
104 PHP_CHECK_FUNC(getdomainname, nsl)
105 PHP_CHECK_FUNC(mbrtowc)
106 PHP_CHECK_FUNC(mbtowc)
107 PHP_CHECK_FUNC(iswalnum)
108 PHP_CHECK_FUNC(nl_langinfo)
114 AC_MSG_CHECKING([for idna.h])
116 for i in "$PHP_HTTP_LIBIDN_DIR" "$IDN_DIR" /usr/local /usr /opt; do
117 if test -f "$i/include/idna.h"; then
122 if test "x$IDNA_DIR" = "x"; then
123 AC_MSG_RESULT([not found])
125 AC_MSG_RESULT([found in $IDNA_DIR])
126 AC_DEFINE([PHP_HTTP_HAVE_IDN], [1], [Have libidn support])
127 PHP_ADD_INCLUDE($IDNA_DIR/include)
128 PHP_ADD_LIBRARY_WITH_PATH(idn, $IDNA_DIR/$PHP_LIBDIR, HTTP_SHARED_LIBADD)
134 AC_MSG_CHECKING([for zlib.h])
136 for i in "$PHP_HTTP_ZLIB_DIR" "$PHP_ZLIB_DIR" "$PHP_ZLIB" /usr/local /usr /opt; do
137 if test -f "$i/include/zlib.h"; then
142 if test "x$ZLIB_DIR" = "x"; then
143 AC_MSG_RESULT([not found])
144 AC_MSG_ERROR([could not find zlib.h])
146 AC_MSG_RESULT([found in $ZLIB_DIR])
147 AC_MSG_CHECKING([for zlib version >= 1.2.0.4])
148 ZLIB_VERSION=`$EGREP "define ZLIB_VERSION" $ZLIB_DIR/include/zlib.h | $SED -e 's/[[^0-9\.]]//g'`
149 AC_MSG_RESULT([$ZLIB_VERSION])
150 if test `echo $ZLIB_VERSION | $SED -e 's/[[^0-9]]/ /g' | $AWK '{print $1*1000000 + $2*10000 + $3*100 + $4}'` -lt 1020004; then
151 AC_MSG_ERROR([zlib version greater or equal to 1.2.0.4 required])
153 PHP_ADD_INCLUDE($ZLIB_DIR/include)
154 PHP_ADD_LIBRARY_WITH_PATH(z, $ZLIB_DIR/$PHP_LIBDIR, HTTP_SHARED_LIBADD)
162 if test "$PHP_HTTP_LIBCURL_DIR" = "no"; then
163 AC_DEFINE([PHP_HTTP_HAVE_CURL], [0], [ ])
165 AC_MSG_CHECKING([for curl/curl.h])
167 for i in "$PHP_HTTP_LIBCURL_DIR" /usr/local /usr /opt; do
168 if test -f "$i/include/curl/curl.h"; then
173 if test "x$CURL_DIR" = "x"; then
174 AC_MSG_RESULT([not found])
176 AC_MSG_RESULT([found in $CURL_DIR])
178 AC_MSG_CHECKING([for curl-config])
180 for i in "$CURL_DIR/bin/curl-config" "$CURL_DIR/curl-config" `which curl-config`; do
181 if test -x "$i"; then
186 if test "x$CURL_CONFIG" = "x"; then
187 AC_MSG_RESULT([not found])
188 AC_MSG_ERROR([could not find curl-config])
190 AC_MSG_RESULT([found: $CURL_CONFIG])
195 dnl Debian wheezy: 7.26.0
196 dnl Debian sqeeze: 7.21.0
197 dnl Debian ancient 7.18.2
198 AC_MSG_CHECKING([for curl version >= 7.18.2])
199 CURL_VERSION=`$CURL_CONFIG --version | $SED -e 's/[[^0-9\.]]//g'`
200 AC_MSG_RESULT([$CURL_VERSION])
201 if test `echo $CURL_VERSION | $SED -e 's/[[^0-9]]/ /g' | $AWK '{print $1*10000 + $2*100 + $3}'` -lt 71802; then
202 AC_MSG_ERROR([libcurl version greater or equal to 7.18.2 required])
209 save_INCLUDES="$INCLUDES"
213 save_CFLAGS="$CFLAGS"
214 CFLAGS="$CFLAGS `$CURL_CONFIG --cflags`"
215 save_LDFLAGS="$LDFLAGS"
216 LDFLAGS="$LDFLAGS `$CURL_CONFIG --libs` $ld_runpath_switch$CURL_DIR/$PHP_LIBDIR"
218 AC_MSG_CHECKING([for SSL support in libcurl])
219 CURL_SSL=`$CURL_CONFIG --feature | $EGREP SSL`
221 if test "$CURL_SSL" = "SSL"; then
223 AC_DEFINE([PHP_HTTP_HAVE_SSL], [1], [ ])
225 AC_MSG_CHECKING([for openssl support in libcurl])
227 #include <curl/curl.h>
228 int main(int argc, char *argv[]) {
229 curl_version_info_data *data = curl_version_info(CURLVERSION_NOW);
230 if (data && data->ssl_version && *data->ssl_version) {
231 const char *ptr = data->ssl_version;
232 while(*ptr == ' ') ++ptr;
233 return strncasecmp(ptr, "OpenSSL", sizeof("OpenSSL")-1);
239 AC_CHECK_HEADER([openssl/ssl.h], [
240 AC_CHECK_HEADER([openssl/crypto.h], [
241 AC_DEFINE([PHP_HTTP_HAVE_OPENSSL], [1], [ ])
242 CURL_SSL_LIBS="ssl crypto"
251 AC_MSG_CHECKING([for gnutls support in libcurl])
253 #include <curl/curl.h>
254 int main(int argc, char *argv[]) {
255 curl_version_info_data *data = curl_version_info(CURLVERSION_NOW);
256 if (data && data->ssl_version && *data->ssl_version) {
257 const char *ptr = data->ssl_version;
258 while(*ptr == ' ') ++ptr;
259 return strncasecmp(ptr, "GnuTLS", sizeof("GnuTLS")-1);
265 AC_CHECK_HEADER([gnutls.h], [
266 AC_CHECK_HEADER([gcrypt.h], [
267 AC_DEFINE([PHP_HTTP_HAVE_GNUTLS], [1], [ ])
268 CURL_SSL_LIBS="gnutls gcrypt"
280 AC_MSG_CHECKING([for ares support in libcurl])
282 #include <curl/curl.h>
283 int main(int argc, char *argv[]) {
284 curl_version_info_data *data = curl_version_info(CURLVERSION_NOW);
285 if (data && data->ares && data->ares_num0) {
292 AC_DEFINE([PHP_HTTP_HAVE_ARES], [1], [ ])
299 INCLUDES="$save_INCLUDES"
301 CFLAGS="$save_CFLAGS"
302 LDFLAGS="$save_LDFLAGS"
304 if test -n "$CURL_SSL_LIBS"; then
305 for CURL_SSL_LIB in $CURL_SSL_LIBS; do
306 PHP_ADD_LIBRARY_WITH_PATH([$CURL_SSL_LIB], $CURL_DIR/$PHP_LIBDIR, PHP_HTTP_SHARED_LIBADD)
310 dnl end compile tests
312 AC_MSG_CHECKING([for bundled SSL CA info])
314 for i in `$CURL_CONFIG --ca` "/etc/ssl/certs/ca-certificates.crt" "/etc/ssl/certs/ca-bundle.crt"; do
315 if test -f "$i"; then
320 if test "x$CURL_CAINFO" = "x"; then
321 AC_MSG_RESULT([not found])
323 AC_MSG_RESULT([$CURL_CAINFO])
324 AC_DEFINE_UNQUOTED([PHP_HTTP_CURL_CAINFO], ["$CURL_CAINFO"], [path to bundled SSL CA info])
327 PHP_ADD_INCLUDE($CURL_DIR/include)
328 PHP_ADD_LIBRARY_WITH_PATH(curl, $CURL_DIR/$PHP_LIBDIR, HTTP_SHARED_LIBADD)
329 PHP_EVAL_LIBLINE(`$CURL_CONFIG --libs`, HTTP_SHARED_LIBADD)
330 AC_DEFINE([PHP_HTTP_HAVE_CURL], [1], [Have libcurl support])
331 HTTP_HAVE_A_REQUEST_LIB=true
339 if test "$PHP_HTTP_LIBEVENT_DIR" = "no"; then
340 AC_DEFINE([PHP_HTTP_HAVE_EVENT], [0], [ ])
342 AC_MSG_CHECKING([for event2/event.h])
344 for i in "$PHP_HTTP_LIBEVENT_DIR" /usr/local /usr /opt; do
345 if test -f "$i/include/event.h"; then
350 if test "x$EVENT_DIR" = "x"; then
351 AC_MSG_RESULT([not found])
352 AC_MSG_WARN([continuing without libevent support])
353 AC_DEFINE([PHP_HTTP_HAVE_EVENT], [0], [ ])
355 AC_MSG_RESULT([found in $EVENT_DIR])
357 AC_MSG_CHECKING([for libevent version, roughly])
359 if test -f "$EVENT_DIR/include/event2/event.h"; then
360 EVENT_VER="`$AWK '/_EVENT_VERSION/ {gsub(/\"/,\"\",$3); print $3}' < $EVENT_DIR/include/event2/event-config.h`"
361 AC_DEFINE([PHP_HTTP_HAVE_EVENT2], [1], [ ])
363 AC_DEFINE([PHP_HTTP_HAVE_EVENT2], [0], [ ])
364 if test -f "$EVENT_DIR/include/evhttp.h" && test -f "$EVENT_DIR/include/evdns.h"; then
365 if test -f "$EVENT_DIR/include/evrpc.h"; then
366 EVENT_VER="1.4 or greater"
368 EVENT_VER="1.2 or greater"
371 EVENT_VER="1.1b or lower"
374 AC_DEFINE_UNQUOTED([PHP_HTTP_EVENT_VERSION], ["$EVENT_VER"], [ ])
375 AC_MSG_RESULT([$EVENT_VER])
377 PHP_ADD_INCLUDE($EVENT_DIR/include)
378 PHP_ADD_LIBRARY_WITH_PATH(event, $EVENT_DIR/$PHP_LIBDIR, HTTP_SHARED_LIBADD)
379 AC_DEFINE([PHP_HTTP_HAVE_EVENT], [1], [Have libevent support for cURL])
386 HTTP_HAVE_PHP_EXT([raphf], [
387 AC_MSG_CHECKING([for php_raphf.h])
388 HTTP_EXT_RAPHF_INCDIR=
389 for i in `echo $INCLUDES | $SED -e's/-I//g'` $abs_srcdir ../raphf; do
391 if test -f $i/php_raphf.h; then
392 HTTP_EXT_RAPHF_INCDIR=$i
394 elif test -f $i/ext/raphf/php_raphf.h; then
395 HTTP_EXT_RAPHF_INCDIR=$i/ext/raphf
400 if test "x$HTTP_EXT_RAPHF_INCDIR" = "x"; then
401 AC_MSG_ERROR([not found])
403 AC_MSG_RESULT([$HTTP_EXT_RAPHF_INCDIR])
404 AC_DEFINE([PHP_HTTP_HAVE_PHP_RAPHF_H], [1], [Have ext/raphf support])
405 PHP_ADD_INCLUDE([$HTTP_EXT_RAPHF_INCDIR])
408 AC_MSG_ERROR([Please install pecl/raphf and activate extension=raphf.$SHLIB_DL_SUFFIX_NAME in your php.ini])
414 HTTP_HAVE_PHP_EXT([propro], [
415 AC_MSG_CHECKING([for php_propro.h])
416 HTTP_EXT_PROPRO_INCDIR=
417 for i in `echo $INCLUDES | $SED -e's/-I//g'` $abs_srcdir ../propro; do
419 if test -f $i/php_propro.h; then
420 HTTP_EXT_PROPRO_INCDIR=$i
422 elif test -f $i/ext/propro/php_propro.h; then
423 HTTP_EXT_PROPRO_INCDIR=$i/ext/propro
428 if test "x$HTTP_EXT_PROPRO_INCDIR" = "x"; then
429 AC_MSG_ERROR([not found])
431 AC_MSG_RESULT([$HTTP_EXT_PROPRO_INCDIR])
432 AC_DEFINE([PHP_HTTP_HAVE_PHP_PROPRO_H], [1], [Have ext/propro support])
433 PHP_ADD_INCLUDE([$HTTP_EXT_PROPRO_INCDIR])
436 AC_MSG_ERROR([Please install pecl/propro and activate extension=propro.$SHLIB_DL_SUFFIX_NAME in your php.ini])
439 PHP_ARG_WITH([http-shared-deps], [whether to depend on extensions which have been built shared],
440 [ --without-http-shared-deps HTTP: do not depend on extensions like hash
441 and iconv (when they are built shared)], $PHP_HTTP, $PHP_HTTP)
445 HTTP_HAVE_PHP_EXT([hash], [
446 AC_MSG_CHECKING([for php_hash.h])
447 HTTP_EXT_HASH_INCDIR=
448 for i in `echo $INCLUDES | $SED -e's/-I//g'` $abs_srcdir ../hash; do
450 if test -f $i/php_hash.h; then
451 HTTP_EXT_HASH_INCDIR=$i
453 elif test -f $i/ext/hash/php_hash.h; then
454 HTTP_EXT_HASH_INCDIR=$i/ext/hash
459 if test "x$HTTP_EXT_HASH_INCDIR" = "x"; then
460 AC_MSG_RESULT([not found])
462 AC_MSG_RESULT([$HTTP_EXT_HASH_INCDIR])
463 AC_DEFINE([PHP_HTTP_HAVE_PHP_HASH_H], [1], [Have ext/hash support])
464 PHP_ADD_INCLUDE([$HTTP_EXT_HASH_INCDIR])
471 HTTP_HAVE_PHP_EXT([json])
477 HTTP_HAVE_PHP_EXT([iconv])
486 php_http_client_curl.c \
487 php_http_client_request.c \
488 php_http_client_response.c \
491 php_http_encoding.c \
493 php_http_env_request.c \
494 php_http_env_response.c \
496 php_http_exception.c \
498 php_http_header_parser.c \
501 php_http_message_body.c \
503 php_http_message_parser.c \
505 php_http_negotiate.c \
509 php_http_querystring.c \
514 PHP_NEW_EXTENSION([http], $PHP_HTTP_SOURCES, $ext_shared)
516 dnl shared extension deps
517 HTTP_SHARED_DEP([hash])
518 HTTP_SHARED_DEP([iconv])
519 HTTP_SHARED_DEP([json])
522 PHP_ADD_EXTENSION_DEP([http], [raphf], true)
523 PHP_ADD_EXTENSION_DEP([http], [propo], true)
525 PHP_SUBST([HTTP_SHARED_LIBADD])
530 php_http_curl_client.h \
531 php_http_curl_client_datashare.h \
532 php_http_client_datashare.h \
533 php_http_client_factory.h \
535 php_http_client_interface.h \
536 php_http_curl_client_pool.h \
537 php_http_client_pool.h \
538 php_http_client_request.h \
539 php_http_client_response.h \
542 php_http_encoding.h \
544 php_http_env_request.h \
545 php_http_env_response.h \
547 php_http_exception.h \
550 php_http_header_parser.h \
553 php_http_message_body.h \
555 php_http_message_parser.h \
557 php_http_negotiate.h \
561 php_http_querystring.h \
566 PHP_INSTALL_HEADERS(ext/http, $PHP_HTTP_HEADERS)
568 AC_DEFINE([HAVE_HTTP], [1], [Have extended HTTP support])