3d5eefc4198f089f4a772513b48a2c7ca57c92a7
[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-shared-deps], [whether to depend on extensions which have been built shared],
8 [ --with-http-shared-deps
9 HTTP: disable to not depend on extensions like hash,
10 iconv and session (when built shared)], $PHP_HTTP, $PHP_HTTP)
11 PHP_ARG_WITH([http-curl-requests], [whether to enable cURL HTTP request support],
12 [ --with-http-curl-requests[=LIBCURLDIR]
13 HTTP: with cURL request support], $PHP_HTTP, $PHP_HTTP)
14 PHP_ARG_WITH([http-curl-libevent], [whether to enable libevent support fur cURL],
15 [ --with-http-curl-libevent[=LIBEVENTDIR]
16 HTTP: libevent install directory], $PHP_HTTP_CURL_REQUESTS, "")
17 PHP_ARG_WITH([http-zlib-compression], [whether to enable zlib encodings support],
18 [ --with-http-zlib-compression[=LIBZDIR]
19 HTTP: with zlib encodings support], $PHP_HTTP, $PHP_HTTP)
20 PHP_ARG_WITH([http-magic-mime], [whether to enable response content type guessing],
21 [ --with-http-magic-mime[=LIBMAGICDIR]
22 HTTP: with magic mime response content type guessing], "no", "no")
23
24 if test "$PHP_HTTP" != "no"; then
25
26 ifdef([AC_PROG_EGREP], [
27 AC_PROG_EGREP
28 ], [
29 AC_CHECK_PROG(EGREP, egrep, egrep)
30 ])
31 ifdef([AC_PROG_SED], [
32 AC_PROG_SED
33 ], [
34 ifdef([LT_AC_PROG_SED], [
35 LT_AC_PROG_SED
36 ], [
37 AC_CHECK_PROG(SED, sed, sed)
38 ])
39 ])
40
41 AC_PROG_CPP
42
43 if test "$PHP_HTTP_SHARED_DEPS" != "no"; then
44 AC_DEFINE([HTTP_SHARED_DEPS], [1], [ ])
45 else
46 AC_DEFINE([HTTP_SHARED_DEPS], [0], [ ])
47 fi
48
49 dnl
50 dnl HTTP_SHARED_DEP(name[, code-if-yes[, code-if-not]])
51 dnl
52 AC_DEFUN([HTTP_SHARED_DEP], [
53 extname=$1
54 haveext=$[HTTP_HAVE_EXT_]translit($1,a-z_-,A-Z__)
55
56 AC_MSG_CHECKING([whether to add a dependency on ext/$extname])
57 if test "$PHP_HTTP_SHARED_DEPS" = "no"; then
58 AC_MSG_RESULT([no])
59 $3
60 elif test "$haveext"; then
61 AC_MSG_RESULT([yes])
62 ifdef([PHP_ADD_EXTENSION_DEP], [
63 PHP_ADD_EXTENSION_DEP([http], $1, true)
64 ])
65 $2
66 else
67 AC_MSG_RESULT([no])
68 $3
69 fi
70 ])
71
72 dnl
73 dnl HTTP_HAVE_PHP_EXT(name[, code-if-yes[, code-if-not]])
74 dnl
75 AC_DEFUN([HTTP_HAVE_PHP_EXT], [
76 extname=$1
77 haveext=$[PHP_]translit($1,a-z_-,A-Z__)
78
79 AC_MSG_CHECKING([for ext/$extname support])
80 if test -x "$PHP_EXECUTABLE"; then
81 grepext=`$PHP_EXECUTABLE -m | $EGREP ^$extname\$`
82 if test "$grepext" = "$extname"; then
83 [HTTP_HAVE_EXT_]translit($1,a-z_-,A-Z__)=1
84 AC_MSG_RESULT([yes])
85 $2
86 else
87 [HTTP_HAVE_EXT_]translit($1,a-z_-,A-Z__)=
88 AC_MSG_RESULT([no])
89 $3
90 fi
91 elif test "$haveext" != "no" && test "x$haveext" != "x"; then
92 [HTTP_HAVE_EXT_]translit($1,a-z_-,A-Z__)=1
93 AC_MSG_RESULT([yes])
94 $2
95 else
96 [HTTP_HAVE_EXT_]translit($1,a-z_-,A-Z__)=
97 AC_MSG_RESULT([no])
98 $3
99 fi
100 ])
101
102 dnl ----
103 dnl STDC
104 dnl ----
105 AC_CHECK_HEADERS([netdb.h unistd.h])
106 PHP_CHECK_FUNC(gethostname, nsl)
107 PHP_CHECK_FUNC(getdomainname, nsl)
108 PHP_CHECK_FUNC(getservbyport, nsl)
109 PHP_CHECK_FUNC(getservbyname, nsl)
110
111 dnl ----
112 dnl ZLIB
113 dnl ----
114 if test "$PHP_HTTP_ZLIB_COMPRESSION" != "no"; then
115 AC_MSG_CHECKING([for zlib.h])
116 ZLIB_DIR=
117 for i in "$PHP_HTTP_ZLIB_COMPRESSION" "$PHP_ZLIB_DIR" "$PHP_ZLIB" /usr/local /usr /opt; do
118 if test -f "$i/include/zlib.h"; then
119 ZLIB_DIR=$i
120 break;
121 fi
122 done
123 if test "x$ZLIB_DIR" = "x"; then
124 AC_MSG_RESULT([not found])
125 AC_MSG_ERROR([could not find zlib.h])
126 else
127 AC_MSG_RESULT([found in $ZLIB_DIR])
128 AC_MSG_CHECKING([for zlib version >= 1.2.0.4])
129 ZLIB_VERSION=`$EGREP "define ZLIB_VERSION" $ZLIB_DIR/include/zlib.h | $SED -e 's/[[^0-9\.]]//g'`
130 AC_MSG_RESULT([$ZLIB_VERSION])
131 if test `echo $ZLIB_VERSION | $SED -e 's/[[^0-9]]/ /g' | $AWK '{print $1*1000000 + $2*10000 + $3*100 + $4}'` -lt 1020004; then
132 AC_MSG_ERROR([libz version greater or equal to 1.2.0.4 required])
133 else
134 PHP_ADD_INCLUDE($ZLIB_DIR/include)
135 PHP_ADD_LIBRARY_WITH_PATH(z, $ZLIB_DIR/$PHP_LIBDIR, HTTP_SHARED_LIBADD)
136 AC_DEFINE([HTTP_HAVE_ZLIB], [1], [Have zlib support])
137 fi
138 fi
139 fi
140
141 dnl ----
142 dnl CURL
143 dnl ----
144 if test "$PHP_HTTP_CURL_REQUESTS" != "no"; then
145 AC_MSG_CHECKING([for curl/curl.h])
146 CURL_DIR=
147 for i in "$PHP_HTTP_CURL_REQUESTS" /usr/local /usr /opt; do
148 if test -f "$i/include/curl/curl.h"; then
149 CURL_DIR=$i
150 break
151 fi
152 done
153 if test "x$CURL_DIR" = "x"; then
154 AC_MSG_RESULT([not found])
155 AC_MSG_ERROR([could not find curl/curl.h])
156 else
157 AC_MSG_RESULT([found in $CURL_DIR])
158 fi
159
160 AC_MSG_CHECKING([for curl-config])
161 CURL_CONFIG=
162 for i in "$CURL_DIR/bin/curl-config" "$CURL_DIR/curl-config" `which curl-config`; do
163 if test -x "$i"; then
164 CURL_CONFIG=$i
165 break
166 fi
167 done
168 if test "x$CURL_CONFIG" = "x"; then
169 AC_MSG_RESULT([not found])
170 AC_MSG_ERROR([could not find curl-config])
171 else
172 AC_MSG_RESULT([found: $CURL_CONFIG])
173 fi
174
175 dnl Debian stable has currently 7.13.2 (this is not a typo)
176 AC_MSG_CHECKING([for curl version >= 7.12.3])
177 CURL_VERSION=`$CURL_CONFIG --version | $SED -e 's/[[^0-9\.]]//g'`
178 AC_MSG_RESULT([$CURL_VERSION])
179 if test `echo $CURL_VERSION | $SED -e 's/[[^0-9]]/ /g' | $AWK '{print $1*10000 + $2*100 + $3}'` -lt 71203; then
180 AC_MSG_ERROR([libcurl version greater or equal to 7.12.3 required])
181 fi
182
183 dnl
184 dnl compile tests
185 dnl
186
187 save_INCLUDES="$INCLUDES"
188 INCLUDES=
189 save_LIBS="$LIBS"
190 LIBS=
191 save_CFLAGS="$CFLAGS"
192 CFLAGS=`$CURL_CONFIG --cflags`
193 save_LDFLAGS="$LDFLAGS"
194 LDFLAGS=`$CURL_CONFIG --libs`
195 LDFLAGS="$LDFLAGS $ld_runpath_switch$CURL_DIR/$PHP_LIBDIR"
196
197 AC_MSG_CHECKING([for SSL support in libcurl])
198 CURL_SSL=`$CURL_CONFIG --feature | $EGREP SSL`
199 if test "$CURL_SSL" = "SSL"; then
200 AC_MSG_RESULT([yes])
201 AC_DEFINE([HTTP_HAVE_SSL], [1], [ ])
202
203 AC_MSG_CHECKING([for openssl support in libcurl])
204 AC_TRY_RUN([
205 #include <curl/curl.h>
206 int main(int argc, char *argv[]) {
207 curl_version_info_data *data = curl_version_info(CURLVERSION_NOW);
208 if (data && data->ssl_version && *data->ssl_version) {
209 const char *ptr = data->ssl_version;
210 while(*ptr == ' ') ++ptr;
211 return strncasecmp(ptr, "OpenSSL", sizeof("OpenSSL")-1);
212 }
213 return 1;
214 }
215 ], [
216 AC_MSG_RESULT([yes])
217 AC_CHECK_HEADER([openssl/crypto.h], [
218 AC_DEFINE([HTTP_HAVE_OPENSSL], [1], [ ])
219 ])
220 ], [
221 AC_MSG_RESULT([no])
222 ], [
223 AC_MSG_RESULT([no])
224 ])
225
226 AC_MSG_CHECKING([for gnutls support in libcurl])
227 AC_TRY_RUN([
228 #include <curl/curl.h>
229 int main(int argc, char *argv[]) {
230 curl_version_info_data *data = curl_version_info(CURLVERSION_NOW);
231 if (data && data->ssl_version && *data->ssl_version) {
232 const char *ptr = data->ssl_version;
233 while(*ptr == ' ') ++ptr;
234 return strncasecmp(ptr, "GnuTLS", sizeof("GnuTLS")-1);
235 }
236 return 1;
237 }
238 ], [
239 AC_MSG_RESULT([yes])
240 AC_CHECK_HEADER([gcrypt.h], [
241 AC_DEFINE([HTTP_HAVE_GNUTLS], [1], [ ])
242 ])
243 ], [
244 AC_MSG_RESULT([no])
245 ], [
246 AC_MSG_RESULT([no])
247 ])
248 else
249 AC_MSG_RESULT([no])
250 fi
251
252 INCLUDES="$save_INCLUDES"
253 LIBS="$save_LIBS"
254 CFLAGS="$save_CFLAGS"
255 LDFLAGS="$save_LDFLAGS"
256
257 dnl end compile tests
258
259 AC_MSG_CHECKING([for bundled SSL CA info])
260 CURL_CAINFO=
261 for i in `$CURL_CONFIG --ca` "/etc/ssl/certs/ca-certificates.crt"; do
262 if test -f "$i"; then
263 CURL_CAINFO="$i"
264 break
265 fi
266 done
267 if test "x$CURL_CAINFO" = "x"; then
268 AC_MSG_RESULT([not found])
269 else
270 AC_MSG_RESULT([$CURL_CAINFO])
271 AC_DEFINE_UNQUOTED([HTTP_CURL_CAINFO], ["$CURL_CAINFO"], [path to bundled SSL CA info])
272 fi
273
274 PHP_ADD_INCLUDE($CURL_DIR/include)
275 PHP_ADD_LIBRARY_WITH_PATH(curl, $CURL_DIR/$PHP_LIBDIR, HTTP_SHARED_LIBADD)
276 PHP_EVAL_LIBLINE(`$CURL_CONFIG --libs`, HTTP_SHARED_LIBADD)
277 AC_DEFINE([HTTP_HAVE_CURL], [1], [Have cURL support])
278
279 PHP_CHECK_LIBRARY(curl, curl_share_strerror,
280 [AC_DEFINE([HAVE_CURL_SHARE_STRERROR], [1], [ ])], [ ],
281 [$CURL_LIBS -L$CURL_DIR/$PHP_LIBDIR]
282 )
283 PHP_CHECK_LIBRARY(curl, curl_multi_strerror,
284 [AC_DEFINE([HAVE_CURL_MULTI_STRERROR], [1], [ ])], [ ],
285 [$CURL_LIBS -L$CURL_DIR/$PHP_LIBDIR]
286 )
287 PHP_CHECK_LIBRARY(curl, curl_easy_strerror,
288 [AC_DEFINE([HAVE_CURL_EASY_STRERROR], [1], [ ])], [ ],
289 [$CURL_LIBS -L$CURL_DIR/$PHP_LIBDIR]
290 )
291 PHP_CHECK_LIBRARY(curl, curl_easy_reset,
292 [AC_DEFINE([HAVE_CURL_EASY_RESET], [1], [ ])], [ ],
293 [$CURL_LIBS -L$CURL_DIR/$PHP_LIBDIR]
294 )
295 PHP_CHECK_LIBRARY(curl, curl_formget,
296 [AC_DEFINE([HAVE_CURL_FORMGET], [1], [ ])], [ ],
297 [$CURL_LIBS -L$CURL_DIR/$PHP_LIBDIR]
298 )
299 PHP_CHECK_LIBRARY(curl, curl_multi_setopt,
300 [AC_DEFINE([HAVE_CURL_MULTI_SETOPT], [1], [ ])], [ ],
301 [$CURL_LIBS -L$CURL_DIR/$PHP_LIBDIR]
302 )
303 PHP_CHECK_LIBRARY(curl, curl_multi_timeout,
304 [AC_DEFINE([HAVE_CURL_MULTI_TIMEOUT], [1], [ ])], [ ],
305 [$CURL_LIBS -L$CURL_DIR/$PHP_LIBDIR]
306 )
307
308 dnl ----
309 dnl EVENT
310 dnl ----
311
312 if test "$PHP_HTTP_CURL_LIBEVENT" != "no"; then
313 HTTP_HAVE_PHP_EXT([event], [
314 AC_MSG_WARN([event support is incompatible with pecl/event; continuing without libevent support])
315 ], [
316 AC_MSG_CHECKING([for event.h])
317 EVENT_DIR=
318 for i in "$PHP_HTTP_CURL_LIBEVENT" /usr/local /usr /opt; do
319 if test -f "$i/include/event.h"; then
320 EVENT_DIR=$i
321 break
322 fi
323 done
324 if test "x$EVENT_DIR" = "x"; then
325 AC_MSG_RESULT([not found])
326 AC_MSG_WARN([continuing without libevent support])
327 else
328 AC_MSG_RESULT([found in $EVENT_DIR])
329
330 AC_MSG_CHECKING([for libevent version, roughly])
331 EVENT_VER="1.1b or lower"
332 if test -f "$EVENT_DIR/include/evhttp.h" && test -f "$EVENT_DIR/include/evdns.h"; then
333 if test -f "$EVENT_DIR/include/evrpc.h"; then
334 EVENT_VER="1.4 or greater"
335 else
336 EVENT_VER="1.2 or greater"
337 fi
338 fi
339 AC_DEFINE_UNQUOTED([HTTP_EVENT_VERSION], ["$EVENT_VER"], [ ])
340 AC_MSG_RESULT([$EVENT_VER])
341
342 AC_MSG_CHECKING([for libcurl version >= 7.16.0])
343 AC_MSG_RESULT([$CURL_VERSION])
344 if test `echo $CURL_VERSION | $SED -e 's/[[^0-9]]/ /g' | $AWK '{print $1*10000 + $2*100 + $3}'` -lt 71600; then
345 AC_MSG_WARN([libcurl version greater or equal to 7.16.0 required; continuing without libevent support])
346 else
347 PHP_ADD_INCLUDE($EVENT_DIR/include)
348 PHP_ADD_LIBRARY_WITH_PATH(event, $EVENT_DIR/$PHP_LIBDIR, HTTP_SHARED_LIBADD)
349 AC_DEFINE([HTTP_HAVE_EVENT], [1], [Have libevent support for cURL])
350 PHP_CHECK_LIBRARY(curl, curl_multi_socket_action,
351 [AC_DEFINE([HAVE_CURL_MULTI_SOCKET_ACTION], [1], [ ])], [ ],
352 [$CURL_LIBS -L$CURL_DIR/$PHP_LIBDIR]
353 )
354 fi
355 fi
356 ])
357 fi
358 fi
359
360 dnl ----
361 dnl MAGIC
362 dnl ----
363 if test "$PHP_HTTP_MAGIC_MIME" != "no"; then
364 AC_MSG_CHECKING([for magic.h])
365 MAGIC_DIR=
366 for i in "$PHP_HTTP_MAGIC_MIME" /usr/local /usr /opt; do
367 if test -f "$i/include/magic.h"; then
368 MAGIC_DIR=$i
369 break
370 fi
371 done
372 if test "x$MAGIC_DIR" = "x"; then
373 AC_MSG_RESULT([not found])
374 AC_MSG_ERROR([could not find magic.h])
375 else
376 AC_MSG_RESULT([found in $MAGIC_DIR])
377 fi
378
379 PHP_ADD_INCLUDE($MAGIC_DIR/include)
380 PHP_ADD_LIBRARY_WITH_PATH(magic, $MAGIC_DIR/$PHP_LIBDIR, HTTP_SHARED_LIBADD)
381 AC_DEFINE([HTTP_HAVE_MAGIC], [1], [Have magic mime support])
382 fi
383
384 dnl ----
385 dnl HASH
386 dnl ----
387 HTTP_HAVE_PHP_EXT([hash], [
388 AC_MSG_CHECKING([for php_hash.h])
389 HTTP_EXT_HASH_INCDIR=
390 for i in `echo $INCLUDES | $SED -e's/-I//g'` $abs_srcdir ../hash; do
391 if test -d $i; then
392 if test -f $i/php_hash.h; then
393 HTTP_EXT_HASH_INCDIR=$i
394 break
395 elif test -f $i/ext/hash/php_hash.h; then
396 HTTP_EXT_HASH_INCDIR=$i/ext/hash
397 break
398 fi
399 fi
400 done
401 if test "x$HTTP_EXT_HASH_INCDIR" = "x"; then
402 AC_MSG_RESULT([not found])
403 else
404 AC_MSG_RESULT([$HTTP_EXT_HASH_INCDIR])
405 AC_DEFINE([HTTP_HAVE_PHP_HASH_H], [1], [Have ext/hash support])
406 PHP_ADD_INCLUDE([$HTTP_EXT_HASH_INCDIR])
407 fi
408 ])
409
410 dnl ----
411 dnl ICONV
412 dnl ----
413 HTTP_HAVE_PHP_EXT([iconv])
414
415 dnl ----
416 dnl SESSION
417 dnl ----
418 HTTP_HAVE_PHP_EXT([session])
419
420 dnl ----
421 dnl DONE
422 dnl ----
423 PHP_HTTP_SOURCES="missing.c http.c http_functions.c phpstr/phpstr.c \
424 http_util_object.c http_message_object.c http_request_object.c http_request_pool_api.c \
425 http_response_object.c http_exception_object.c http_requestpool_object.c \
426 http_api.c http_cache_api.c http_request_api.c http_request_info.c http_date_api.c \
427 http_headers_api.c http_message_api.c http_send_api.c http_url_api.c \
428 http_info_api.c http_request_method_api.c http_encoding_api.c \
429 http_filter_api.c http_request_body_api.c http_querystring_object.c \
430 http_deflatestream_object.c http_inflatestream_object.c http_cookie_api.c \
431 http_querystring_api.c http_request_datashare_api.c http_requestdatashare_object.c \
432 http_persistent_handle_api.c"
433
434 PHP_NEW_EXTENSION([http], $PHP_HTTP_SOURCES, $ext_shared)
435
436 dnl shared extension deps
437 HTTP_SHARED_DEP([hash])
438 HTTP_SHARED_DEP([iconv])
439 HTTP_SHARED_DEP([session])
440
441 PHP_ADD_BUILD_DIR($ext_builddir/phpstr, 1)
442 PHP_SUBST([HTTP_SHARED_LIBADD])
443
444 PHP_HTTP_HEADERS="php_http_std_defs.h php_http.h php_http_api.h php_http_cache_api.h \
445 php_http_date_api.h php_http_headers_api.h php_http_info_api.h php_http_message_api.h \
446 php_http_request_api.h php_http_request_method_api.h php_http_send_api.h php_http_url_api.h \
447 php_http_encoding_api.h phpstr/phpstr.h missing.h php_http_request_body_api.h \
448 php_http_exception_object.h php_http_message_object.h php_http_request_object.h \
449 php_http_requestpool_object.h php_http_response_object.h php_http_util_object.h \
450 php_http_querystring_object.h php_http_deflatestream_object.h php_http_inflatestream_object.h \
451 php_http_cookie_api.h php_http_querystring_api.h php_http_request_datashare_api.h php_http_requestdatashare_object.h \
452 php_http_persistent_handle_api.h"
453 ifdef([PHP_INSTALL_HEADERS], [
454 PHP_INSTALL_HEADERS(ext/http, $PHP_HTTP_HEADERS)
455 ], [
456 PHP_SUBST([PHP_HTTP_HEADERS])
457 PHP_ADD_MAKEFILE_FRAGMENT
458 ])
459
460 AC_DEFINE([HAVE_HTTP], [1], [Have extended HTTP support])
461 fi