experimental urlparser
[m6w6/ext-http] / config9.m4
1 dnl config.m4 for pecl/http
2 dnl $Id: config9.m4 242664 2007-09-18 19:13:37Z mike $
3 dnl vim: noet ts=4 sw=4
4
5 PHP_ARG_WITH([http], [whether to enable extended HTTP support],
6 [ --with-http Enable extended HTTP support])
7 PHP_ARG_WITH([http-zlib-dir], [],
8 [ --with-http-zlib-dir[=DIR] HTTP: where to find zlib], $PHP_HTTP, $PHP_HTTP)
9 PHP_ARG_WITH([http-libcurl-dir], [],
10 [ --with-http-libcurl-dir[=DIR] HTTP: where to find libcurl], $PHP_HTTP, $PHP_HTTP)
11 PHP_ARG_WITH([http-libevent-dir], [],
12 [ --with-http-libevent-dir[=DIR] HTTP: where to find libevent], $PHP_HTTP_LIBCURL_DIR, "")
13 PHP_ARG_WITH([http-libidn-dir], [],
14 [ --with-http-libidn-dir=[=DIR] HTTP: where to find libidn], $PHP_HTTP_LIBCURL_DIR, "")
15
16 if test "$PHP_HTTP" != "no"; then
17
18 HTTP_HAVE_A_REQUEST_LIB=false
19
20 ifdef([AC_PROG_EGREP], [
21 AC_PROG_EGREP
22 ], [
23 AC_CHECK_PROG(EGREP, egrep, egrep)
24 ])
25 ifdef([AC_PROG_SED], [
26 AC_PROG_SED
27 ], [
28 ifdef([LT_AC_PROG_SED], [
29 LT_AC_PROG_SED
30 ], [
31 AC_CHECK_PROG(SED, sed, sed)
32 ])
33 ])
34
35 AC_PROG_CPP
36
37 if test "$PHP_HTTP_SHARED_DEPS" != "no"; then
38 AC_DEFINE([PHP_HTTP_SHARED_DEPS], [1], [ ])
39 else
40 AC_DEFINE([PHP_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=$[PHP_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 AC_DEFINE([PHP_HTTP_HAVE_EXT_]translit($1,a-z_-,A-Z__), [1], [ ])
57 ifdef([PHP_ADD_EXTENSION_DEP], [
58 PHP_ADD_EXTENSION_DEP([http], $1, true)
59 ])
60 $2
61 else
62 AC_MSG_RESULT([no])
63 $3
64 fi
65 ])
66
67 dnl
68 dnl HTTP_HAVE_PHP_EXT(name[, code-if-yes[, code-if-not]])
69 dnl
70 AC_DEFUN([HTTP_HAVE_PHP_EXT], [
71 extname=$1
72 haveext=$[PHP_]translit($1,a-z_-,A-Z__)
73 AC_MSG_CHECKING([for ext/$extname support])
74 if test -x "$PHP_EXECUTABLE"; then
75 grepext=`$PHP_EXECUTABLE -m | $EGREP ^$extname\$`
76 if test "$grepext" = "$extname"; then
77 [PHP_HTTP_HAVE_EXT_]translit($1,a-z_-,A-Z__)=1
78 AC_MSG_RESULT([yes])
79 $2
80 else
81 [PHP_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 [PHP_HTTP_HAVE_EXT_]translit($1,a-z_-,A-Z__)=1
87 AC_MSG_RESULT([yes])
88 $2
89 else
90 [PHP_HTTP_HAVE_EXT_]translit($1,a-z_-,A-Z__)=
91 AC_MSG_RESULT([no])
92 $3
93 fi
94 ])
95
96
97 dnl ----
98 dnl STDC
99 dnl ----
100 AC_TYPE_OFF_T
101 dnl getdomainname() is declared in netdb.h on some platforms: AIX, OSF
102 AC_CHECK_HEADERS([netdb.h unistd.h wchar.h wctype.h langinfo.h])
103 PHP_CHECK_FUNC(gethostname, nsl)
104 PHP_CHECK_FUNC(getdomainname, nsl)
105 PHP_CHECK_FUNC(mbrtowc)
106 PHP_CHECK_FUNC(mbtowc)
107 PHP_CHECK_FUNC(iswalnum)
108 PHP_CHECK_FUNC(nl_langinfo)
109
110 dnl ----
111 dnl IDN
112 dnl ----
113
114 AC_MSG_CHECKING([for idna.h])
115 IDNA_DIR=
116 for i in "$PHP_HTTP_LIBIDN_DIR" "$IDN_DIR" /usr/local /usr /opt; do
117 if test -f "$i/include/idna.h"; then
118 IDNA_DIR=$i
119 break;
120 fi
121 done
122 if test "x$IDNA_DIR" = "x"; then
123 AC_MSG_RESULT([not found])
124 else
125 AC_MSG_RESULT([found in $IDNA_DIR])
126 AC_DEFINE([PHP_HTTP_HAVE_IDN], [1], [Have libidn support])
127 PHP_ADD_INCLUDE($IDNA_DIR/include)
128 PHP_ADD_LIBRARY_WITH_PATH(idn, $IDNA_DIR/$PHP_LIBDIR, HTTP_SHARED_LIBADD)
129 fi
130
131 dnl ----
132 dnl ZLIB
133 dnl ----
134 AC_MSG_CHECKING([for zlib.h])
135 ZLIB_DIR=
136 for i in "$PHP_HTTP_ZLIB_DIR" "$PHP_ZLIB_DIR" "$PHP_ZLIB" /usr/local /usr /opt; do
137 if test -f "$i/include/zlib.h"; then
138 ZLIB_DIR=$i
139 break;
140 fi
141 done
142 if test "x$ZLIB_DIR" = "x"; then
143 AC_MSG_RESULT([not found])
144 AC_MSG_ERROR([could not find zlib.h])
145 else
146 AC_MSG_RESULT([found in $ZLIB_DIR])
147 AC_MSG_CHECKING([for zlib version >= 1.2.0.4])
148 ZLIB_VERSION=`$EGREP "define ZLIB_VERSION" $ZLIB_DIR/include/zlib.h | $SED -e 's/[[^0-9\.]]//g'`
149 AC_MSG_RESULT([$ZLIB_VERSION])
150 if test `echo $ZLIB_VERSION | $SED -e 's/[[^0-9]]/ /g' | $AWK '{print $1*1000000 + $2*10000 + $3*100 + $4}'` -lt 1020004; then
151 AC_MSG_ERROR([zlib version greater or equal to 1.2.0.4 required])
152 else
153 PHP_ADD_INCLUDE($ZLIB_DIR/include)
154 PHP_ADD_LIBRARY_WITH_PATH(z, $ZLIB_DIR/$PHP_LIBDIR, HTTP_SHARED_LIBADD)
155 fi
156 fi
157
158 dnl ----
159 dnl CURL
160 dnl ----
161
162 if test "$PHP_HTTP_LIBCURL_DIR" = "no"; then
163 AC_DEFINE([PHP_HTTP_HAVE_CURL], [0], [ ])
164 else
165 AC_MSG_CHECKING([for curl/curl.h])
166 CURL_DIR=
167 for i in "$PHP_HTTP_LIBCURL_DIR" /usr/local /usr /opt; do
168 if test -f "$i/include/curl/curl.h"; then
169 CURL_DIR=$i
170 break
171 fi
172 done
173 if test "x$CURL_DIR" = "x"; then
174 AC_MSG_RESULT([not found])
175 else
176 AC_MSG_RESULT([found in $CURL_DIR])
177
178 AC_MSG_CHECKING([for curl-config])
179 CURL_CONFIG=
180 for i in "$CURL_DIR/bin/curl-config" "$CURL_DIR/curl-config" `which curl-config`; do
181 if test -x "$i"; then
182 CURL_CONFIG=$i
183 break
184 fi
185 done
186 if test "x$CURL_CONFIG" = "x"; then
187 AC_MSG_RESULT([not found])
188 AC_MSG_ERROR([could not find curl-config])
189 else
190 AC_MSG_RESULT([found: $CURL_CONFIG])
191 fi
192
193 dnl RHEL6: 7.19.7
194 dnl SUSE11: 7.19.7
195 dnl Debian wheezy: 7.26.0
196 dnl Debian sqeeze: 7.21.0
197 dnl Debian ancient 7.18.2
198 AC_MSG_CHECKING([for curl version >= 7.18.2])
199 CURL_VERSION=`$CURL_CONFIG --version | $SED -e 's/[[^0-9\.]]//g'`
200 AC_MSG_RESULT([$CURL_VERSION])
201 if test `echo $CURL_VERSION | $SED -e 's/[[^0-9]]/ /g' | $AWK '{print $1*10000 + $2*100 + $3}'` -lt 71802; then
202 AC_MSG_ERROR([libcurl version greater or equal to 7.18.2 required])
203 fi
204
205 dnl
206 dnl compile tests
207 dnl
208
209 save_INCLUDES="$INCLUDES"
210 INCLUDES=
211 save_LIBS="$LIBS"
212 LIBS=
213 save_CFLAGS="$CFLAGS"
214 CFLAGS="$CFLAGS `$CURL_CONFIG --cflags`"
215 save_LDFLAGS="$LDFLAGS"
216 LDFLAGS="$LDFLAGS `$CURL_CONFIG --libs` $ld_runpath_switch$CURL_DIR/$PHP_LIBDIR"
217
218 AC_MSG_CHECKING([for SSL support in libcurl])
219 CURL_SSL=`$CURL_CONFIG --feature | $EGREP SSL`
220 CURL_SSL_LIBS=""
221 if test "$CURL_SSL" = "SSL"; then
222 AC_MSG_RESULT([yes])
223 AC_DEFINE([PHP_HTTP_HAVE_SSL], [1], [ ])
224
225 AC_MSG_CHECKING([for openssl support in libcurl])
226 AC_TRY_RUN([
227 #include <curl/curl.h>
228 int main(int argc, char *argv[]) {
229 curl_version_info_data *data = curl_version_info(CURLVERSION_NOW);
230 if (data && data->ssl_version && *data->ssl_version) {
231 const char *ptr = data->ssl_version;
232 while(*ptr == ' ') ++ptr;
233 return strncasecmp(ptr, "OpenSSL", sizeof("OpenSSL")-1);
234 }
235 return 1;
236 }
237 ], [
238 AC_MSG_RESULT([yes])
239 AC_CHECK_HEADER([openssl/ssl.h], [
240 AC_CHECK_HEADER([openssl/crypto.h], [
241 AC_DEFINE([PHP_HTTP_HAVE_OPENSSL], [1], [ ])
242 CURL_SSL_LIBS="ssl crypto"
243 ])
244 ])
245 ], [
246 AC_MSG_RESULT([no])
247 ], [
248 AC_MSG_RESULT([no])
249 ])
250
251 AC_MSG_CHECKING([for gnutls support in libcurl])
252 AC_TRY_RUN([
253 #include <curl/curl.h>
254 int main(int argc, char *argv[]) {
255 curl_version_info_data *data = curl_version_info(CURLVERSION_NOW);
256 if (data && data->ssl_version && *data->ssl_version) {
257 const char *ptr = data->ssl_version;
258 while(*ptr == ' ') ++ptr;
259 return strncasecmp(ptr, "GnuTLS", sizeof("GnuTLS")-1);
260 }
261 return 1;
262 }
263 ], [
264 AC_MSG_RESULT([yes])
265 AC_CHECK_HEADER([gnutls.h], [
266 AC_CHECK_HEADER([gcrypt.h], [
267 AC_DEFINE([PHP_HTTP_HAVE_GNUTLS], [1], [ ])
268 CURL_SSL_LIBS="gnutls gcrypt"
269 ])
270 ])
271 ], [
272 AC_MSG_RESULT([no])
273 ], [
274 AC_MSG_RESULT([no])
275 ])
276 else
277 AC_MSG_RESULT([no])
278 fi
279
280 AC_MSG_CHECKING([for ares support in libcurl])
281 AC_TRY_RUN([
282 #include <curl/curl.h>
283 int main(int argc, char *argv[]) {
284 curl_version_info_data *data = curl_version_info(CURLVERSION_NOW);
285 if (data && data->ares && data->ares_num0) {
286 return 0;
287 }
288 return 1;
289 }
290 ], [
291 AC_MSG_RESULT([yes])
292 AC_DEFINE([PHP_HTTP_HAVE_ARES], [1], [ ])
293 ], [
294 AC_MSG_RESULT([no])
295 ], [
296 AC_MSG_RESULT([no])
297 ])
298
299 INCLUDES="$save_INCLUDES"
300 LIBS="$save_LIBS"
301 CFLAGS="$save_CFLAGS"
302 LDFLAGS="$save_LDFLAGS"
303
304 if test -n "$CURL_SSL_LIBS"; then
305 for CURL_SSL_LIB in $CURL_SSL_LIBS; do
306 PHP_ADD_LIBRARY_WITH_PATH([$CURL_SSL_LIB], $CURL_DIR/$PHP_LIBDIR, PHP_HTTP_SHARED_LIBADD)
307 done
308 fi
309
310 dnl end compile tests
311
312 AC_MSG_CHECKING([for bundled SSL CA info])
313 CURL_CAINFO=
314 for i in `$CURL_CONFIG --ca` "/etc/ssl/certs/ca-certificates.crt" "/etc/ssl/certs/ca-bundle.crt"; do
315 if test -f "$i"; then
316 CURL_CAINFO="$i"
317 break
318 fi
319 done
320 if test "x$CURL_CAINFO" = "x"; then
321 AC_MSG_RESULT([not found])
322 else
323 AC_MSG_RESULT([$CURL_CAINFO])
324 AC_DEFINE_UNQUOTED([PHP_HTTP_CURL_CAINFO], ["$CURL_CAINFO"], [path to bundled SSL CA info])
325 fi
326
327 PHP_ADD_INCLUDE($CURL_DIR/include)
328 PHP_ADD_LIBRARY_WITH_PATH(curl, $CURL_DIR/$PHP_LIBDIR, HTTP_SHARED_LIBADD)
329 PHP_EVAL_LIBLINE(`$CURL_CONFIG --libs`, HTTP_SHARED_LIBADD)
330 AC_DEFINE([PHP_HTTP_HAVE_CURL], [1], [Have libcurl support])
331 HTTP_HAVE_A_REQUEST_LIB=true
332 fi
333 fi
334
335 dnl ----
336 dnl EVENT
337 dnl ----
338
339 if test "$PHP_HTTP_LIBEVENT_DIR" = "no"; then
340 AC_DEFINE([PHP_HTTP_HAVE_EVENT], [0], [ ])
341 else
342 AC_MSG_CHECKING([for event2/event.h])
343 EVENT_DIR=
344 for i in "$PHP_HTTP_LIBEVENT_DIR" /usr/local /usr /opt; do
345 if test -f "$i/include/event.h"; then
346 EVENT_DIR=$i
347 break
348 fi
349 done
350 if test "x$EVENT_DIR" = "x"; then
351 AC_MSG_RESULT([not found])
352 AC_MSG_WARN([continuing without libevent support])
353 AC_DEFINE([PHP_HTTP_HAVE_EVENT], [0], [ ])
354 else
355 AC_MSG_RESULT([found in $EVENT_DIR])
356
357 AC_MSG_CHECKING([for libevent version, roughly])
358
359 if test -f "$EVENT_DIR/include/event2/event.h"; then
360 EVENT_VER="`$AWK '/_EVENT_VERSION/ {gsub(/\"/,\"\",$3); print $3}' < $EVENT_DIR/include/event2/event-config.h`"
361 AC_DEFINE([PHP_HTTP_HAVE_EVENT2], [1], [ ])
362 else
363 AC_DEFINE([PHP_HTTP_HAVE_EVENT2], [0], [ ])
364 if test -f "$EVENT_DIR/include/evhttp.h" && test -f "$EVENT_DIR/include/evdns.h"; then
365 if test -f "$EVENT_DIR/include/evrpc.h"; then
366 EVENT_VER="1.4 or greater"
367 else
368 EVENT_VER="1.2 or greater"
369 fi
370 else
371 EVENT_VER="1.1b or lower"
372 fi
373 fi
374 AC_DEFINE_UNQUOTED([PHP_HTTP_EVENT_VERSION], ["$EVENT_VER"], [ ])
375 AC_MSG_RESULT([$EVENT_VER])
376
377 PHP_ADD_INCLUDE($EVENT_DIR/include)
378 PHP_ADD_LIBRARY_WITH_PATH(event, $EVENT_DIR/$PHP_LIBDIR, HTTP_SHARED_LIBADD)
379 AC_DEFINE([PHP_HTTP_HAVE_EVENT], [1], [Have libevent support for cURL])
380 fi
381 fi
382
383 dnl ----
384 dnl RAPHF
385 dnl ----
386 HTTP_HAVE_PHP_EXT([raphf], [
387 AC_MSG_CHECKING([for php_raphf.h])
388 HTTP_EXT_RAPHF_INCDIR=
389 for i in `echo $INCLUDES | $SED -e's/-I//g'` $abs_srcdir ../raphf; do
390 if test -d $i; then
391 if test -f $i/php_raphf.h; then
392 HTTP_EXT_RAPHF_INCDIR=$i
393 break
394 elif test -f $i/ext/raphf/php_raphf.h; then
395 HTTP_EXT_RAPHF_INCDIR=$i/ext/raphf
396 break
397 fi
398 fi
399 done
400 if test "x$HTTP_EXT_RAPHF_INCDIR" = "x"; then
401 AC_MSG_ERROR([not found])
402 else
403 AC_MSG_RESULT([$HTTP_EXT_RAPHF_INCDIR])
404 AC_DEFINE([PHP_HTTP_HAVE_PHP_RAPHF_H], [1], [Have ext/raphf support])
405 PHP_ADD_INCLUDE([$HTTP_EXT_RAPHF_INCDIR])
406 fi
407 ], [
408 AC_MSG_ERROR([Please install pecl/raphf and activate extension=raphf.$SHLIB_DL_SUFFIX_NAME in your php.ini])
409 ])
410
411 dnl ----
412 dnl PROPRO
413 dnl ----
414 HTTP_HAVE_PHP_EXT([propro], [
415 AC_MSG_CHECKING([for php_propro.h])
416 HTTP_EXT_PROPRO_INCDIR=
417 for i in `echo $INCLUDES | $SED -e's/-I//g'` $abs_srcdir ../propro; do
418 if test -d $i; then
419 if test -f $i/php_propro.h; then
420 HTTP_EXT_PROPRO_INCDIR=$i
421 break
422 elif test -f $i/ext/propro/php_propro.h; then
423 HTTP_EXT_PROPRO_INCDIR=$i/ext/propro
424 break
425 fi
426 fi
427 done
428 if test "x$HTTP_EXT_PROPRO_INCDIR" = "x"; then
429 AC_MSG_ERROR([not found])
430 else
431 AC_MSG_RESULT([$HTTP_EXT_PROPRO_INCDIR])
432 AC_DEFINE([PHP_HTTP_HAVE_PHP_PROPRO_H], [1], [Have ext/propro support])
433 PHP_ADD_INCLUDE([$HTTP_EXT_PROPRO_INCDIR])
434 fi
435 ], [
436 AC_MSG_ERROR([Please install pecl/propro and activate extension=propro.$SHLIB_DL_SUFFIX_NAME in your php.ini])
437 ])
438
439 PHP_ARG_WITH([http-shared-deps], [whether to depend on extensions which have been built shared],
440 [ --without-http-shared-deps HTTP: do not depend on extensions like hash
441 and iconv (when they are built shared)], $PHP_HTTP, $PHP_HTTP)
442 dnl ----
443 dnl HASH
444 dnl ----
445 HTTP_HAVE_PHP_EXT([hash], [
446 AC_MSG_CHECKING([for php_hash.h])
447 HTTP_EXT_HASH_INCDIR=
448 for i in `echo $INCLUDES | $SED -e's/-I//g'` $abs_srcdir ../hash; do
449 if test -d $i; then
450 if test -f $i/php_hash.h; then
451 HTTP_EXT_HASH_INCDIR=$i
452 break
453 elif test -f $i/ext/hash/php_hash.h; then
454 HTTP_EXT_HASH_INCDIR=$i/ext/hash
455 break
456 fi
457 fi
458 done
459 if test "x$HTTP_EXT_HASH_INCDIR" = "x"; then
460 AC_MSG_RESULT([not found])
461 else
462 AC_MSG_RESULT([$HTTP_EXT_HASH_INCDIR])
463 AC_DEFINE([PHP_HTTP_HAVE_PHP_HASH_H], [1], [Have ext/hash support])
464 PHP_ADD_INCLUDE([$HTTP_EXT_HASH_INCDIR])
465 fi
466 ])
467
468 dnl ----
469 dnl JSON
470 dnl ----
471 HTTP_HAVE_PHP_EXT([json])
472
473
474 dnl ----
475 dnl ICONV
476 dnl ----
477 HTTP_HAVE_PHP_EXT([iconv])
478
479 dnl ----
480 dnl DONE
481 dnl ----
482 PHP_HTTP_SOURCES="\
483 php_http_buffer.c \
484 php_http.c \
485 php_http_client.c \
486 php_http_client_curl.c \
487 php_http_client_request.c \
488 php_http_client_response.c \
489 php_http_cookie.c \
490 php_http_curl.c \
491 php_http_encoding.c \
492 php_http_env.c \
493 php_http_env_request.c \
494 php_http_env_response.c \
495 php_http_etag.c \
496 php_http_exception.c \
497 php_http_filter.c \
498 php_http_header_parser.c \
499 php_http_header.c \
500 php_http_info.c \
501 php_http_message_body.c \
502 php_http_message.c \
503 php_http_message_parser.c \
504 php_http_misc.c \
505 php_http_negotiate.c \
506 php_http_object.c \
507 php_http_options.c \
508 php_http_params.c \
509 php_http_querystring.c \
510 php_http_strlist.c \
511 php_http_url.c \
512 php_http_version.c \
513 "
514 PHP_NEW_EXTENSION([http], $PHP_HTTP_SOURCES, $ext_shared)
515
516 dnl shared extension deps
517 HTTP_SHARED_DEP([hash])
518 HTTP_SHARED_DEP([iconv])
519 HTTP_SHARED_DEP([json])
520
521 dnl extension deps
522 PHP_ADD_EXTENSION_DEP([http], [raphf], true)
523 PHP_ADD_EXTENSION_DEP([http], [propo], true)
524
525 PHP_SUBST([HTTP_SHARED_LIBADD])
526
527 PHP_HTTP_HEADERS="
528 php_http_api.h \
529 php_http_buffer.h \
530 php_http_curl_client.h \
531 php_http_curl_client_datashare.h \
532 php_http_client_datashare.h \
533 php_http_client_factory.h \
534 php_http_client.h \
535 php_http_client_interface.h \
536 php_http_curl_client_pool.h \
537 php_http_client_pool.h \
538 php_http_client_request.h \
539 php_http_client_response.h \
540 php_http_cookie.h \
541 php_http_curl.h \
542 php_http_encoding.h \
543 php_http_env.h \
544 php_http_env_request.h \
545 php_http_env_response.h \
546 php_http_etag.h \
547 php_http_exception.h \
548 php_http_filter.h \
549 php_http.h \
550 php_http_header_parser.h \
551 php_http_header.h \
552 php_http_info.h \
553 php_http_message_body.h \
554 php_http_message.h \
555 php_http_message_parser.h \
556 php_http_misc.h \
557 php_http_negotiate.h \
558 php_http_object.h \
559 php_http_options.h \
560 php_http_params.h \
561 php_http_querystring.h \
562 php_http_strlist.h \
563 php_http_url.h \
564 php_http_version.h \
565 "
566 PHP_INSTALL_HEADERS(ext/http, $PHP_HTTP_HEADERS)
567
568 AC_DEFINE([HAVE_HTTP], [1], [Have extended HTTP support])
569 fi