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-shared-deps], [whether to depend on extensions which have been built shared],
8 [ --with-http-shared-deps
9 HTTP: disable to not depend on extensions like hash,
10 iconv and session (when built shared)], $PHP_HTTP, $PHP_HTTP)
11 PHP_ARG_WITH([http-curl-requests], [whether to enable cURL HTTP request support],
12 [ --with-http-curl-requests[=LIBCURLDIR]
13 HTTP: with cURL request support], $PHP_HTTP, $PHP_HTTP)
14 PHP_ARG_WITH([http-zlib-compression], [whether to enable zlib encodings support],
15 [ --with-http-zlib-compression[=LIBZDIR]
16 HTTP: with zlib encodings support], $PHP_HTTP, $PHP_HTTP)
17 PHP_ARG_WITH([http-magic-mime], [whether to enable response content type guessing],
18 [ --with-http-magic-mime[=LIBMAGICDIR]
19 HTTP: with magic mime response content type guessing], "no", "no")
21 if test "$PHP_HTTP" != "no"; then
23 ifdef([AC_PROG_EGREP], [
26 AC_CHECK_PROG(EGREP, egrep, egrep)
28 ifdef([AC_PROG_SED], [
31 ifdef([LT_AC_PROG_SED], [
34 AC_CHECK_PROG(SED, sed, sed)
38 if test "$PHP_HTTP_SHARED_DEPS" != "no"; then
39 AC_DEFINE([HTTP_SHARED_DEPS], [1], [ ])
41 AC_DEFINE([HTTP_SHARED_DEPS], [0], [ ])
45 dnl HTTP_SHARED_DEP(name[, code-if-yes[, code-if-not]])
47 AC_DEFUN([HTTP_SHARED_DEP], [
49 haveext=$[HTTP_HAVE_EXT_]translit($1,a-z_-,A-Z__)
51 AC_MSG_CHECKING([whether to add a dependency on ext/$extname])
52 if test "$PHP_HTTP_SHARED_DEPS" = "no"; then
55 elif test "$haveext"; then
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 ishared=$[PHP_]translit($1,a-z_-,A-Z__)_SHARED
75 AC_MSG_CHECKING([for ext/$extname support])
76 if test -x "$PHP_EXECUTABLE"; then
77 if test "`$PHP_EXECUTABLE -m | $EGREP ^$extname\$`" = "$extname"; then
78 [HTTP_HAVE_EXT_]translit($1,a-z_-,A-Z__)=1
82 [HTTP_HAVE_EXT_]translit($1,a-z_-,A-Z__)=
86 elif test "$haveext" != "no" && test "x$haveext" != "x"; then
87 [HTTP_HAVE_EXT_]translit($1,a-z_-,A-Z__)=1
91 [HTTP_HAVE_EXT_]translit($1,a-z_-,A-Z__)=
100 AC_CHECK_HEADERS([netdb.h unistd.h])
101 PHP_CHECK_FUNC(gethostname, nsl)
102 PHP_CHECK_FUNC(getdomainname, nsl)
103 PHP_CHECK_FUNC(getservbyport, nsl)
104 PHP_CHECK_FUNC(getservbyname, nsl)
109 if test "$PHP_HTTP_ZLIB_COMPRESSION" != "no"; then
110 AC_MSG_CHECKING([for zlib.h])
112 for i in "$PHP_HTTP_ZLIB_COMPRESSION" "$PHP_ZLIB_DIR" "$PHP_ZLIB" /usr/local /usr /opt; do
113 if test -f "$i/include/zlib.h"; then
118 if test -z "$ZLIB_DIR"; 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([libz 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)
131 AC_DEFINE([HTTP_HAVE_ZLIB], [1], [Have zlib support])
139 if test "$PHP_HTTP_CURL_REQUESTS" != "no"; then
140 AC_MSG_CHECKING([for curl/curl.h])
142 for i in "$PHP_HTTP_CURL_REQUESTS" /usr/local /usr /opt; do
143 if test -f "$i/include/curl/curl.h"; then
148 if test -z "$CURL_DIR"; then
149 AC_MSG_RESULT([not found])
150 AC_MSG_ERROR([could not find curl/curl.h])
152 AC_MSG_RESULT([found in $CURL_DIR])
155 AC_MSG_CHECKING([for curl-config])
157 for i in "$CURL_DIR/bin/curl-config" "$CURL_DIR/curl-config" `which curl-config`; do
158 if test -x "$i"; then
163 if test -z "$CURL_CONFIG"; then
164 AC_MSG_RESULT([not found])
165 AC_MSG_ERROR([could not find curl-config])
167 AC_MSG_RESULT([found: $CURL_CONFIG])
170 dnl Debian stable has currently 7.13.2 (this is not a typo)
171 AC_MSG_CHECKING([for curl version >= 7.12.3])
172 CURL_VERSION=`$CURL_CONFIG --version | $SED -e 's/[[^0-9\.]]//g'`
173 AC_MSG_RESULT([$CURL_VERSION])
174 if test `echo $CURL_VERSION | $SED -e 's/[[^0-9]]/ /g' | $AWK '{print $1*10000 + $2*100 + $3}'` -lt 71203; then
175 AC_MSG_ERROR([libcurl version greater or equal to 7.12.3 required])
182 save_INCLUDES="$INCLUDES"
186 save_CFLAGS="$CFLAGS"
187 CFLAGS="`$CURL_CONFIG --cflags`"
188 save_LDFLAGS="$LDFLAGS"
189 LDFLAGS="`$CURL_CONFIG --libs` $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([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([HTTP_HAVE_OPENSSL], [1], [ ])
220 AC_MSG_CHECKING([for gnutls support in libcurl])
222 #include <curl/curl.h>
223 int main(int argc, char *argv[]) {
224 curl_version_info_data *data = curl_version_info(CURLVERSION_NOW);
225 if (data && data->ssl_version && *data->ssl_version) {
226 const char *ptr = data->ssl_version;
227 while(*ptr == ' ') ++ptr;
228 return strncasecmp(ptr, "GnuTLS", sizeof("GnuTLS")-1);
234 AC_CHECK_HEADER([gcrypt.h], [
235 AC_DEFINE([HTTP_HAVE_GNUTLS], [1], [ ])
246 INCLUDES="$save_INCLUDES"
248 CFLAGS="$save_CFLAGS"
249 LDFLAGS="$save_LDFLAGS"
251 dnl end compile tests
253 AC_MSG_CHECKING([for bundled SSL CA info])
255 for i in `$CURL_CONFIG --ca` "/etc/ssl/certs/ca-certificates.crt"; do
256 if test -f "$i"; then
261 if test -z "$CURL_CAINFO"; then
262 AC_MSG_RESULT([not found])
264 AC_MSG_RESULT([$CURL_CAINFO])
265 AC_DEFINE_UNQUOTED([HTTP_CURL_CAINFO], ["$CURL_CAINFO"], [path to bundled SSL CA info])
268 PHP_ADD_INCLUDE($CURL_DIR/include)
269 PHP_ADD_LIBRARY_WITH_PATH(curl, $CURL_DIR/$PHP_LIBDIR, HTTP_SHARED_LIBADD)
270 PHP_EVAL_LIBLINE(`$CURL_CONFIG --libs`, HTTP_SHARED_LIBADD)
271 AC_DEFINE([HTTP_HAVE_CURL], [1], [Have cURL support])
273 PHP_CHECK_LIBRARY(curl, curl_share_strerror,
274 [AC_DEFINE([HAVE_CURL_SHARE_STRERROR], [1], [ ])], [ ],
275 [$CURL_LIBS -L$CURL_DIR/$PHP_LIBDIR]
277 PHP_CHECK_LIBRARY(curl, curl_multi_strerror,
278 [AC_DEFINE([HAVE_CURL_MULTI_STRERROR], [1], [ ])], [ ],
279 [$CURL_LIBS -L$CURL_DIR/$PHP_LIBDIR]
281 PHP_CHECK_LIBRARY(curl, curl_easy_strerror,
282 [AC_DEFINE([HAVE_CURL_EASY_STRERROR], [1], [ ])], [ ],
283 [$CURL_LIBS -L$CURL_DIR/$PHP_LIBDIR]
285 PHP_CHECK_LIBRARY(curl, curl_easy_reset,
286 [AC_DEFINE([HAVE_CURL_EASY_RESET], [1], [ ])], [ ],
287 [$CURL_LIBS -L$CURL_DIR/$PHP_LIBDIR]
289 PHP_CHECK_LIBRARY(curl, curl_formget,
290 [AC_DEFINE([HAVE_CURL_FORMGET], [1], [ ])], [ ],
291 [$CURL_LIBS -L$CURL_DIR/$PHP_LIBDIR]
293 PHP_CHECK_LIBRARY(curl, curl_multi_setopt,
294 [AC_DEFINE([HAVE_CURL_MULTI_SETOPT], [1], [ ])], [ ],
295 [$CURL_LIBS -L$CURL_DIR/$PHP_LIBDIR]
297 PHP_CHECK_LIBRARY(curl, curl_multi_timeout,
298 [AC_DEFINE([HAVE_CURL_MULTI_TIMEOUT], [1], [ ])], [ ],
299 [$CURL_LIBS -L$CURL_DIR/$PHP_LIBDIR]
307 if test "$PHP_HTTP_MAGIC_MIME" != "no"; then
308 AC_MSG_CHECKING([for magic.h])
310 for i in "$PHP_HTTP_MAGIC_MIME" /usr/local /usr /opt; do
311 if test -f "$i/include/magic.h"; then
316 if test -z "$MAGIC_DIR"; then
317 AC_MSG_RESULT([not found])
318 AC_MSG_ERROR([could not find magic.h])
320 AC_MSG_RESULT([found in $MAGIC_DIR])
323 PHP_ADD_INCLUDE($MAGIC_DIR/include)
324 PHP_ADD_LIBRARY_WITH_PATH(magic, $MAGIC_DIR/$PHP_LIBDIR, HTTP_SHARED_LIBADD)
325 AC_DEFINE([HTTP_HAVE_MAGIC], [1], [Have magic mime support])
331 HTTP_HAVE_PHP_EXT([hash], [
332 AC_MSG_CHECKING([for php_hash.h])
333 HTTP_EXT_HASH_INCDIR=
334 for i in `echo $INCLUDES | $SED -e's/-I//g'` $abs_srcdir ../hash; do
336 if test -f $i/php_hash.h; then
337 HTTP_EXT_HASH_INCDIR=$i
339 elif test -f $i/ext/hash/php_hash.h; then
340 HTTP_EXT_HASH_INCDIR=$i/ext/hash
345 if test -z "$HTTP_EXT_HASH_INCDIR"; then
346 AC_MSG_RESULT([not found])
348 AC_MSG_RESULT([$HTTP_EXT_HASH_INCDIR])
349 AC_DEFINE([HTTP_HAVE_PHP_HASH_H], [1], [Have ext/hash support])
350 PHP_ADD_INCLUDE([$HTTP_EXT_HASH_INCDIR])
357 HTTP_HAVE_PHP_EXT([iconv])
362 HTTP_HAVE_PHP_EXT([session])
367 PHP_HTTP_SOURCES="missing.c http.c http_functions.c phpstr/phpstr.c \
368 http_util_object.c http_message_object.c http_request_object.c http_request_pool_api.c \
369 http_response_object.c http_exception_object.c http_requestpool_object.c \
370 http_api.c http_cache_api.c http_request_api.c http_request_info.c http_date_api.c \
371 http_headers_api.c http_message_api.c http_send_api.c http_url_api.c \
372 http_info_api.c http_request_method_api.c http_encoding_api.c \
373 http_filter_api.c http_request_body_api.c http_querystring_object.c \
374 http_deflatestream_object.c http_inflatestream_object.c http_cookie_api.c \
375 http_querystring_api.c http_request_datashare_api.c http_requestdatashare_object.c \
376 http_persistent_handle_api.c"
378 PHP_NEW_EXTENSION([http], $PHP_HTTP_SOURCES, $ext_shared)
380 dnl shared extension deps
381 HTTP_SHARED_DEP([hash])
382 HTTP_SHARED_DEP([iconv])
383 HTTP_SHARED_DEP([session])
385 PHP_ADD_BUILD_DIR($ext_builddir/phpstr, 1)
386 PHP_SUBST([HTTP_SHARED_LIBADD])
388 PHP_HTTP_HEADERS="php_http_std_defs.h php_http.h php_http_api.h php_http_cache_api.h \
389 php_http_date_api.h php_http_headers_api.h php_http_info_api.h php_http_message_api.h \
390 php_http_request_api.h php_http_request_method_api.h php_http_send_api.h php_http_url_api.h \
391 php_http_encoding_api.h phpstr/phpstr.h missing.h php_http_request_body_api.h \
392 php_http_exception_object.h php_http_message_object.h php_http_request_object.h \
393 php_http_requestpool_object.h php_http_response_object.h php_http_util_object.h \
394 php_http_querystring_object.h php_http_deflatestream_object.h php_http_inflatestream_object.h \
395 php_http_cookie_api.h php_http_querystring_api.h php_http_request_datashare_api.h php_http_requestdatashare_object.h \
396 php_http_persistent_handle_api.h"
397 ifdef([PHP_INSTALL_HEADERS], [
398 PHP_INSTALL_HEADERS(ext/http, $PHP_HTTP_HEADERS)
400 PHP_SUBST([PHP_HTTP_HEADERS])
401 PHP_ADD_MAKEFILE_FRAGMENT
404 AC_DEFINE([HAVE_HTTP], [1], [Have extended HTTP support])