1 dnl config.m4 for pecl/http
3 dnl vim: noet ts=1 sw=1
5 PHP_ARG_ENABLE([http], [whether to enable extended HTTP support],
6 [ --enable-http Enable extended HTTP support])
7 PHP_ARG_WITH([http-curl-requests], [whether to enable cURL HTTP requests],
8 [ --with-http-curl-requests[=CURLDIR]
9 With cURL HTTP request support])
10 PHP_ARG_WITH([http-magic-mime], [whether to enable response content type guessing],
11 [ --with-http-magic-mime[=MAGICDIR]
12 With magic mime response content type guessing])
13 PHP_ARG_WITH([http-zlib-compression], [whether to enable support for gzencoded/deflated message bodies],
14 [ --with-http-zlib-compression[=ZLIBDIR]
15 With zlib gzdecode and inflate support])
17 if test "$PHP_HTTP" != "no"; then
22 AC_CHECK_HEADERS([netdb.h])
27 AC_MSG_CHECKING([for zlib.h])
29 for i in "$PHP_HTTP_ZLIB_COMPRESSION" "$PHP_ZLIB_DIR" "$PHP_ZLIB" /user/local /usr /opt; do
30 if test -f "$i/include/zlib.h"; then
35 if test -z "$ZLIB_DIR"; then
36 AC_MSG_RESULT([not found])
37 AC_MSG_WARN([gzip support not enabled; zlib.h not found])
39 AC_MSG_RESULT([found in $ZLIB_DIR])
40 PHP_ADD_INCLUDE($ZLIB_DIR/include)
41 PHP_ADD_LIBRARY_WITH_PATH(z, $ZLIB_DIR/$PHP_LIBDIR, HTTP_SHARED_LIBADD)
42 AC_DEFINE([HTTP_HAVE_ZLIB], [1], [Have zlib support])
48 if test "$PHP_HTTP_CURL_REQUESTS" != "no"; then
50 AC_MSG_CHECKING([for curl/curl.h])
52 for i in "$PHP_HTTP_CURL_REQUESTS" /usr/local /usr /opt; do
53 if test -f "$i/include/curl/curl.h"; then
58 if test -z "$CURL_DIR"; then
59 AC_MSG_RESULT([not found])
60 AC_MSG_ERROR([could not find curl/curl.h])
62 AC_MSG_RESULT([found in $CURL_DIR])
65 AC_MSG_CHECKING([for curl-config])
67 for i in "$CURL_DIR/bin/curl-config" "$CURL_DIR/curl-config" `which curl-config`; do
73 if test -z "$CURL_CONFIG"; then
74 AC_MSG_RESULT([not found])
75 AC_MSG_ERROR([could not find curl-config])
77 AC_MSG_RESULT([found: $CURL_CONFIG])
80 CURL_LIBS=`$CURL_CONFIG --libs`
82 AC_MSG_CHECKING([for SSL support in libcurl])
83 CURL_SSL=`$CURL_CONFIG --features | $EGREP SSL`
84 if test "$CURL_SSL" = "SSL"; then
86 AC_DEFINE([HTTP_HAVE_SSL], [1], [ ])
88 AC_MSG_CHECKING([for SSL library used])
90 for i in $CURL_LIBS; do
91 if test "$i" = "-lssl"; then
92 CURL_SSL_FLAVOUR="openssl"
93 AC_MSG_RESULT([openssl])
94 AC_DEFINE([HTTP_HAVE_OPENSSL], [1], [ ])
95 AC_CHECK_HEADERS([openssl/crypto.h])
97 elif test "$i" = "-lgnutls"; then
98 CURL_SSL_FLAVOUR="gnutls"
99 AC_MSG_RESULT([gnutls])
100 AC_DEFINE([HTTP_HAVE_GNUTLS], [1], [ ])
101 AC_CHECK_HEADERS([gcrypt.h])
105 if test -z "$CURL_SSL_FLAVOUR"; then
106 AC_MSG_RESULT([unknown!])
107 AC_MSG_WARN([Could not determine the type of SSL library used!])
108 AC_MSG_WARN([Building will fail in ZTS mode!])
114 PHP_ADD_INCLUDE($CURL_DIR/include)
115 PHP_ADD_LIBRARY_WITH_PATH(curl, $CURL_DIR/$PHP_LIBDIR, HTTP_SHARED_LIBADD)
116 PHP_EVAL_LIBLINE($CURL_LIBS, HTTP_SHARED_LIBADD)
117 AC_DEFINE([HTTP_HAVE_CURL], [1], [Have cURL support])
119 PHP_CHECK_LIBRARY(curl, curl_multi_strerror,
120 [AC_DEFINE([HAVE_CURL_MULTI_STRERROR], [1], [ ])], [ ],
121 [$CURL_LIBS -L$CURL_DIR/$PHP_LIBDIR]
123 PHP_CHECK_LIBRARY(curl, curl_easy_strerror,
124 [AC_DEFINE([HAVE_CURL_EASY_STRERROR], [1], [ ])], [ ],
125 [$CURL_LIBS -L$CURL_DIR/$PHP_LIBDIR]
127 PHP_CHECK_LIBRARY(curl, curl_easy_reset,
128 [AC_DEFINE([HAVE_CURL_EASY_RESET], [1], [ ])], [ ],
129 [$CURL_LIBS -L$CURL_DIR/$PHP_LIBDIR]
136 if test "$PHP_HTTP_MAGIC_MIME" != "no"; then
138 AC_MSG_CHECKING([for magic.h])
140 for i in "$PHP_HTTP_MAGIC_MIME" /usr/local /usr /opt; do
141 if test -f "$i/include/magic.h"; then
146 if test -z "$MAGIC_DIR"; then
147 AC_MSG_RESULT([not found])
148 AC_MSG_ERROR([could not find magic.h])
150 AC_MSG_RESULT([found in $MAGIC_DIR])
153 PHP_ADD_INCLUDE($MAGIC_DIR/include)
154 PHP_ADD_LIBRARY_WITH_PATH(magic, $MAGIC_DIR/$PHP_LIBDIR, HTTP_SHARED_LIBADD)
155 AC_DEFINE([HTTP_HAVE_MAGIC], [1], [Have magic mime support])
162 if test -x "$PHP_EXECUTABLE"; then
163 if test "`$PHP_EXECUTABLE -m | $EGREP '^hash$'`" = "hash"; then
164 if test -d ../hash; then
165 PHP_ADD_INCLUDE([../hash])
167 old_CPPFLAGS=$CPPFLAGS
169 AC_CHECK_HEADER([php_hash.h],
171 AC_DEFINE([HTTP_HAVE_EXT_HASH], [1], [Have ext/hash support])
173 AC_CHECK_HEADER([hash/php_hash.h],
175 AC_DEFINE([HTTP_HAVE_HASH_EXT_HASH], [1], [Have ext/hash support])
177 AC_CHECK_HEADER([ext/hash/php_hash.h],
179 AC_DEFINE([HTTP_HAVE_EXT_HASH_EXT_HASH], [1], [Have ext/hash support])
184 CPPFLAGS=$old_CPPFLAGS;
186 elif test "$PHP_HASH" != "no" && test "x$PHP_HASH" != "x"; then
187 ifdef([PHP_ADD_EXTENSION_DEP], [
188 PHP_ADD_EXTENSION_DEP([http], [hash], 0)
189 AC_DEFINE([HTTP_HAVE_EXT_HASH_EXT_HASH], [1], [Have ext/hash support])
197 PHP_HTTP_SOURCES="missing.c http.c http_functions.c phpstr/phpstr.c \
198 http_util_object.c http_message_object.c http_request_object.c http_request_pool_api.c \
199 http_response_object.c http_exception_object.c http_requestpool_object.c \
200 http_api.c http_cache_api.c http_request_api.c http_date_api.c \
201 http_headers_api.c http_message_api.c http_send_api.c http_url_api.c \
202 http_info_api.c http_request_method_api.c http_encoding_api.c \
204 PHP_NEW_EXTENSION([http], $PHP_HTTP_SOURCES, $ext_shared)
205 PHP_ADD_BUILD_DIR($ext_builddir/phpstr, 1)
206 PHP_SUBST([HTTP_SHARED_LIBADD])
208 PHP_HTTP_HEADERS="php_http_std_defs.h php_http.h php_http_api.h php_http_cache_api.h \
209 php_http_date_api.h php_http_headers_api.h php_http_info_api.h php_http_message_api.h \
210 php_http_request_api.h php_http_request_method_api.h php_http_send_api.h php_http_url_api.h \
211 php_http_encoding_api.h phpstr/phpstr.h"
213 ifdef([PHP_INSTALL_HEADERS], [
214 PHP_INSTALL_HEADERS(ext/http, $PHP_HTTP_HEADERS)
216 PHP_SUBST([PHP_HTTP_HEADERS])
217 PHP_ADD_MAKEFILE_FRAGMENT
220 AC_DEFINE([HAVE_HTTP], [1], [Have extended HTTP support])