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