config.m4 8.6 KB

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