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