config.m4 8.6 KB

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