- release 1.4.0RC1
[m6w6/ext-http] / config9.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 request support],
8 [ --with-http-curl-requests[=LIBCURLDIR]
9 HTTP: with cURL request support], $PHP_HTTP, $PHP_HTTP)
10 PHP_ARG_WITH([http-zlib-compression], [whether to enable zlib encodings support],
11 [ --with-http-zlib-compression[=LIBZDIR]
12 HTTP: with zlib encodings support], $PHP_HTTP, $PHP_HTTP)
13 PHP_ARG_WITH([http-magic-mime], [whether to enable response content type guessing],
14 [ --with-http-magic-mime[=LIBMAGICDIR]
15 HTTP: with magic mime response content type guessing], "no", "no")
16 PHP_ARG_WITH([http-shared-deps], [whether to depend on extensions which have been built shared],
17 [ --with-http-shared-deps HTTP: disable to not depend on extensions like hash,
18 iconv and session (when built shared)], $PHP_HTTP, $PHP_HTTP)
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 if test "$PHP_HTTP_SHARED_DEPS" != "no"; then
38 AC_DEFINE([HTTP_SHARED_DEPS], [1], [ ])
39 else
40 AC_DEFINE([HTTP_SHARED_DEPS], [0], [ ])
41 fi
42
43 dnl
44 dnl HTTP_SHARED_DEP(name[, code-if-yes[, code-if-not]])
45 dnl
46 AC_DEFUN([HTTP_SHARED_DEP], [
47 extname=$1
48 haveext=$[HTTP_HAVE_EXT_]translit($1,a-z_-,A-Z__)
49
50 AC_MSG_CHECKING([whether to add a dependency on ext/$extname])
51 if test "$PHP_HTTP_SHARED_DEPS" = "no"; then
52 AC_MSG_RESULT([no])
53 $3
54 elif test "$haveext"; then
55 AC_MSG_RESULT([yes])
56 ifdef([PHP_ADD_EXTENSION_DEP], [
57 PHP_ADD_EXTENSION_DEP([http], $1, true)
58 ])
59 $2
60 else
61 AC_MSG_RESULT([no])
62 $3
63 fi
64 ])
65
66 dnl
67 dnl HTTP_HAVE_PHP_EXT(name[, code-if-yes[, code-if-not]])
68 dnl
69 AC_DEFUN([HTTP_HAVE_PHP_EXT], [
70 extname=$1
71 haveext=$[PHP_]translit($1,a-z_-,A-Z__)
72 ishared=$[PHP_]translit($1,a-z_-,A-Z__)_SHARED
73
74 AC_MSG_CHECKING([for ext/$extname support])
75 if test -x "$PHP_EXECUTABLE"; then
76 if test "`$PHP_EXECUTABLE -m | $EGREP ^$extname\$`" = "$extname"; then
77 [HTTP_HAVE_EXT_]translit($1,a-z_-,A-Z__)=1
78 AC_MSG_RESULT([yes])
79 $2
80 else
81 [HTTP_HAVE_EXT_]translit($1,a-z_-,A-Z__)=
82 AC_MSG_RESULT([no])
83 $3
84 fi
85 elif test "$haveext" != "no" && test "x$haveext" != "x"; then
86 [HTTP_HAVE_EXT_]translit($1,a-z_-,A-Z__)=1
87 AC_MSG_RESULT([yes])
88 $2
89 else
90 [HTTP_HAVE_EXT_]translit($1,a-z_-,A-Z__)=
91 AC_MSG_RESULT([no])
92 $3
93 fi
94 ])
95
96 dnl ----
97 dnl STDC
98 dnl ----
99 AC_CHECK_HEADERS([netdb.h unistd.h])
100 PHP_CHECK_FUNC(gethostname, nsl)
101 PHP_CHECK_FUNC(getdomainname, nsl)
102 PHP_CHECK_FUNC(getservbyport, nsl)
103 PHP_CHECK_FUNC(getservbyname, nsl)
104
105 dnl ----
106 dnl ZLIB
107 dnl ----
108 if test "$PHP_HTTP_ZLIB_COMPRESSION" != "no"; then
109 AC_MSG_CHECKING([for zlib.h])
110 ZLIB_DIR=
111 for i in "$PHP_HTTP_ZLIB_COMPRESSION" "$PHP_ZLIB_DIR" "$PHP_ZLIB" /usr/local /usr /opt; do
112 if test -f "$i/include/zlib.h"; then
113 ZLIB_DIR=$i
114 break;
115 fi
116 done
117 if test -z "$ZLIB_DIR"; then
118 AC_MSG_RESULT([not found])
119 AC_MSG_ERROR([could not find zlib.h])
120 else
121 AC_MSG_RESULT([found in $ZLIB_DIR])
122 AC_MSG_CHECKING([for zlib version >= 1.2.0.4])
123 ZLIB_VERSION=`$EGREP "define ZLIB_VERSION" $ZLIB_DIR/include/zlib.h | $SED -e 's/[[^0-9\.]]//g'`
124 AC_MSG_RESULT([$ZLIB_VERSION])
125 if test `echo $ZLIB_VERSION | $SED -e 's/[[^0-9]]/ /g' | $AWK '{print $1*1000000 + $2*10000 + $3*100 + $4}'` -lt 1020004; then
126 AC_MSG_ERROR([libz version greater or equal to 1.2.0.4 required])
127 else
128 PHP_ADD_INCLUDE($ZLIB_DIR/include)
129 PHP_ADD_LIBRARY_WITH_PATH(z, $ZLIB_DIR/$PHP_LIBDIR, HTTP_SHARED_LIBADD)
130 AC_DEFINE([HTTP_HAVE_ZLIB], [1], [Have zlib support])
131 fi
132 fi
133 fi
134
135 dnl ----
136 dnl CURL
137 dnl ----
138 if test "$PHP_HTTP_CURL_REQUESTS" != "no"; then
139 AC_MSG_CHECKING([for curl/curl.h])
140 CURL_DIR=
141 for i in "$PHP_HTTP_CURL_REQUESTS" /usr/local /usr /opt; do
142 if test -f "$i/include/curl/curl.h"; then
143 CURL_DIR=$i
144 break
145 fi
146 done
147 if test -z "$CURL_DIR"; then
148 AC_MSG_RESULT([not found])
149 AC_MSG_ERROR([could not find curl/curl.h])
150 else
151 AC_MSG_RESULT([found in $CURL_DIR])
152 fi
153
154 AC_MSG_CHECKING([for curl-config])
155 CURL_CONFIG=
156 for i in "$CURL_DIR/bin/curl-config" "$CURL_DIR/curl-config" `which curl-config`; do
157 if test -x "$i"; then
158 CURL_CONFIG=$i
159 break
160 fi
161 done
162 if test -z "$CURL_CONFIG"; then
163 AC_MSG_RESULT([not found])
164 AC_MSG_ERROR([could not find curl-config])
165 else
166 AC_MSG_RESULT([found: $CURL_CONFIG])
167 fi
168
169 dnl Debian stable has currently 7.13.2 (this is not a typo)
170 AC_MSG_CHECKING([for curl version >= 7.12.3])
171 CURL_VERSION=`$CURL_CONFIG --version | $SED -e 's/[[^0-9\.]]//g'`
172 AC_MSG_RESULT([$CURL_VERSION])
173 if test `echo $CURL_VERSION | $SED -e 's/[[^0-9]]/ /g' | $AWK '{print $1*10000 + $2*100 + $3}'` -lt 71203; then
174 AC_MSG_ERROR([libcurl version greater or equal to 7.12.3 required])
175 fi
176
177 CURL_LIBS=`$CURL_CONFIG --libs`
178
179 AC_MSG_CHECKING([for SSL support in libcurl])
180 CURL_SSL=`$CURL_CONFIG --features | $EGREP SSL`
181 if test "$CURL_SSL" = "SSL"; then
182 AC_MSG_RESULT([yes])
183 AC_DEFINE([HTTP_HAVE_SSL], [1], [ ])
184
185 AC_MSG_CHECKING([for SSL library used])
186 CURL_SSL_FLAVOUR=
187 for i in $CURL_LIBS; do
188 case $i in
189 -lssl* | -lyassl*)
190 CURL_SSL_FLAVOUR="openssl"
191 AC_MSG_RESULT([openssl])
192 AC_DEFINE([HTTP_HAVE_OPENSSL], [1], [ ])
193 AC_CHECK_HEADERS([openssl/crypto.h])
194 break
195 ;;
196 -lgnutls*)
197 CURL_SSL_FLAVOUR="gnutls"
198 AC_MSG_RESULT([gnutls])
199 AC_DEFINE([HTTP_HAVE_GNUTLS], [1], [ ])
200 AC_CHECK_HEADERS([gcrypt.h])
201 break
202 ;;
203 esac
204 done
205 if test -z "$CURL_SSL_FLAVOUR"; then
206 AC_MSG_RESULT([unknown!])
207 AC_MSG_WARN([Could not determine the type of SSL library used!])
208 AC_MSG_WARN([Building will fail in ZTS mode!])
209 fi
210 else
211 AC_MSG_RESULT([no])
212 fi
213
214 AC_MSG_CHECKING([for bundled SSL CA info])
215 CURL_CAINFO=
216 for i in `$CURL_CONFIG --ca` "/etc/ssl/certs/ca-certificates.crt"; do
217 if test -f "$i"; then
218 CURL_CAINFO="$i"
219 break
220 fi
221 done
222 if test -z "$CURL_CAINFO"; then
223 AC_MSG_RESULT([not found])
224 else
225 AC_MSG_RESULT([$CURL_CAINFO])
226 AC_DEFINE_UNQUOTED([HTTP_CURL_CAINFO], ["$CURL_CAINFO"], [path to bundled SSL CA info])
227 fi
228
229 PHP_ADD_INCLUDE($CURL_DIR/include)
230 PHP_ADD_LIBRARY_WITH_PATH(curl, $CURL_DIR/$PHP_LIBDIR, HTTP_SHARED_LIBADD)
231 PHP_EVAL_LIBLINE($CURL_LIBS, HTTP_SHARED_LIBADD)
232 AC_DEFINE([HTTP_HAVE_CURL], [1], [Have cURL support])
233
234 PHP_CHECK_LIBRARY(curl, curl_share_strerror,
235 [AC_DEFINE([HAVE_CURL_SHARE_STRERROR], [1], [ ])], [ ],
236 [$CURL_LIBS -L$CURL_DIR/$PHP_LIBDIR]
237 )
238 PHP_CHECK_LIBRARY(curl, curl_multi_strerror,
239 [AC_DEFINE([HAVE_CURL_MULTI_STRERROR], [1], [ ])], [ ],
240 [$CURL_LIBS -L$CURL_DIR/$PHP_LIBDIR]
241 )
242 PHP_CHECK_LIBRARY(curl, curl_easy_strerror,
243 [AC_DEFINE([HAVE_CURL_EASY_STRERROR], [1], [ ])], [ ],
244 [$CURL_LIBS -L$CURL_DIR/$PHP_LIBDIR]
245 )
246 PHP_CHECK_LIBRARY(curl, curl_easy_reset,
247 [AC_DEFINE([HAVE_CURL_EASY_RESET], [1], [ ])], [ ],
248 [$CURL_LIBS -L$CURL_DIR/$PHP_LIBDIR]
249 )
250 dnl Debian suddenly (>=7.14.1-2) hides all symbols not starting with "curl"
251 PHP_CHECK_LIBRARY(curl, Curl_getFormData,
252 [AC_DEFINE([HAVE_CURL_GETFORMDATA], [1], [ ])], [ ],
253 [$CURL_LIBS -L$CURL_DIR/$PHP_LIBDIR]
254 )
255 dnl New API function which obsoletes use of Curl_getFormData (>=7.15.5)
256 PHP_CHECK_LIBRARY(curl, curl_formget,
257 [AC_DEFINE([HAVE_CURL_FORMGET], [1], [ ])], [ ],
258 [$CURL_LIBS -L$CURL_DIR/$PHP_LIBDIR]
259 )
260 PHP_CHECK_LIBRARY(curl, curl_multi_setopt,
261 [AC_DEFINE([HAVE_CURL_MULTI_SETOPT], [1], [ ])], [ ],
262 [$CURL_LIBS -L$CURL_DIR/$PHP_LIBDIR]
263 )
264 PHP_CHECK_LIBRARY(curl, curl_multi_timeout,
265 [AC_DEFINE([HAVE_CURL_MULTI_TIMEOUT], [1], [ ])], [ ],
266 [$CURL_LIBS -L$CURL_DIR/$PHP_LIBDIR]
267 )
268 fi
269
270 dnl ----
271 dnl MAGIC
272 dnl ----
273 if test "$PHP_HTTP_MAGIC_MIME" != "no"; then
274 AC_MSG_CHECKING([for magic.h])
275 MAGIC_DIR=
276 for i in "$PHP_HTTP_MAGIC_MIME" /usr/local /usr /opt; do
277 if test -f "$i/include/magic.h"; then
278 MAGIC_DIR=$i
279 break
280 fi
281 done
282 if test -z "$MAGIC_DIR"; then
283 AC_MSG_RESULT([not found])
284 AC_MSG_ERROR([could not find magic.h])
285 else
286 AC_MSG_RESULT([found in $MAGIC_DIR])
287 fi
288
289 PHP_ADD_INCLUDE($MAGIC_DIR/include)
290 PHP_ADD_LIBRARY_WITH_PATH(magic, $MAGIC_DIR/$PHP_LIBDIR, HTTP_SHARED_LIBADD)
291 AC_DEFINE([HTTP_HAVE_MAGIC], [1], [Have magic mime support])
292 fi
293
294 dnl ----
295 dnl HASH
296 dnl ----
297 HTTP_HAVE_PHP_EXT([hash], [
298 AC_MSG_CHECKING([for php_hash.h])
299 HTTP_EXT_HASH_INCDIR=
300 for i in `echo $INCLUDES | $SED -e's/-I//g'` $abs_srcdir ../hash; do
301 if test -d $i; then
302 if test -f $i/php_hash.h; then
303 HTTP_EXT_HASH_INCDIR=$i
304 break
305 elif test -f $i/ext/hash/php_hash.h; then
306 HTTP_EXT_HASH_INCDIR=$i/ext/hash
307 break
308 fi
309 fi
310 done
311 if test -z "$HTTP_EXT_HASH_INCDIR"; then
312 AC_MSG_RESULT([not found])
313 else
314 AC_MSG_RESULT([$HTTP_EXT_HASH_INCDIR])
315 AC_DEFINE([HTTP_HAVE_PHP_HASH_H], [1], [Have ext/hash support])
316 PHP_ADD_INCLUDE([$HTTP_EXT_HASH_INCDIR])
317 fi
318 ])
319
320 dnl ----
321 dnl ICONV
322 dnl ----
323 HTTP_HAVE_PHP_EXT([iconv])
324
325 dnl ----
326 dnl SESSION
327 dnl ----
328 HTTP_HAVE_PHP_EXT([session])
329
330 dnl ----
331 dnl DONE
332 dnl ----
333 PHP_HTTP_SOURCES="missing.c http.c http_functions.c phpstr/phpstr.c \
334 http_util_object.c http_message_object.c http_request_object.c http_request_pool_api.c \
335 http_response_object.c http_exception_object.c http_requestpool_object.c \
336 http_api.c http_cache_api.c http_request_api.c http_request_info.c http_date_api.c \
337 http_headers_api.c http_message_api.c http_send_api.c http_url_api.c \
338 http_info_api.c http_request_method_api.c http_encoding_api.c \
339 http_filter_api.c http_request_body_api.c http_querystring_object.c \
340 http_deflatestream_object.c http_inflatestream_object.c http_cookie_api.c \
341 http_querystring_api.c http_request_datashare_api.c http_requestdatashare_object.c"
342
343 PHP_NEW_EXTENSION([http], $PHP_HTTP_SOURCES, $ext_shared)
344
345 dnl shared extension deps
346 HTTP_SHARED_DEP([hash])
347 HTTP_SHARED_DEP([iconv])
348 HTTP_SHARED_DEP([session])
349
350 PHP_ADD_BUILD_DIR($ext_builddir/phpstr, 1)
351 PHP_SUBST([HTTP_SHARED_LIBADD])
352
353 PHP_HTTP_HEADERS="php_http_std_defs.h php_http.h php_http_api.h php_http_cache_api.h \
354 php_http_date_api.h php_http_headers_api.h php_http_info_api.h php_http_message_api.h \
355 php_http_request_api.h php_http_request_method_api.h php_http_send_api.h php_http_url_api.h \
356 php_http_encoding_api.h phpstr/phpstr.h missing.h php_http_request_body_api.h \
357 php_http_exception_object.h php_http_message_object.h php_http_request_object.h \
358 php_http_requestpool_object.h php_http_response_object.h php_http_util_object.h \
359 php_http_querystring_object.h php_http_deflatestream_object.h php_http_inflatestream_object.h \
360 php_http_cookie_api.h php_http_querystring_api.h php_http_request_datashare_api.h php_http_requestdatashare_object.h"
361 ifdef([PHP_INSTALL_HEADERS], [
362 PHP_INSTALL_HEADERS(ext/http, $PHP_HTTP_HEADERS)
363 ], [
364 PHP_SUBST([PHP_HTTP_HEADERS])
365 PHP_ADD_MAKEFILE_FRAGMENT
366 ])
367
368 AC_DEFINE([HAVE_HTTP], [1], [Have extended HTTP support])
369 fi