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