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