- MFH: odd shell fixes
[m6w6/ext-http] / config9.m4
1 dnl config.m4 for pecl/http
2 dnl $Id$
3 dnl vim: noet ts=1 sw=1
4
5 PHP_ARG_ENABLE([http], [whether to enable extended HTTP support],
6 [ --enable-http Enable extended HTTP support])
7 PHP_ARG_WITH([http-shared-deps], [whether to depend on extensions which have been built shared],
8 [ --with-http-shared-deps
9 HTTP: disable to not depend on extensions like hash,
10 iconv and session (when built shared)], $PHP_HTTP, $PHP_HTTP)
11 PHP_ARG_WITH([http-curl-requests], [whether to enable cURL HTTP request support],
12 [ --with-http-curl-requests[=LIBCURLDIR]
13 HTTP: with cURL request support], $PHP_HTTP, $PHP_HTTP)
14 PHP_ARG_WITH([http-zlib-compression], [whether to enable zlib encodings support],
15 [ --with-http-zlib-compression[=LIBZDIR]
16 HTTP: with zlib encodings support], $PHP_HTTP, $PHP_HTTP)
17 PHP_ARG_WITH([http-magic-mime], [whether to enable response content type guessing],
18 [ --with-http-magic-mime[=LIBMAGICDIR]
19 HTTP: with magic mime response content type guessing], "no", "no")
20
21 if test "$PHP_HTTP" != "no"; then
22
23 ifdef([AC_PROG_EGREP], [
24 AC_PROG_EGREP
25 ], [
26 AC_CHECK_PROG(EGREP, egrep, egrep)
27 ])
28 ifdef([AC_PROG_SED], [
29 AC_PROG_SED
30 ], [
31 ifdef([LT_AC_PROG_SED], [
32 LT_AC_PROG_SED
33 ], [
34 AC_CHECK_PROG(SED, sed, sed)
35 ])
36 ])
37
38 if test "$PHP_HTTP_SHARED_DEPS" != "no"; then
39 AC_DEFINE([HTTP_SHARED_DEPS], [1], [ ])
40 else
41 AC_DEFINE([HTTP_SHARED_DEPS], [0], [ ])
42 fi
43
44 dnl
45 dnl HTTP_SHARED_DEP(name[, code-if-yes[, code-if-not]])
46 dnl
47 AC_DEFUN([HTTP_SHARED_DEP], [
48 extname=$1
49 haveext=$[HTTP_HAVE_EXT_]translit($1,a-z_-,A-Z__)
50
51 AC_MSG_CHECKING([whether to add a dependency on ext/$extname])
52 if test "$PHP_HTTP_SHARED_DEPS" = "no"; then
53 AC_MSG_RESULT([no])
54 $3
55 elif test "$haveext"; then
56 AC_MSG_RESULT([yes])
57 ifdef([PHP_ADD_EXTENSION_DEP], [
58 PHP_ADD_EXTENSION_DEP([http], $1, true)
59 ])
60 $2
61 else
62 AC_MSG_RESULT([no])
63 $3
64 fi
65 ])
66
67 dnl
68 dnl HTTP_HAVE_PHP_EXT(name[, code-if-yes[, code-if-not]])
69 dnl
70 AC_DEFUN([HTTP_HAVE_PHP_EXT], [
71 extname=$1
72 haveext=$[PHP_]translit($1,a-z_-,A-Z__)
73
74 AC_MSG_CHECKING([for ext/$extname support])
75 if test -x "$PHP_EXECUTABLE"; then
76 grepext=`$PHP_EXECUTABLE -m | $EGREP ^$extname\$`
77 if test "$grepext" = "$extname"; then
78 [HTTP_HAVE_EXT_]translit($1,a-z_-,A-Z__)=1
79 AC_MSG_RESULT([yes])
80 $2
81 else
82 [HTTP_HAVE_EXT_]translit($1,a-z_-,A-Z__)=
83 AC_MSG_RESULT([no])
84 $3
85 fi
86 elif test "$haveext" != "no" && test "x$haveext" != "x"; then
87 [HTTP_HAVE_EXT_]translit($1,a-z_-,A-Z__)=1
88 AC_MSG_RESULT([yes])
89 $2
90 else
91 [HTTP_HAVE_EXT_]translit($1,a-z_-,A-Z__)=
92 AC_MSG_RESULT([no])
93 $3
94 fi
95 ])
96
97 dnl
98 dnl odd PHP4 fix
99 dnl
100 if test "x$PHP_LIBDIR" = "x"; then
101 PHP_LIBDIR=lib
102 fi
103
104 dnl ----
105 dnl STDC
106 dnl ----
107 AC_CHECK_HEADERS([netdb.h unistd.h])
108 PHP_CHECK_FUNC(gethostname, nsl)
109 PHP_CHECK_FUNC(getdomainname, nsl)
110 PHP_CHECK_FUNC(getservbyport, nsl)
111 PHP_CHECK_FUNC(getservbyname, nsl)
112
113 dnl ----
114 dnl ZLIB
115 dnl ----
116 if test "$PHP_HTTP_ZLIB_COMPRESSION" != "no"; then
117 AC_MSG_CHECKING([for zlib.h])
118 ZLIB_DIR=
119 for i in "$PHP_HTTP_ZLIB_COMPRESSION" "$PHP_ZLIB_DIR" "$PHP_ZLIB" /usr/local /usr /opt; do
120 if test -f "$i/include/zlib.h"; then
121 ZLIB_DIR=$i
122 break;
123 fi
124 done
125 if test "x$ZLIB_DIR" = "x"; then
126 AC_MSG_RESULT([not found])
127 AC_MSG_ERROR([could not find zlib.h])
128 else
129 AC_MSG_RESULT([found in $ZLIB_DIR])
130 AC_MSG_CHECKING([for zlib version >= 1.2.0.4])
131 ZLIB_VERSION=`$EGREP "define ZLIB_VERSION" $ZLIB_DIR/include/zlib.h | $SED -e 's/[[^0-9\.]]//g'`
132 AC_MSG_RESULT([$ZLIB_VERSION])
133 if test `echo $ZLIB_VERSION | $SED -e 's/[[^0-9]]/ /g' | $AWK '{print $1*1000000 + $2*10000 + $3*100 + $4}'` -lt 1020004; then
134 AC_MSG_ERROR([libz version greater or equal to 1.2.0.4 required])
135 else
136 PHP_ADD_INCLUDE($ZLIB_DIR/include)
137 PHP_ADD_LIBRARY_WITH_PATH(z, $ZLIB_DIR/$PHP_LIBDIR, HTTP_SHARED_LIBADD)
138 AC_DEFINE([HTTP_HAVE_ZLIB], [1], [Have zlib support])
139 fi
140 fi
141 fi
142
143 dnl ----
144 dnl CURL
145 dnl ----
146 if test "$PHP_HTTP_CURL_REQUESTS" != "no"; then
147 AC_MSG_CHECKING([for curl/curl.h])
148 CURL_DIR=
149 for i in "$PHP_HTTP_CURL_REQUESTS" /usr/local /usr /opt; do
150 if test -f "$i/include/curl/curl.h"; then
151 CURL_DIR=$i
152 break
153 fi
154 done
155 if test "x$CURL_DIR" = "x"; then
156 AC_MSG_RESULT([not found])
157 AC_MSG_ERROR([could not find curl/curl.h])
158 else
159 AC_MSG_RESULT([found in $CURL_DIR])
160 fi
161
162 AC_MSG_CHECKING([for curl-config])
163 CURL_CONFIG=
164 for i in "$CURL_DIR/bin/curl-config" "$CURL_DIR/curl-config" `which curl-config`; do
165 if test -x "$i"; then
166 CURL_CONFIG=$i
167 break
168 fi
169 done
170 if test "x$CURL_CONFIG" = "x"; then
171 AC_MSG_RESULT([not found])
172 AC_MSG_ERROR([could not find curl-config])
173 else
174 AC_MSG_RESULT([found: $CURL_CONFIG])
175 fi
176
177 dnl Debian stable has currently 7.13.2 (this is not a typo)
178 AC_MSG_CHECKING([for curl version >= 7.12.3])
179 CURL_VERSION=`$CURL_CONFIG --version | $SED -e 's/[[^0-9\.]]//g'`
180 AC_MSG_RESULT([$CURL_VERSION])
181 if test `echo $CURL_VERSION | $SED -e 's/[[^0-9]]/ /g' | $AWK '{print $1*10000 + $2*100 + $3}'` -lt 71203; then
182 AC_MSG_ERROR([libcurl version greater or equal to 7.12.3 required])
183 fi
184
185 dnl
186 dnl compile tests
187 dnl
188
189 save_INCLUDES="$INCLUDES"
190 INCLUDES=
191 save_LIBS="$LIBS"
192 LIBS=
193 save_CFLAGS="$CFLAGS"
194 CFLAGS=`$CURL_CONFIG --cflags`
195 save_LDFLAGS="$LDFLAGS"
196 LDFLAGS=`$CURL_CONFIG --libs`
197 LDFLAGS="$LDFLAGS $ld_runpath_switch$CURL_DIR/$PHP_LIBDIR"
198
199 AC_MSG_CHECKING([for SSL support in libcurl])
200 CURL_SSL=`$CURL_CONFIG --feature | $EGREP SSL`
201 if test "$CURL_SSL" = "SSL"; then
202 AC_MSG_RESULT([yes])
203 AC_DEFINE([HTTP_HAVE_SSL], [1], [ ])
204
205 AC_MSG_CHECKING([for openssl support in libcurl])
206 AC_TRY_RUN([
207 #include <curl/curl.h>
208 int main(int argc, char *argv[]) {
209 curl_version_info_data *data = curl_version_info(CURLVERSION_NOW);
210 if (data && data->ssl_version && *data->ssl_version) {
211 const char *ptr = data->ssl_version;
212 while(*ptr == ' ') ++ptr;
213 return strncasecmp(ptr, "OpenSSL", sizeof("OpenSSL")-1);
214 }
215 return 1;
216 }
217 ], [
218 AC_MSG_RESULT([yes])
219 AC_CHECK_HEADER([openssl/crypto.h], [
220 AC_DEFINE([HTTP_HAVE_OPENSSL], [1], [ ])
221 ])
222 ], [
223 AC_MSG_RESULT([no])
224 ], [
225 AC_MSG_RESULT([no])
226 ])
227
228 AC_MSG_CHECKING([for gnutls support in libcurl])
229 AC_TRY_RUN([
230 #include <curl/curl.h>
231 int main(int argc, char *argv[]) {
232 curl_version_info_data *data = curl_version_info(CURLVERSION_NOW);
233 if (data && data->ssl_version && *data->ssl_version) {
234 const char *ptr = data->ssl_version;
235 while(*ptr == ' ') ++ptr;
236 return strncasecmp(ptr, "GnuTLS", sizeof("GnuTLS")-1);
237 }
238 return 1;
239 }
240 ], [
241 AC_MSG_RESULT([yes])
242 AC_CHECK_HEADER([gcrypt.h], [
243 AC_DEFINE([HTTP_HAVE_GNUTLS], [1], [ ])
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 INCLUDES="$save_INCLUDES"
255 LIBS="$save_LIBS"
256 CFLAGS="$save_CFLAGS"
257 LDFLAGS="$save_LDFLAGS"
258
259 dnl end compile tests
260
261 AC_MSG_CHECKING([for bundled SSL CA info])
262 CURL_CAINFO=
263 for i in `$CURL_CONFIG --ca` "/etc/ssl/certs/ca-certificates.crt"; do
264 if test -f "$i"; then
265 CURL_CAINFO="$i"
266 break
267 fi
268 done
269 if test "x$CURL_CAINFO" = "x"; then
270 AC_MSG_RESULT([not found])
271 else
272 AC_MSG_RESULT([$CURL_CAINFO])
273 AC_DEFINE_UNQUOTED([HTTP_CURL_CAINFO], ["$CURL_CAINFO"], [path to bundled SSL CA info])
274 fi
275
276 PHP_ADD_INCLUDE($CURL_DIR/include)
277 PHP_ADD_LIBRARY_WITH_PATH(curl, $CURL_DIR/$PHP_LIBDIR, HTTP_SHARED_LIBADD)
278 PHP_EVAL_LIBLINE(`$CURL_CONFIG --libs`, HTTP_SHARED_LIBADD)
279 AC_DEFINE([HTTP_HAVE_CURL], [1], [Have cURL support])
280
281 PHP_CHECK_LIBRARY(curl, curl_share_strerror,
282 [AC_DEFINE([HAVE_CURL_SHARE_STRERROR], [1], [ ])], [ ],
283 [$CURL_LIBS -L$CURL_DIR/$PHP_LIBDIR]
284 )
285 PHP_CHECK_LIBRARY(curl, curl_multi_strerror,
286 [AC_DEFINE([HAVE_CURL_MULTI_STRERROR], [1], [ ])], [ ],
287 [$CURL_LIBS -L$CURL_DIR/$PHP_LIBDIR]
288 )
289 PHP_CHECK_LIBRARY(curl, curl_easy_strerror,
290 [AC_DEFINE([HAVE_CURL_EASY_STRERROR], [1], [ ])], [ ],
291 [$CURL_LIBS -L$CURL_DIR/$PHP_LIBDIR]
292 )
293 PHP_CHECK_LIBRARY(curl, curl_easy_reset,
294 [AC_DEFINE([HAVE_CURL_EASY_RESET], [1], [ ])], [ ],
295 [$CURL_LIBS -L$CURL_DIR/$PHP_LIBDIR]
296 )
297 PHP_CHECK_LIBRARY(curl, curl_formget,
298 [AC_DEFINE([HAVE_CURL_FORMGET], [1], [ ])], [ ],
299 [$CURL_LIBS -L$CURL_DIR/$PHP_LIBDIR]
300 )
301 PHP_CHECK_LIBRARY(curl, curl_multi_setopt,
302 [AC_DEFINE([HAVE_CURL_MULTI_SETOPT], [1], [ ])], [ ],
303 [$CURL_LIBS -L$CURL_DIR/$PHP_LIBDIR]
304 )
305 PHP_CHECK_LIBRARY(curl, curl_multi_timeout,
306 [AC_DEFINE([HAVE_CURL_MULTI_TIMEOUT], [1], [ ])], [ ],
307 [$CURL_LIBS -L$CURL_DIR/$PHP_LIBDIR]
308 )
309
310 fi
311
312 dnl ----
313 dnl MAGIC
314 dnl ----
315 if test "$PHP_HTTP_MAGIC_MIME" != "no"; then
316 AC_MSG_CHECKING([for magic.h])
317 MAGIC_DIR=
318 for i in "$PHP_HTTP_MAGIC_MIME" /usr/local /usr /opt; do
319 if test -f "$i/include/magic.h"; then
320 MAGIC_DIR=$i
321 break
322 fi
323 done
324 if test "x$MAGIC_DIR" = "x"; then
325 AC_MSG_RESULT([not found])
326 AC_MSG_ERROR([could not find magic.h])
327 else
328 AC_MSG_RESULT([found in $MAGIC_DIR])
329 fi
330
331 PHP_ADD_INCLUDE($MAGIC_DIR/include)
332 PHP_ADD_LIBRARY_WITH_PATH(magic, $MAGIC_DIR/$PHP_LIBDIR, HTTP_SHARED_LIBADD)
333 AC_DEFINE([HTTP_HAVE_MAGIC], [1], [Have magic mime support])
334 fi
335
336 dnl ----
337 dnl HASH
338 dnl ----
339 HTTP_HAVE_PHP_EXT([hash], [
340 AC_MSG_CHECKING([for php_hash.h])
341 HTTP_EXT_HASH_INCDIR=
342 for i in `echo $INCLUDES | $SED -e's/-I//g'` $abs_srcdir ../hash; do
343 if test -d $i; then
344 if test -f $i/php_hash.h; then
345 HTTP_EXT_HASH_INCDIR=$i
346 break
347 elif test -f $i/ext/hash/php_hash.h; then
348 HTTP_EXT_HASH_INCDIR=$i/ext/hash
349 break
350 fi
351 fi
352 done
353 if test "x$HTTP_EXT_HASH_INCDIR" = "x"; then
354 AC_MSG_RESULT([not found])
355 else
356 AC_MSG_RESULT([$HTTP_EXT_HASH_INCDIR])
357 AC_DEFINE([HTTP_HAVE_PHP_HASH_H], [1], [Have ext/hash support])
358 PHP_ADD_INCLUDE([$HTTP_EXT_HASH_INCDIR])
359 fi
360 ])
361
362 dnl ----
363 dnl ICONV
364 dnl ----
365 HTTP_HAVE_PHP_EXT([iconv])
366
367 dnl ----
368 dnl SESSION
369 dnl ----
370 HTTP_HAVE_PHP_EXT([session])
371
372 dnl ----
373 dnl DONE
374 dnl ----
375 PHP_HTTP_SOURCES="missing.c http.c http_functions.c phpstr/phpstr.c \
376 http_util_object.c http_message_object.c http_request_object.c http_request_pool_api.c \
377 http_response_object.c http_exception_object.c http_requestpool_object.c \
378 http_api.c http_cache_api.c http_request_api.c http_request_info.c http_date_api.c \
379 http_headers_api.c http_message_api.c http_send_api.c http_url_api.c \
380 http_info_api.c http_request_method_api.c http_encoding_api.c \
381 http_filter_api.c http_request_body_api.c http_querystring_object.c \
382 http_deflatestream_object.c http_inflatestream_object.c http_cookie_api.c \
383 http_querystring_api.c http_request_datashare_api.c http_requestdatashare_object.c \
384 http_persistent_handle_api.c"
385
386 PHP_NEW_EXTENSION([http], $PHP_HTTP_SOURCES, $ext_shared)
387
388 dnl shared extension deps
389 HTTP_SHARED_DEP([hash])
390 HTTP_SHARED_DEP([iconv])
391 HTTP_SHARED_DEP([session])
392
393 PHP_ADD_BUILD_DIR($ext_builddir/phpstr, 1)
394 PHP_SUBST([HTTP_SHARED_LIBADD])
395
396 PHP_HTTP_HEADERS="php_http_std_defs.h php_http.h php_http_api.h php_http_cache_api.h \
397 php_http_date_api.h php_http_headers_api.h php_http_info_api.h php_http_message_api.h \
398 php_http_request_api.h php_http_request_method_api.h php_http_send_api.h php_http_url_api.h \
399 php_http_encoding_api.h phpstr/phpstr.h missing.h php_http_request_body_api.h \
400 php_http_exception_object.h php_http_message_object.h php_http_request_object.h \
401 php_http_requestpool_object.h php_http_response_object.h php_http_util_object.h \
402 php_http_querystring_object.h php_http_deflatestream_object.h php_http_inflatestream_object.h \
403 php_http_cookie_api.h php_http_querystring_api.h php_http_request_datashare_api.h php_http_requestdatashare_object.h \
404 php_http_persistent_handle_api.h"
405 ifdef([PHP_INSTALL_HEADERS], [
406 PHP_INSTALL_HEADERS(ext/http, $PHP_HTTP_HEADERS)
407 ], [
408 PHP_SUBST([PHP_HTTP_HEADERS])
409 PHP_ADD_MAKEFILE_FRAGMENT
410 ])
411
412 AC_DEFINE([HAVE_HTTP], [1], [Have extended HTTP support])
413 fi