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