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