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