7412b634394f4aca2e0e110454ef609030482a86
[m6w6/ext-http] / config.m4
1 dnl config.m4 for pecl/http
2 dnl $Id$
3
4 PHP_ARG_ENABLE([http], [whether to enable extended HTTP support],
5 [ --enable-http Enable extended HTTP support])
6 PHP_ARG_WITH([http-curl-requests], [whether to enable cURL HTTP requests],
7 [ --with-http-curl-requests[=CURLDIR]
8 With cURL HTTP request support])
9 PHP_ARG_WITH([http-mhash-etags], [whether to enable mhash ETag generator],
10 [ --with-http-mhash-etags[=MHASHDIR]
11 With mhash ETag generator support])
12 PHP_ARG_WITH([http-magic-mime], [whether to enable response content type guessing],
13 [ --with-http-magic-mime[=MAGICDIR]
14 With magic mime response content type guessing])
15 PHP_ARG_WITH([http-zlib-compression], [whether to enable support for gzencoded/deflated message bodies])
16 [ --with-http-zlib-compression[=ZLIBDIR]
17 With zlib gzdecode and inflate support])
18
19 if test "$PHP_HTTP" != "no"; then
20
21 dnl -------
22 dnl NETDB.H
23 dnl -------
24 AC_MSG_CHECKING(for netdb.h)
25 if test -r /usr/include/netdb.h -o -r /usr/local/include/netdb.h; then
26 AC_DEFINE(HAVE_NETDB_H, 1, [Have netdb.h])
27 AC_MSG_RESULT(found in default path)
28 else
29 AC_MSG_RESULT(not found in default path)
30 fi
31
32 dnl ----
33 dnl ZLIB
34 dnl ----
35 AC_MSG_CHECKING([for zlib.h])
36 ZLIB_DIR=
37 for i int "$PHP_HTTP_ZLIB_COMPRESSION" /user/local /usr /opt; do
38 if test -r "$i/include/zlib.h"; then
39 ZLIB_DIR=$i
40 break;
41 fi
42 done
43 if test -z "$ZLIB_DIR"; then
44 AC_MSG_RESULT([not found])
45 AC_MSG_WARNING([zlib support not enabled; zlib.h not found])
46 else
47 PHP_ADD_INCLUDE($ZLIB_DIR/include)
48 PHP_ADD_LIBRARY_WITH_PATH(libz, $ZLIB_DIR/$PHP_LIBDIR, HTTP_SHARED_LIBADD)
49 AC_DEFINE([HTTP_HAVE_ZLIB], [1], [Have zlib support])
50 fi
51
52 dnl ----
53 dnl CURL
54 dnl ----
55 if test "$PHP_HTTP_CURL_REQUESTS" != "no"; then
56
57 AC_MSG_CHECKING([for curl/curl.h])
58 CURL_DIR=
59 for i in "$PHP_HTTP_CURL_REQUESTS" /usr/local /usr /opt; do
60 if test -r "$i/include/curl/curl.h"; then
61 CURL_DIR=$i
62 break
63 fi
64 done
65 if test -z "$CURL_DIR"; then
66 AC_MSG_RESULT([not found])
67 AC_MSG_ERROR([could not find curl/curl.h])
68 else
69 AC_MSG_RESULT([found in $CURL_DIR])
70 fi
71
72 AC_MSG_CHECKING([for curl-config])
73 CURL_CONFIG=
74 for i in "$CURL_DIR/bin/curl-config" "$CURL_DIR/curl-config" `which curl-config`; do
75 if test -x "$i"; then
76 CURL_CONFIG=$i
77 break
78 fi
79 done
80 if test -z "$CURL_CONFIG"; then
81 AC_MSG_RESULT([not found])
82 AC_MSG_ERROR([could not find curl-config])
83 else
84 AC_MSG_RESULT([found: $CURL_CONFIG])
85 fi
86
87 CURL_SSL=`$CURL_CONFIG --features | $EGREP SSL`
88 if test "$CURL_SSL" == "SSL"; then
89 AC_DEFINE([HTTP_HAVE_SSL], [1], [ ])
90 fi
91 AC_CHECK_HEADERS([openssl/crypto.h])
92
93 CURL_LIBS=`$CURL_CONFIG --libs`
94
95 PHP_ADD_INCLUDE($CURL_DIR/include)
96 PHP_ADD_LIBRARY_WITH_PATH(curl, $CURL_DIR/$PHP_LIBDIR, HTTP_SHARED_LIBADD)
97 PHP_EVAL_LIBLINE($CURL_LIBS, HTTP_SHARED_LIBADD)
98 AC_DEFINE([HTTP_HAVE_CURL], [1], [Have cURL support])
99
100 PHP_CHECK_LIBRARY(curl, curl_multi_strerror,
101 [AC_DEFINE([HAVE_CURL_MULTI_STRERROR], [1], [ ])], [ ],
102 [$CURL_LIBS -L$CURL_DIR/$PHP_LIBDIR]
103 )
104 PHP_CHECK_LIBRARY(curl, curl_easy_strerror,
105 [AC_DEFINE([HAVE_CURL_EASY_STRERROR], [1], [ ])], [ ],
106 [$CURL_LIBS -L$CURL_DIR/$PHP_LIBDIR]
107 )
108 PHP_CHECK_LIBRARY(curl, curl_easy_reset,
109 [AC_DEFINE([HAVE_CURL_EASY_RESET], [1], [ ])], [ ],
110 [$CURL_LIBS -L$CURL_DIR/$PHP_LIBDIR]
111 )
112 fi
113
114 dnl ----
115 dnl MHASH
116 dnl ----
117 if test "$PHP_HTTP_MHASH_ETAGS" != "no"; then
118
119 AC_MSG_CHECKING([for mhash.h])
120 MHASH_DIR=
121 for i in "$PHP_HTTP_MHASH_ETAGS" /usr/local /usr /opt; do
122 if test -f "$i/include/mhash.h"; then
123 MHASH_DIR=$i
124 break
125 fi
126 done
127 if test -z "$MHASH_DIR"; then
128 AC_MSG_RESULT([not found])
129 AC_MSG_ERROR([could not find mhash.h])
130 else
131 AC_MSG_RESULT([found in $MHASH_DIR])
132 fi
133
134 PHP_ADD_INCLUDE($MHASH_DIR/include)
135 PHP_ADD_LIBRARY_WITH_PATH(mhash, $MHASH_DIR/$PHP_LIBDIR, HTTP_SHARED_LIBADD)
136 AC_DEFINE([HTTP_HAVE_MHASH], [1], [Have mhash support])
137 fi
138
139 dnl ----
140 dnl MAGIC
141 dnl ----
142 if test "$PHP_HTTP_MAGIC_MIME" != "no"; then
143
144 AC_MSG_CHECKING([for magic.h])
145 MAGIC_DIR=
146 for i in "$PHP_HTTP_MAGIC_MIME" /usr/local /usr /opt; do
147 if test -f "$i/include/magic.h"; then
148 MAGIC_DIR=$i
149 break
150 fi
151 done
152 if test -z "$MAGIC_DIR"; then
153 AC_MSG_RESULT([not found])
154 AC_MSG_ERROR([could not find magic.h])
155 else
156 AC_MSG_RESULT([found in $MAGIC_DIR])
157 fi
158
159 PHP_ADD_INCLUDE($MAGIC_DIR/include)
160 PHP_ADD_LIBRARY_WITH_PATH(magic, $MAGIC_DIR/$PHP_LIBDIR, HTTP_SHARED_LIBADD)
161 AC_DEFINE([HTTP_HAVE_MAGIC], [1], [Have magic mime support])
162 fi
163
164 dnl ----
165 dnl DONE
166 dnl ----
167 PHP_HTTP_SOURCES="missing.c http.c http_functions.c phpstr/phpstr.c \
168 http_util_object.c http_message_object.c http_request_object.c http_request_pool_api.c \
169 http_response_object.c http_exception_object.c http_requestpool_object.c \
170 http_api.c http_cache_api.c http_request_api.c http_date_api.c \
171 http_headers_api.c http_message_api.c http_send_api.c http_url_api.c \
172 http_info_api.c http_request_method_api.c http_encoding_api.c"
173 PHP_NEW_EXTENSION([http], $PHP_HTTP_SOURCES, [$ext_shared])
174 PHP_ADD_BUILD_DIR($ext_builddir/phpstr, 1)
175 PHP_SUBST([HTTP_SHARED_LIBADD])
176
177 HTTP_HEADER_FILES="php_http_std_defs.h php_http.h php_http_api.h php_http_cache_api.h \
178 php_http_date_api.h php_http_headers_api.h php_http_info_api.h php_http_message_api.h \
179 php_http_request_api.h php_http_request_method_api.h php_http_send_api.h php_http_url_api.h \
180 php_http_encodig_api.h"
181 PHP_SUBST([HTTP_HEADER_FILES])
182
183 ifdef([PHP_INSTALL_HEADERS],
184 [
185 PHP_INSTALL_HEADERS(ext/http, $HTTP_HEADER_FILES)
186 PHP_INSTALL_HEADERS(ext/http/phpstr, [phpstr/phpstr.h])
187 ], [
188 PHP_ADD_MAKEFILE_FRAGMENT
189 ])
190
191 AC_DEFINE([HAVE_HTTP], [1], [Have extended HTTP support])
192 fi