- highly experimental stream wrapper
[m6w6/ext-http] / config.m4
1 dnl config.m4 for pecl/http
2 dnl $Id$
3 dnl vim: noet ts=1 sw=1
4
5 PHP_ARG_ENABLE([http], [whether to enable extended HTTP support],
6 [ --enable-http Enable extended HTTP support])
7 PHP_ARG_ENABLE([http-stream-wrapper], [whether to enable experimental stream wrapper],
8 [ --enable-http-stream-wrapper
9 Enable experimental stream wrapper support], no, no)
10 PHP_ARG_WITH([http-curl-requests], [whether to enable cURL HTTP requests],
11 [ --with-http-curl-requests[=CURLDIR]
12 With cURL HTTP request support])
13 PHP_ARG_WITH([http-magic-mime], [whether to enable response content type guessing],
14 [ --with-http-magic-mime[=MAGICDIR]
15 With magic mime response content type guessing])
16 PHP_ARG_WITH([http-zlib-compression], [whether to enable support for gzencoded/deflated message bodies],
17 [ --with-http-zlib-compression[=ZLIBDIR]
18 With zlib gzdecode and inflate support])
19
20 if test "$PHP_HTTP" != "no"; then
21
22 ifdef([AC_PROG_EGREP], [
23 AC_PROG_EGREP
24 ], [
25 AC_CHECK_PROG(EGREP, egrep, egrep)
26 ])
27 ifdef([AC_PROG_SED], [
28 AC_PROG_SED
29 ], [
30 ifdef([LT_AC_PROG_SED], [
31 LT_AC_PROG_SED
32 ], [
33 AC_CHECK_PROG(SED, sed, sed)
34 ])
35 ])
36
37 dnl -------
38 dnl NETDB.H
39 dnl -------
40 AC_CHECK_HEADERS([netdb.h])
41
42 dnl ----
43 dnl ZLIB
44 dnl ----
45 AC_MSG_CHECKING([for zlib.h])
46 ZLIB_DIR=
47 for i in "$PHP_HTTP_ZLIB_COMPRESSION" "$PHP_ZLIB_DIR" "$PHP_ZLIB" /user/local /usr /opt; do
48 if test -f "$i/include/zlib.h"; then
49 ZLIB_DIR=$i
50 break;
51 fi
52 done
53 if test -z "$ZLIB_DIR"; then
54 AC_MSG_RESULT([not found])
55 AC_MSG_WARN([gzip support not enabled; zlib.h not found])
56 else
57 AC_MSG_RESULT([found in $ZLIB_DIR])
58 PHP_ADD_INCLUDE($ZLIB_DIR/include)
59 PHP_ADD_LIBRARY_WITH_PATH(z, $ZLIB_DIR/$PHP_LIBDIR, HTTP_SHARED_LIBADD)
60 AC_DEFINE([HTTP_HAVE_ZLIB], [1], [Have zlib support])
61 fi
62
63 dnl ----
64 dnl CURL
65 dnl ----
66 if test "$PHP_HTTP_CURL_REQUESTS" != "no"; then
67
68 AC_MSG_CHECKING([for curl/curl.h])
69 CURL_DIR=
70 for i in "$PHP_HTTP_CURL_REQUESTS" /usr/local /usr /opt; do
71 if test -f "$i/include/curl/curl.h"; then
72 CURL_DIR=$i
73 break
74 fi
75 done
76 if test -z "$CURL_DIR"; then
77 AC_MSG_RESULT([not found])
78 AC_MSG_ERROR([could not find curl/curl.h])
79 else
80 AC_MSG_RESULT([found in $CURL_DIR])
81 fi
82
83 AC_MSG_CHECKING([for curl-config])
84 CURL_CONFIG=
85 for i in "$CURL_DIR/bin/curl-config" "$CURL_DIR/curl-config" `which curl-config`; do
86 if test -x "$i"; then
87 CURL_CONFIG=$i
88 break
89 fi
90 done
91 if test -z "$CURL_CONFIG"; then
92 AC_MSG_RESULT([not found])
93 AC_MSG_ERROR([could not find curl-config])
94 else
95 AC_MSG_RESULT([found: $CURL_CONFIG])
96 fi
97
98 dnl Debian stable has currently 7.13.2 (this is not a typo)
99 AC_MSG_CHECKING([for curl version >= 7.12.3])
100 CURL_VERSION=`$CURL_CONFIG --version | $SED -e 's/[[^0-9\.]]//g'`
101 AC_MSG_RESULT([$CURL_VERSION])
102 if test `echo $CURL_VERSION | $AWK '{print $1*10000 + $2*100 + $3}'` -lt 71203; then
103 AC_MSG_ERROR([libcurl version greater or equal to 7.12.3 required])
104 fi
105
106 CURL_LIBS=`$CURL_CONFIG --libs`
107
108 AC_MSG_CHECKING([for SSL support in libcurl])
109 CURL_SSL=`$CURL_CONFIG --features | $EGREP SSL`
110 if test "$CURL_SSL" = "SSL"; then
111 AC_MSG_RESULT([yes])
112 AC_DEFINE([HTTP_HAVE_SSL], [1], [ ])
113
114 AC_MSG_CHECKING([for SSL library used])
115 CURL_SSL_FLAVOUR=
116 for i in $CURL_LIBS; do
117 if test "$i" = "-lssl"; then
118 CURL_SSL_FLAVOUR="openssl"
119 AC_MSG_RESULT([openssl])
120 AC_DEFINE([HTTP_HAVE_OPENSSL], [1], [ ])
121 AC_CHECK_HEADERS([openssl/crypto.h])
122 break
123 elif test "$i" = "-lgnutls"; then
124 CURL_SSL_FLAVOUR="gnutls"
125 AC_MSG_RESULT([gnutls])
126 AC_DEFINE([HTTP_HAVE_GNUTLS], [1], [ ])
127 AC_CHECK_HEADERS([gcrypt.h])
128 break
129 fi
130 done
131 if test -z "$CURL_SSL_FLAVOUR"; then
132 AC_MSG_RESULT([unknown!])
133 AC_MSG_WARN([Could not determine the type of SSL library used!])
134 AC_MSG_WARN([Building will fail in ZTS mode!])
135 fi
136 else
137 AC_MSG_RESULT([no])
138 fi
139
140 PHP_ADD_INCLUDE($CURL_DIR/include)
141 PHP_ADD_LIBRARY_WITH_PATH(curl, $CURL_DIR/$PHP_LIBDIR, HTTP_SHARED_LIBADD)
142 PHP_EVAL_LIBLINE($CURL_LIBS, HTTP_SHARED_LIBADD)
143 AC_DEFINE([HTTP_HAVE_CURL], [1], [Have cURL support])
144
145 PHP_CHECK_LIBRARY(curl, curl_multi_strerror,
146 [AC_DEFINE([HAVE_CURL_MULTI_STRERROR], [1], [ ])], [ ],
147 [$CURL_LIBS -L$CURL_DIR/$PHP_LIBDIR]
148 )
149 PHP_CHECK_LIBRARY(curl, curl_easy_strerror,
150 [AC_DEFINE([HAVE_CURL_EASY_STRERROR], [1], [ ])], [ ],
151 [$CURL_LIBS -L$CURL_DIR/$PHP_LIBDIR]
152 )
153 PHP_CHECK_LIBRARY(curl, curl_easy_reset,
154 [AC_DEFINE([HAVE_CURL_EASY_RESET], [1], [ ])], [ ],
155 [$CURL_LIBS -L$CURL_DIR/$PHP_LIBDIR]
156 )
157 fi
158
159 dnl ----
160 dnl MAGIC
161 dnl ----
162 if test "$PHP_HTTP_MAGIC_MIME" != "no"; then
163
164 AC_MSG_CHECKING([for magic.h])
165 MAGIC_DIR=
166 for i in "$PHP_HTTP_MAGIC_MIME" /usr/local /usr /opt; do
167 if test -f "$i/include/magic.h"; then
168 MAGIC_DIR=$i
169 break
170 fi
171 done
172 if test -z "$MAGIC_DIR"; then
173 AC_MSG_RESULT([not found])
174 AC_MSG_ERROR([could not find magic.h])
175 else
176 AC_MSG_RESULT([found in $MAGIC_DIR])
177 fi
178
179 PHP_ADD_INCLUDE($MAGIC_DIR/include)
180 PHP_ADD_LIBRARY_WITH_PATH(magic, $MAGIC_DIR/$PHP_LIBDIR, HTTP_SHARED_LIBADD)
181 AC_DEFINE([HTTP_HAVE_MAGIC], [1], [Have magic mime support])
182 fi
183
184 dnl ----
185 dnl HASH
186 dnl ----
187
188 AC_MSG_CHECKING(for ext/hash support)
189 if test -x "$PHP_EXECUTABLE"; then
190 if test "`$PHP_EXECUTABLE -m | $EGREP '^hash$'`" = "hash"; then
191 if test -d ../hash; then
192 PHP_ADD_INCLUDE([../hash])
193 fi
194 old_CPPFLAGS=$CPPFLAGS
195 CPPFLAGS=$INCLUDES
196 AC_MSG_RESULT([looking for php_hash.h])
197 AC_CHECK_HEADER([ext/hash/php_hash.h], [
198 AC_DEFINE([HTTP_HAVE_EXT_HASH_EXT_HASH], [1], [Have ext/hash support])
199 ], [
200 AC_CHECK_HEADER([hash/php_hash.h], [
201 AC_DEFINE([HTTP_HAVE_HASH_EXT_HASH], [1], [Have ext/hash support])
202 ], [
203 AC_CHECK_HEADER([php_hash.h], [
204 AC_DEFINE([HTTP_HAVE_EXT_HASH], [1], [Have ext/hash support])
205 ])
206 ])
207 ])
208 CPPFLAGS=$old_CPPFLAGS;
209 else
210 AC_MSG_RESULT(disabled)
211 fi
212 elif test "$PHP_HASH" != "no" && test "x$PHP_HASH" != "x"; then
213 AC_MSG_RESULT(enabled)
214 ifdef([PHP_ADD_EXTENSION_DEP], [
215 PHP_ADD_EXTENSION_DEP([http], [hash], 0)
216 AC_DEFINE([HTTP_HAVE_EXT_HASH_EXT_HASH], [1], [Have ext/hash support])
217 ])
218 else
219 AC_MSG_RESULT(disabled)
220 fi
221
222 dnl ----
223 dnl DONE
224 dnl ----
225 PHP_HTTP_SOURCES="missing.c http.c http_functions.c phpstr/phpstr.c \
226 http_util_object.c http_message_object.c http_request_object.c http_request_pool_api.c \
227 http_response_object.c http_exception_object.c http_requestpool_object.c \
228 http_api.c http_cache_api.c http_request_api.c http_date_api.c \
229 http_headers_api.c http_message_api.c http_send_api.c http_url_api.c \
230 http_info_api.c http_request_method_api.c http_encoding_api.c \
231 http_filter_api.c http_request_body_api.c http_wrapper_api.h"
232 PHP_NEW_EXTENSION([http], $PHP_HTTP_SOURCES, $ext_shared)
233 PHP_ADD_BUILD_DIR($ext_builddir/phpstr, 1)
234 PHP_SUBST([HTTP_SHARED_LIBADD])
235
236 PHP_HTTP_HEADERS="php_http_std_defs.h php_http.h php_http_api.h php_http_cache_api.h \
237 php_http_date_api.h php_http_headers_api.h php_http_info_api.h php_http_message_api.h \
238 php_http_request_api.h php_http_request_method_api.h php_http_send_api.h php_http_url_api.h \
239 php_http_encoding_api.h phpstr/phpstr.h missing.h php_http_request_body_api.h \
240 php_http_exception_object.h php_http_message_object.h php_http_request_object.h \
241 php_http_requestpool_object.h php_http_response_object.h php_http_util_object.h \
242 php_http_wrapper_api.h"
243 ifdef([PHP_INSTALL_HEADERS], [
244 PHP_INSTALL_HEADERS(ext/http, $PHP_HTTP_HEADERS)
245 ], [
246 PHP_SUBST([PHP_HTTP_HEADERS])
247 PHP_ADD_MAKEFILE_FRAGMENT
248 ])
249
250 AC_DEFINE([HAVE_HTTP], [1], [Have extended HTTP support])
251
252 if test "$PHP_HTTP_STREAM_WRAPPER" = "yes"; then
253 AC_DEFINE([HTTP_HAVE_WRAPPER], [1], [Have experimental HTTP stream wrapper])
254 fi
255 fi