5 AC_DEFUN([IMAP_INC_CHK],[if test -r "$i$1/c-client.h"; then
6 AC_DEFINE(HAVE_IMAP2000, 1, [ ])
10 elif test -r "$i$1/rfc822.h"; then
16 AC_DEFUN([IMAP_LIB_CHK],[
17 str="$IMAP_DIR/$1/lib$lib.*"
18 for i in `echo $str`; do
19 test -r $i && IMAP_LIBDIR=$IMAP_DIR/$1 && break 2
23 dnl PHP_IMAP_TEST_BUILD(function, action-if-ok, action-if-not-ok, extra-libs)
24 AC_DEFUN([PHP_IMAP_TEST_BUILD], [
25 PHP_TEST_BUILD([$1], [$2], [$3], [$4],
27 #if defined(__GNUC__) && __GNUC__ >= 4
28 # define PHP_IMAP_EXPORT __attribute__ ((visibility("default")))
30 # define PHP_IMAP_EXPORT
33 PHP_IMAP_EXPORT void mm_log(void){}
34 PHP_IMAP_EXPORT void mm_dlog(void){}
35 PHP_IMAP_EXPORT void mm_flags(void){}
36 PHP_IMAP_EXPORT void mm_fatal(void){}
37 PHP_IMAP_EXPORT void mm_critical(void){}
38 PHP_IMAP_EXPORT void mm_nocritical(void){}
39 PHP_IMAP_EXPORT void mm_notify(void){}
40 PHP_IMAP_EXPORT void mm_login(void){}
41 PHP_IMAP_EXPORT void mm_diskerror(void){}
42 PHP_IMAP_EXPORT void mm_status(void){}
43 PHP_IMAP_EXPORT void mm_lsub(void){}
44 PHP_IMAP_EXPORT void mm_list(void){}
45 PHP_IMAP_EXPORT void mm_exists(void){}
46 PHP_IMAP_EXPORT void mm_searched(void){}
47 PHP_IMAP_EXPORT void mm_expunged(void){}
51 AC_DEFUN([PHP_IMAP_KRB_CHK], [
52 if test "$PHP_KERBEROS" != "no"; then
53 PHP_SETUP_KERBEROS(IMAP_SHARED_LIBADD,
55 AC_DEFINE(HAVE_IMAP_KRB,1,[ ])
57 AC_MSG_ERROR([Kerberos libraries not found.
59 Check the path given to --with-kerberos (if no path is given, searches in /usr/kerberos, /usr/local and /usr )
63 AC_EGREP_HEADER(auth_gss, $IMAP_INC_DIR/linkage.h, [
64 AC_MSG_ERROR([This c-client library is built with Kerberos support.
66 Add --with-kerberos to your configure line. Check config.log for details.
72 AC_DEFUN([PHP_IMAP_SSL_CHK], [
73 if test "$PHP_IMAP_SSL" != "no"; then
74 if test "$PHP_OPENSSL" = ""; then
77 PHP_SETUP_OPENSSL(IMAP_SHARED_LIBADD,
79 AC_DEFINE(HAVE_IMAP_SSL,1,[ ])
81 AC_MSG_ERROR([OpenSSL libraries not found.
83 Check the path given to --with-openssl-dir and output in config.log)
86 elif test -f "$IMAP_INC_DIR/linkage.c"; then
87 AC_EGREP_HEADER(ssl_onceonlyinit, $IMAP_INC_DIR/linkage.c, [
88 AC_MSG_ERROR([This c-client library is built with SSL support.
90 Add --with-imap-ssl to your configure line. Check config.log for details.
97 PHP_ARG_WITH(imap,for IMAP support,
98 [ --with-imap[=DIR] Include IMAP support. DIR is the c-client install prefix])
100 PHP_ARG_WITH(kerberos,for IMAP Kerberos support,
101 [ --with-kerberos[=DIR] IMAP: Include Kerberos support. DIR is the Kerberos install prefix], no, no)
103 PHP_ARG_WITH(imap-ssl,for IMAP SSL support,
104 [ --with-imap-ssl[=DIR] IMAP: Include SSL support. DIR is the OpenSSL install prefix], no, no)
107 if test "$PHP_IMAP" != "no"; then
108 PHP_SUBST(IMAP_SHARED_LIBADD)
109 PHP_NEW_EXTENSION(imap, php_imap.c, $ext_shared)
110 AC_DEFINE(HAVE_IMAP,1,[ ])
112 for i in $PHP_IMAP /usr/local /usr; do
114 el[]IMAP_INC_CHK(/include/c-client)
115 el[]IMAP_INC_CHK(/include/imap)
116 el[]IMAP_INC_CHK(/include)
117 el[]IMAP_INC_CHK(/imap)
118 el[]IMAP_INC_CHK(/c-client)
122 dnl Check for c-client version 2004
123 AC_EGREP_HEADER(mail_fetch_overview_sequence, $IMAP_INC_DIR/mail.h, [
124 AC_DEFINE(HAVE_IMAP2004,1,[ ])
127 dnl Check for new version of the utf8_mime2text() function
129 CFLAGS="-I$IMAP_INC_DIR"
130 AC_CACHE_CHECK(for utf8_mime2text signature, ac_cv_utf8_mime2text,
133 #include <c-client.h>
135 SIZEDTEXT *src, *dst;
136 utf8_mime2text(src, dst);
138 ac_cv_utf8_mime2text=old
140 ac_cv_utf8_mime2text=new
143 if test "$ac_cv_utf8_mime2text" = "new"; then
144 AC_DEFINE(HAVE_NEW_MIME2TEXT, 1, [Whether utf8_mime2text() has new signature])
149 CFLAGS="-I$IMAP_INC_DIR"
150 AC_CACHE_CHECK(for U8T_DECOMPOSE, ac_cv_u8t_canonical,
152 #include <c-client.h>
154 int i = U8T_CANONICAL;
156 ac_cv_u8t_decompose=yes
158 ac_cv_u8t_decompose=no
163 if test "$ac_cv_u8t_decompose" = "no" && test "$ac_cv_utf8_mime2text" = "new"; then
164 AC_MSG_ERROR([utf8_mime2text() has new signature, but U8T_CANONICAL is missing. This should not happen. Check config.log for additional information.])
166 if test "$ac_cv_u8t_decompose" = "yes" && test "$ac_cv_utf8_mime2text" = "old"; then
167 AC_MSG_ERROR([utf8_mime2text() has old signature, but U8T_CANONICAL is present. This should not happen. Check config.log for additional information.])
170 dnl Check for c-client version 2001
171 old_CPPFLAGS=$CPPFLAGS
172 CPPFLAGS=-I$IMAP_INC_DIR
173 AC_EGREP_CPP(this_is_true, [
175 #if defined(IMAPSSLPORT)
179 AC_DEFINE(HAVE_IMAP2001, 1, [ ])
181 CPPFLAGS=$old_CPPFLAGS
183 PHP_CHECK_LIBRARY(pam, pam_start,
185 PHP_ADD_LIBRARY(pam,, IMAP_SHARED_LIBADD)
186 AC_DEFINE(HAVE_LIBPAM,1,[ ])
189 PHP_CHECK_LIBRARY(crypt, crypt,
191 PHP_ADD_LIBRARY(crypt,, IMAP_SHARED_LIBADD)
192 AC_DEFINE(HAVE_LIBCRYPT,1,[ ])
195 PHP_EXPAND_PATH($IMAP_DIR, IMAP_DIR)
197 if test -z "$IMAP_DIR"; then
198 AC_MSG_ERROR(Cannot find rfc822.h. Please check your c-client installation.)
201 if test -r "$IMAP_DIR/c-client/c-client.a"; then
202 ln -s "$IMAP_DIR/c-client/c-client.a" "$IMAP_DIR/c-client/libc-client.a" >/dev/null 2>&1
203 elif test -r "$IMAP_DIR/$PHP_LIBDIR/c-client.a"; then
204 ln -s "$IMAP_DIR/$PHP_LIBDIR/c-client.a" "$IMAP_DIR/$PHP_LIBDIR/libc-client.a" >/dev/null 2>&1
207 for lib in c-client4 c-client imap; do
209 IMAP_LIB_CHK($PHP_LIBDIR)
210 IMAP_LIB_CHK(c-client)
213 if test -z "$IMAP_LIBDIR"; then
214 AC_MSG_ERROR(Cannot find imap library (libc-client.a). Please check your c-client installation.)
217 PHP_ADD_INCLUDE($IMAP_INC_DIR)
218 PHP_ADD_LIBRARY_DEFER($IMAP_LIB,, IMAP_SHARED_LIBADD)
219 PHP_ADD_LIBPATH($IMAP_LIBDIR, IMAP_SHARED_LIBADD)
223 dnl Test the build in the end
224 TST_LIBS="$DLIBS $IMAP_SHARED_LIBADD"
226 dnl Check if auth_gss exists
227 PHP_IMAP_TEST_BUILD(auth_gssapi_valid, [
228 AC_DEFINE(HAVE_IMAP_AUTH_GSS, 1, [ ])
231 dnl Check if utf8_to_mutf7 exists
232 PHP_IMAP_TEST_BUILD(utf8_to_mutf7, [
233 AC_DEFINE(HAVE_IMAP_MUTF7, 1, [ ])
236 AC_MSG_CHECKING(whether rfc822_output_address_list function present)
237 PHP_TEST_BUILD(foobar, [
239 AC_DEFINE(HAVE_RFC822_OUTPUT_ADDRESS_LIST, 1, [ ])
245 #if defined(__GNUC__) && __GNUC__ >= 4
246 # define PHP_IMAP_EXPORT __attribute__ ((visibility("default")))
248 # define PHP_IMAP_EXPORT
251 PHP_IMAP_EXPORT void mm_log(void){}
252 PHP_IMAP_EXPORT void mm_dlog(void){}
253 PHP_IMAP_EXPORT void mm_flags(void){}
254 PHP_IMAP_EXPORT void mm_fatal(void){}
255 PHP_IMAP_EXPORT void mm_critical(void){}
256 PHP_IMAP_EXPORT void mm_nocritical(void){}
257 PHP_IMAP_EXPORT void mm_notify(void){}
258 PHP_IMAP_EXPORT void mm_login(void){}
259 PHP_IMAP_EXPORT void mm_diskerror(void){}
260 PHP_IMAP_EXPORT void mm_status(void){}
261 PHP_IMAP_EXPORT void mm_lsub(void){}
262 PHP_IMAP_EXPORT void mm_list(void){}
263 PHP_IMAP_EXPORT void mm_exists(void){}
264 PHP_IMAP_EXPORT void mm_searched(void){}
265 PHP_IMAP_EXPORT void mm_expunged(void){}
266 void rfc822_output_address_list(void);
268 char foobar () {f = rfc822_output_address_list;}
271 AC_MSG_CHECKING(whether build with IMAP works)
272 PHP_IMAP_TEST_BUILD(mail_newbody, [
276 AC_MSG_ERROR([build test failed. Please check the config.log for details.])