1AC_DEFUN([IMAP_INC_CHK],[if test -r "$i$1/c-client.h"; then 2 AC_DEFINE(HAVE_IMAP2000, 1, [ ]) 3 IMAP_DIR=$i 4 IMAP_INC_DIR=$i$1 5 break 6 elif test -r "$i$1/rfc822.h"; then 7 IMAP_DIR=$i; 8 IMAP_INC_DIR=$i$1 9 break 10]) 11 12AC_DEFUN([IMAP_LIB_CHK],[ 13 str="$IMAP_DIR/$1/lib$lib.*" 14 for i in `echo $str`; do 15 test -r $i && IMAP_LIBDIR=$IMAP_DIR/$1 && break 2 16 done 17]) 18 19dnl PHP_IMAP_TEST_BUILD(function, action-if-ok, action-if-not-ok, extra-libs, extra-source) 20AC_DEFUN([PHP_IMAP_TEST_BUILD], [ 21 PHP_TEST_BUILD([$1], [$2], [$3], [$4], [$5] 22 [ 23#if defined(__GNUC__) && __GNUC__ >= 4 24# define PHP_IMAP_EXPORT __attribute__ ((visibility("default"))) 25#else 26# define PHP_IMAP_EXPORT 27#endif 28 29 PHP_IMAP_EXPORT void mm_log(void){} 30 PHP_IMAP_EXPORT void mm_dlog(void){} 31 PHP_IMAP_EXPORT void mm_flags(void){} 32 PHP_IMAP_EXPORT void mm_fatal(void){} 33 PHP_IMAP_EXPORT void mm_critical(void){} 34 PHP_IMAP_EXPORT void mm_nocritical(void){} 35 PHP_IMAP_EXPORT void mm_notify(void){} 36 PHP_IMAP_EXPORT void mm_login(void){} 37 PHP_IMAP_EXPORT void mm_diskerror(void){} 38 PHP_IMAP_EXPORT void mm_status(void){} 39 PHP_IMAP_EXPORT void mm_lsub(void){} 40 PHP_IMAP_EXPORT void mm_list(void){} 41 PHP_IMAP_EXPORT void mm_exists(void){} 42 PHP_IMAP_EXPORT void mm_searched(void){} 43 PHP_IMAP_EXPORT void mm_expunged(void){} 44 ]) 45]) 46 47AC_DEFUN([PHP_IMAP_KRB_CHK], [ 48 if test "$PHP_KERBEROS" != "no"; then 49 PKG_CHECK_MODULES([KERBEROS], [krb5-gssapi krb5]) 50 51 PHP_EVAL_INCLINE($KERBEROS_CFLAGS) 52 PHP_EVAL_LIBLINE($KERBEROS_LIBS, IMAP_SHARED_LIBADD) 53 54 AC_DEFINE(HAVE_IMAP_KRB, 1, [Whether IMAP extension has Kerberos support]) 55 else 56 AC_EGREP_HEADER(auth_gss, $IMAP_INC_DIR/linkage.h, [ 57 AC_MSG_ERROR([This c-client library is built with Kerberos support. 58 59 Add --with-kerberos to your configure line. Check config.log for details. 60 ]) 61 ]) 62 fi 63]) 64 65AC_DEFUN([PHP_IMAP_SSL_CHK], [ 66 if test "$PHP_IMAP_SSL" != "no"; then 67 if test "$PHP_OPENSSL" = ""; then 68 PHP_OPENSSL='no' 69 fi 70 PHP_SETUP_OPENSSL(IMAP_SHARED_LIBADD, 71 [ 72 AC_DEFINE(HAVE_IMAP_SSL,1,[ ]) 73 ], [ 74 AC_MSG_ERROR([OpenSSL libraries not found. 75 76 Check whether openssl is on your PKG_CONFIG_PATH and the output in config.log) 77 ]) 78 ]) 79 elif test -f "$IMAP_INC_DIR/linkage.c"; then 80 AC_EGREP_HEADER(ssl_onceonlyinit, $IMAP_INC_DIR/linkage.c, [ 81 AC_MSG_ERROR([This c-client library is built with SSL support. 82 83 Add --with-imap-ssl to your configure line. Check config.log for details. 84 ]) 85 ]) 86 fi 87]) 88 89PHP_ARG_WITH([imap], 90 [for IMAP support], 91 [AS_HELP_STRING([[--with-imap[=DIR]]], 92 [Include IMAP support. DIR is the c-client install prefix])]) 93 94PHP_ARG_WITH([kerberos], 95 [for IMAP Kerberos support], 96 [AS_HELP_STRING([--with-kerberos], 97 [IMAP: Include Kerberos support])], 98 [no], 99 [no]) 100 101PHP_ARG_WITH([imap-ssl], 102 [for IMAP SSL support], 103 [AS_HELP_STRING([[--with-imap-ssl]], 104 [IMAP: Include SSL support])], 105 [no], 106 [no]) 107 108if test "$PHP_IMAP" != "no"; then 109 PHP_SUBST(IMAP_SHARED_LIBADD) 110 PHP_NEW_EXTENSION(imap, php_imap.c, $ext_shared,, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1) 111 AC_DEFINE(HAVE_IMAP,1,[ ]) 112 113 for i in $PHP_IMAP /usr/local /usr; do 114 IMAP_INC_CHK() 115 el[]IMAP_INC_CHK(/include/c-client) 116 el[]IMAP_INC_CHK(/include/imap) 117 el[]IMAP_INC_CHK(/include) 118 el[]IMAP_INC_CHK(/imap) 119 el[]IMAP_INC_CHK(/c-client) 120 fi 121 done 122 123 dnl Check for c-client version 2004 124 AC_EGREP_HEADER(mail_fetch_overview_sequence, $IMAP_INC_DIR/mail.h, [ 125 AC_DEFINE(HAVE_IMAP2004,1,[ ]) 126 ]) 127 128 dnl Check for new version of the utf8_mime2text() function 129 old_CFLAGS=$CFLAGS 130 CFLAGS="-I$IMAP_INC_DIR" 131 AC_CACHE_CHECK(for utf8_mime2text signature, ac_cv_utf8_mime2text, 132 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 133#include <stdio.h> 134#include <c-client.h> 135 ]],[[ 136 SIZEDTEXT *src, *dst; 137 utf8_mime2text(src, dst); 138 ]])],[ 139 ac_cv_utf8_mime2text=old 140 ],[ 141 ac_cv_utf8_mime2text=new 142 ]) 143 ) 144 if test "$ac_cv_utf8_mime2text" = "new"; then 145 AC_DEFINE(HAVE_NEW_MIME2TEXT, 1, [Whether utf8_mime2text() has new signature]) 146 fi 147 CFLAGS=$old_CFLAGS 148 149 old_CFLAGS=$CFLAGS 150 CFLAGS="-I$IMAP_INC_DIR" 151 AC_CACHE_CHECK(for U8T_DECOMPOSE, ac_cv_u8t_decompose, 152 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 153#include <c-client.h> 154 ]],[[ 155 int i = U8T_CANONICAL; 156 ]])],[ 157 ac_cv_u8t_decompose=yes 158 ],[ 159 ac_cv_u8t_decompose=no 160 ]) 161 ) 162 CFLAGS=$old_CFLAGS 163 164 if test "$ac_cv_u8t_decompose" = "no" && test "$ac_cv_utf8_mime2text" = "new"; then 165 AC_MSG_ERROR([utf8_mime2text() has new signature, but U8T_CANONICAL is missing. This should not happen. Check config.log for additional information.]) 166 fi 167 if test "$ac_cv_u8t_decompose" = "yes" && test "$ac_cv_utf8_mime2text" = "old"; then 168 AC_MSG_ERROR([utf8_mime2text() has old signature, but U8T_CANONICAL is present. This should not happen. Check config.log for additional information.]) 169 fi 170 171 dnl Check for c-client version 2001 172 old_CPPFLAGS=$CPPFLAGS 173 CPPFLAGS=-I$IMAP_INC_DIR 174 AC_EGREP_CPP(this_is_true, [ 175#include "imap4r1.h" 176#if defined(IMAPSSLPORT) 177 this_is_true 178#endif 179 ],[ 180 AC_DEFINE(HAVE_IMAP2001, 1, [ ]) 181 ],[]) 182 CPPFLAGS=$old_CPPFLAGS 183 184 PHP_CHECK_LIBRARY(pam, pam_start, 185 [ 186 PHP_ADD_LIBRARY(pam,, IMAP_SHARED_LIBADD) 187 AC_DEFINE(HAVE_LIBPAM,1,[ ]) 188 ]) 189 190 PHP_CHECK_LIBRARY(crypt, crypt, 191 [ 192 PHP_ADD_LIBRARY(crypt,, IMAP_SHARED_LIBADD) 193 AC_DEFINE(HAVE_LIBCRYPT,1,[ ]) 194 ]) 195 196 PHP_EXPAND_PATH($IMAP_DIR, IMAP_DIR) 197 198 if test -z "$IMAP_DIR"; then 199 AC_MSG_ERROR(Cannot find rfc822.h. Please check your c-client installation.) 200 fi 201 202 if test ! -r "$IMAP_DIR/c-client/libc-client.a" && test -r "$IMAP_DIR/c-client/c-client.a" ; then 203 ln -s "$IMAP_DIR/c-client/c-client.a" "$IMAP_DIR/c-client/libc-client.a" >/dev/null 2>&1 204 elif test ! -r "$IMAP_DIR/$PHP_LIBDIR/libc-client.a" && test -r "$IMAP_DIR/$PHP_LIBDIR/c-client.a"; then 205 ln -s "$IMAP_DIR/$PHP_LIBDIR/c-client.a" "$IMAP_DIR/$PHP_LIBDIR/libc-client.a" >/dev/null 2>&1 206 fi 207 208 for lib in c-client4 c-client imap; do 209 IMAP_LIB=$lib 210 IMAP_LIB_CHK($PHP_LIBDIR) 211 IMAP_LIB_CHK(c-client) 212 done 213 214 if test -z "$IMAP_LIBDIR"; then 215 AC_MSG_ERROR(Cannot find imap library (libc-client.a). Please check your c-client installation.) 216 fi 217 218 PHP_ADD_INCLUDE($IMAP_INC_DIR) 219 PHP_ADD_LIBRARY_DEFER($IMAP_LIB,, IMAP_SHARED_LIBADD) 220 PHP_ADD_LIBPATH($IMAP_LIBDIR, IMAP_SHARED_LIBADD) 221 PHP_IMAP_KRB_CHK 222 PHP_IMAP_SSL_CHK 223 224 dnl Test the build in the end 225 TST_LIBS="$DLIBS $IMAP_SHARED_LIBADD" 226 227 dnl Check if auth_gss exists 228 PHP_IMAP_TEST_BUILD(auth_gssapi_valid, [ 229 AC_DEFINE(HAVE_IMAP_AUTH_GSS, 1, [ ]) 230 ], [], $TST_LIBS) 231 232 dnl Check if utf8_to_mutf7 exists. We need to do some gymnastics because 233 dnl utf8_to_mutf7 takes an argument and will segfault without it. We 234 dnl therefore test another function utf8_to_mutf7_php() which calls 235 dnl the utf8_to_mutf7() function with the empty string as an argument. 236 PHP_IMAP_TEST_BUILD(utf8_to_mutf7_php, [ 237 AC_DEFINE(HAVE_IMAP_MUTF7, 1, [ ]) 238 ], [], $TST_LIBS, [ 239 char utf8_to_mutf7_php(){ return utf8_to_mutf7(""); } 240 ]) 241 242 AC_MSG_CHECKING(whether rfc822_output_address_list function present) 243 PHP_TEST_BUILD(foobar, [ 244 AC_MSG_RESULT(yes) 245 AC_DEFINE(HAVE_RFC822_OUTPUT_ADDRESS_LIST, 1, [ ]) 246 ], [ 247 AC_MSG_RESULT(no) 248 ], [ 249 $TST_LIBS 250 ], [ 251#if defined(__GNUC__) && __GNUC__ >= 4 252# define PHP_IMAP_EXPORT __attribute__ ((visibility("default"))) 253#else 254# define PHP_IMAP_EXPORT 255#endif 256 257 PHP_IMAP_EXPORT void mm_log(void){} 258 PHP_IMAP_EXPORT void mm_dlog(void){} 259 PHP_IMAP_EXPORT void mm_flags(void){} 260 PHP_IMAP_EXPORT void mm_fatal(void){} 261 PHP_IMAP_EXPORT void mm_critical(void){} 262 PHP_IMAP_EXPORT void mm_nocritical(void){} 263 PHP_IMAP_EXPORT void mm_notify(void){} 264 PHP_IMAP_EXPORT void mm_login(void){} 265 PHP_IMAP_EXPORT void mm_diskerror(void){} 266 PHP_IMAP_EXPORT void mm_status(void){} 267 PHP_IMAP_EXPORT void mm_lsub(void){} 268 PHP_IMAP_EXPORT void mm_list(void){} 269 PHP_IMAP_EXPORT void mm_exists(void){} 270 PHP_IMAP_EXPORT void mm_searched(void){} 271 PHP_IMAP_EXPORT void mm_expunged(void){} 272 void rfc822_output_address_list(void); 273 void (*f)(void); 274 char foobar () {f = rfc822_output_address_list;} 275 ]) 276 277 AC_MSG_CHECKING(whether build with IMAP works) 278 PHP_IMAP_TEST_BUILD(mail_newbody, [ 279 AC_MSG_RESULT(yes) 280 ], [ 281 AC_MSG_RESULT(no) 282 AC_MSG_ERROR([build test failed. Please check the config.log for details.]) 283 ], $TST_LIBS) 284fi 285