config.m4 8.7 KB

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