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