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