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