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_ENABLE([http-persistent-handles], [whether to enable per-process persistent cURL handles],
8 [ --enable-http-persistent-handles
9 HTTP: enable per-process persistent cURL handles], "no", "no")
10 PHP_ARG_WITH([http-shared-deps], [whether to depend on extensions which have been built shared],
11 [ --with-http-shared-deps
12 HTTP: disable to not depend on extensions like hash,
13 iconv and session (when built shared)], $PHP_HTTP, $PHP_HTTP)
14 PHP_ARG_WITH([http-curl-requests], [whether to enable cURL HTTP request support],
15 [ --with-http-curl-requests[=LIBCURLDIR]
16 HTTP: with cURL request support], $PHP_HTTP, $PHP_HTTP)
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")
24 if test "$PHP_HTTP" != "no"; then
26 ifdef([AC_PROG_EGREP], [
29 AC_CHECK_PROG(EGREP, egrep, egrep)
31 ifdef([AC_PROG_SED], [
34 ifdef([LT_AC_PROG_SED], [
37 AC_CHECK_PROG(SED, sed, sed)
41 if test "$PHP_HTTP_SHARED_DEPS" != "no"; then
42 AC_DEFINE([HTTP_SHARED_DEPS], [1], [ ])
44 AC_DEFINE([HTTP_SHARED_DEPS], [0], [ ])
48 dnl HTTP_SHARED_DEP(name[, code-if-yes[, code-if-not]])
50 AC_DEFUN([HTTP_SHARED_DEP], [
52 haveext=$[HTTP_HAVE_EXT_]translit($1,a-z_-,A-Z__)
54 AC_MSG_CHECKING([whether to add a dependency on ext/$extname])
55 if test "$PHP_HTTP_SHARED_DEPS" = "no"; then
58 elif test "$haveext"; then
60 ifdef([PHP_ADD_EXTENSION_DEP], [
61 PHP_ADD_EXTENSION_DEP([http], $1, true)
71 dnl HTTP_HAVE_PHP_EXT(name[, code-if-yes[, code-if-not]])
73 AC_DEFUN([HTTP_HAVE_PHP_EXT], [
75 haveext=$[PHP_]translit($1,a-z_-,A-Z__)
76 ishared=$[PHP_]translit($1,a-z_-,A-Z__)_SHARED
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
85 [HTTP_HAVE_EXT_]translit($1,a-z_-,A-Z__)=
89 elif test "$haveext" != "no" && test "x$haveext" != "x"; then
90 [HTTP_HAVE_EXT_]translit($1,a-z_-,A-Z__)=1
94 [HTTP_HAVE_EXT_]translit($1,a-z_-,A-Z__)=
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)
112 if test "$PHP_HTTP_ZLIB_COMPRESSION" != "no"; then
113 AC_MSG_CHECKING([for zlib.h])
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
121 if test -z "$ZLIB_DIR"; then
122 AC_MSG_RESULT([not found])
123 AC_MSG_ERROR([could not find zlib.h])
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])
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])
142 if test "$PHP_HTTP_CURL_REQUESTS" != "no"; then
143 AC_MSG_CHECKING([for curl/curl.h])
145 for i in "$PHP_HTTP_CURL_REQUESTS" /usr/local /usr /opt; do
146 if test -f "$i/include/curl/curl.h"; then
151 if test -z "$CURL_DIR"; then
152 AC_MSG_RESULT([not found])
153 AC_MSG_ERROR([could not find curl/curl.h])
155 AC_MSG_RESULT([found in $CURL_DIR])
158 AC_MSG_CHECKING([for 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
166 if test -z "$CURL_CONFIG"; then
167 AC_MSG_RESULT([not found])
168 AC_MSG_ERROR([could not find curl-config])
170 AC_MSG_RESULT([found: $CURL_CONFIG])
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])
181 CURL_LIBS=`$CURL_CONFIG --libs`
183 AC_MSG_CHECKING([for SSL support in libcurl])
184 CURL_SSL=`$CURL_CONFIG --feature | $EGREP SSL`
185 if test "$CURL_SSL" = "SSL"; then
187 AC_DEFINE([HTTP_HAVE_SSL], [1], [ ])
189 AC_MSG_CHECKING([for SSL library used])
191 for i in $CURL_LIBS; do
194 CURL_SSL_FLAVOUR="openssl"
195 AC_MSG_RESULT([openssl])
196 AC_DEFINE([HTTP_HAVE_OPENSSL], [1], [ ])
197 AC_CHECK_HEADERS([openssl/crypto.h])
201 CURL_SSL_FLAVOUR="gnutls"
202 AC_MSG_RESULT([gnutls])
203 AC_DEFINE([HTTP_HAVE_GNUTLS], [1], [ ])
204 AC_CHECK_HEADERS([gcrypt.h])
209 if test -z "$CURL_SSL_FLAVOUR"; then
210 AC_MSG_RESULT([unknown!])
211 AC_MSG_WARN([Could not determine the type of SSL library used!])
212 AC_MSG_WARN([Building will fail in ZTS mode!])
218 AC_MSG_CHECKING([for bundled SSL CA info])
220 for i in `$CURL_CONFIG --ca` "/etc/ssl/certs/ca-certificates.crt"; do
221 if test -f "$i"; then
226 if test -z "$CURL_CAINFO"; then
227 AC_MSG_RESULT([not found])
229 AC_MSG_RESULT([$CURL_CAINFO])
230 AC_DEFINE_UNQUOTED([HTTP_CURL_CAINFO], ["$CURL_CAINFO"], [path to bundled SSL CA info])
233 PHP_ADD_INCLUDE($CURL_DIR/include)
234 PHP_ADD_LIBRARY_WITH_PATH(curl, $CURL_DIR/$PHP_LIBDIR, HTTP_SHARED_LIBADD)
235 PHP_EVAL_LIBLINE($CURL_LIBS, HTTP_SHARED_LIBADD)
236 AC_DEFINE([HTTP_HAVE_CURL], [1], [Have cURL support])
238 PHP_CHECK_LIBRARY(curl, curl_share_strerror,
239 [AC_DEFINE([HAVE_CURL_SHARE_STRERROR], [1], [ ])], [ ],
240 [$CURL_LIBS -L$CURL_DIR/$PHP_LIBDIR]
242 PHP_CHECK_LIBRARY(curl, curl_multi_strerror,
243 [AC_DEFINE([HAVE_CURL_MULTI_STRERROR], [1], [ ])], [ ],
244 [$CURL_LIBS -L$CURL_DIR/$PHP_LIBDIR]
246 PHP_CHECK_LIBRARY(curl, curl_easy_strerror,
247 [AC_DEFINE([HAVE_CURL_EASY_STRERROR], [1], [ ])], [ ],
248 [$CURL_LIBS -L$CURL_DIR/$PHP_LIBDIR]
250 PHP_CHECK_LIBRARY(curl, curl_easy_reset,
251 [AC_DEFINE([HAVE_CURL_EASY_RESET], [1], [ ])], [ ],
252 [$CURL_LIBS -L$CURL_DIR/$PHP_LIBDIR]
254 dnl Debian suddenly (>=7.14.1-2) hides all symbols not starting with "curl"
255 PHP_CHECK_LIBRARY(curl, Curl_getFormData,
256 [AC_DEFINE([HAVE_CURL_GETFORMDATA], [1], [ ])], [ ],
257 [$CURL_LIBS -L$CURL_DIR/$PHP_LIBDIR]
259 dnl New API function which obsoletes use of Curl_getFormData (>=7.15.5)
260 PHP_CHECK_LIBRARY(curl, curl_formget,
261 [AC_DEFINE([HAVE_CURL_FORMGET], [1], [ ])], [ ],
262 [$CURL_LIBS -L$CURL_DIR/$PHP_LIBDIR]
264 PHP_CHECK_LIBRARY(curl, curl_multi_setopt,
265 [AC_DEFINE([HAVE_CURL_MULTI_SETOPT], [1], [ ])], [ ],
266 [$CURL_LIBS -L$CURL_DIR/$PHP_LIBDIR]
268 PHP_CHECK_LIBRARY(curl, curl_multi_timeout,
269 [AC_DEFINE([HAVE_CURL_MULTI_TIMEOUT], [1], [ ])], [ ],
270 [$CURL_LIBS -L$CURL_DIR/$PHP_LIBDIR]
273 dnl persistent cURL handles
274 AC_MSG_CHECKING([whether to enable per-process persistent cURL handles])
275 if test "$PHP_HTTP_PERSISTENT_HANDLES" != "no"; then
276 AC_DEFINE([HTTP_HAVE_PERSISTENT_HANDLES], [1], [Have per-process persistent cURL handles])
286 if test "$PHP_HTTP_MAGIC_MIME" != "no"; then
287 AC_MSG_CHECKING([for magic.h])
289 for i in "$PHP_HTTP_MAGIC_MIME" /usr/local /usr /opt; do
290 if test -f "$i/include/magic.h"; then
295 if test -z "$MAGIC_DIR"; then
296 AC_MSG_RESULT([not found])
297 AC_MSG_ERROR([could not find magic.h])
299 AC_MSG_RESULT([found in $MAGIC_DIR])
302 PHP_ADD_INCLUDE($MAGIC_DIR/include)
303 PHP_ADD_LIBRARY_WITH_PATH(magic, $MAGIC_DIR/$PHP_LIBDIR, HTTP_SHARED_LIBADD)
304 AC_DEFINE([HTTP_HAVE_MAGIC], [1], [Have magic mime support])
310 HTTP_HAVE_PHP_EXT([hash], [
311 AC_MSG_CHECKING([for php_hash.h])
312 HTTP_EXT_HASH_INCDIR=
313 for i in `echo $INCLUDES | $SED -e's/-I//g'` $abs_srcdir ../hash; do
315 if test -f $i/php_hash.h; then
316 HTTP_EXT_HASH_INCDIR=$i
318 elif test -f $i/ext/hash/php_hash.h; then
319 HTTP_EXT_HASH_INCDIR=$i/ext/hash
324 if test -z "$HTTP_EXT_HASH_INCDIR"; then
325 AC_MSG_RESULT([not found])
327 AC_MSG_RESULT([$HTTP_EXT_HASH_INCDIR])
328 AC_DEFINE([HTTP_HAVE_PHP_HASH_H], [1], [Have ext/hash support])
329 PHP_ADD_INCLUDE([$HTTP_EXT_HASH_INCDIR])
336 HTTP_HAVE_PHP_EXT([iconv])
341 HTTP_HAVE_PHP_EXT([session])
346 PHP_HTTP_SOURCES="missing.c http.c http_functions.c phpstr/phpstr.c \
347 http_util_object.c http_message_object.c http_request_object.c http_request_pool_api.c \
348 http_response_object.c http_exception_object.c http_requestpool_object.c \
349 http_api.c http_cache_api.c http_request_api.c http_request_info.c http_date_api.c \
350 http_headers_api.c http_message_api.c http_send_api.c http_url_api.c \
351 http_info_api.c http_request_method_api.c http_encoding_api.c \
352 http_filter_api.c http_request_body_api.c http_querystring_object.c \
353 http_deflatestream_object.c http_inflatestream_object.c http_cookie_api.c \
354 http_querystring_api.c http_request_datashare_api.c http_requestdatashare_object.c \
355 http_persistent_handle_api.c"
357 PHP_NEW_EXTENSION([http], $PHP_HTTP_SOURCES, $ext_shared)
359 dnl shared extension deps
360 HTTP_SHARED_DEP([hash])
361 HTTP_SHARED_DEP([iconv])
362 HTTP_SHARED_DEP([session])
364 PHP_ADD_BUILD_DIR($ext_builddir/phpstr, 1)
365 PHP_SUBST([HTTP_SHARED_LIBADD])
367 PHP_HTTP_HEADERS="php_http_std_defs.h php_http.h php_http_api.h php_http_cache_api.h \
368 php_http_date_api.h php_http_headers_api.h php_http_info_api.h php_http_message_api.h \
369 php_http_request_api.h php_http_request_method_api.h php_http_send_api.h php_http_url_api.h \
370 php_http_encoding_api.h phpstr/phpstr.h missing.h php_http_request_body_api.h \
371 php_http_exception_object.h php_http_message_object.h php_http_request_object.h \
372 php_http_requestpool_object.h php_http_response_object.h php_http_util_object.h \
373 php_http_querystring_object.h php_http_deflatestream_object.h php_http_inflatestream_object.h \
374 php_http_cookie_api.h php_http_querystring_api.h php_http_request_datashare_api.h php_http_requestdatashare_object.h \
375 php_http_persistent_handle_api.h"
376 ifdef([PHP_INSTALL_HEADERS], [
377 PHP_INSTALL_HEADERS(ext/http, $PHP_HTTP_HEADERS)
379 PHP_SUBST([PHP_HTTP_HEADERS])
380 PHP_ADD_MAKEFILE_FRAGMENT
383 AC_DEFINE([HAVE_HTTP], [1], [Have extended HTTP support])