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