configure.ac 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. AC_INIT([isync], [1.3.5])
  2. AC_CONFIG_HEADERS([autodefs.h])
  3. AM_INIT_AUTOMAKE
  4. AM_MAINTAINER_MODE
  5. AC_PROG_CC_C99
  6. if test "$GCC" = yes; then
  7. CFLAGS="$CFLAGS -pipe -W -Wall -Wshadow -Wstrict-prototypes -std=c99 -pedantic -Wno-overlength-strings"
  8. fi
  9. CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
  10. AC_CHECK_PROG(PERL, perl, perl)
  11. if test "x$PERL" = "x"; then
  12. AC_MSG_ERROR([perl not found])
  13. fi
  14. need_perl=5.14
  15. AC_CACHE_CHECK([whether perl is recent enough], ob_cv_perl_ver, [
  16. if $PERL -e "use v$need_perl;" 2> /dev/null; then
  17. ob_cv_perl_ver=yes
  18. else
  19. ob_cv_perl_ver=no
  20. fi
  21. ])
  22. if test "x$ob_cv_perl_ver" = "xno"; then
  23. AC_MSG_ERROR([perl is too old, need v$need_perl])
  24. fi
  25. AC_CACHE_CHECK([whether strftime supports %z], ob_cv_strftime_z,
  26. [AC_TRY_RUN(
  27. [#include <time.h>
  28. #include <string.h>
  29. int main(void)
  30. {
  31. time_t t = 0;
  32. char buf[32];
  33. strftime(buf, sizeof(buf), "%z", localtime(&t));
  34. return !(buf[0] == '+' || buf[0] == '-');
  35. }
  36. ], [ob_cv_strftime_z=yes], [ob_cv_strftime_z=no], [ob_cv_strftime_z="yes (assumed)"])])
  37. if test "x$ob_cv_strftime_z" = x"no"; then
  38. AC_MSG_ERROR([libc lacks necessary feature])
  39. fi
  40. AC_CHECK_HEADERS(sys/poll.h sys/select.h)
  41. AC_CHECK_FUNCS(vasprintf strnlen memrchr timegm)
  42. AC_CHECK_LIB(socket, socket, [SOCK_LIBS="-lsocket"])
  43. AC_CHECK_LIB(nsl, inet_ntoa, [SOCK_LIBS="$SOCK_LIBS -lnsl"])
  44. AC_SUBST(SOCK_LIBS)
  45. have_ipv6=true
  46. sav_LIBS=$LIBS
  47. LIBS="$LIBS $SOCK_LIBS"
  48. AC_CHECK_FUNCS(getaddrinfo inet_ntop, , [have_ipv6=false])
  49. LIBS=$sav_LIBS
  50. if $have_ipv6; then
  51. AC_DEFINE(HAVE_IPV6, 1, [if your libc has IPv6 support])
  52. fi
  53. have_ssl_paths=
  54. AC_ARG_WITH(ssl,
  55. AC_HELP_STRING([--with-ssl[=PATH]], [where to look for SSL [detect]]),
  56. [ob_cv_with_ssl=$withval])
  57. if test "x$ob_cv_with_ssl" != xno; then
  58. case $ob_cv_with_ssl in
  59. ""|yes)
  60. dnl Detect the pkg-config tool, as it may have extra info about the openssl
  61. dnl installation we can use. I *believe* this is what we are expected to do
  62. dnl on really recent Redhat Linux hosts.
  63. PKG_PROG_PKG_CONFIG
  64. if test "x$PKG_CONFIG" != "x" ; then
  65. AC_MSG_CHECKING([OpenSSL presence with pkg-config])
  66. if $PKG_CONFIG --exists openssl; then
  67. SSL_LIBS=`$PKG_CONFIG --libs-only-l openssl`
  68. SSL_LDFLAGS=`$PKG_CONFIG --libs-only-L openssl`
  69. SSL_CPPFLAGS=`$PKG_CONFIG --cflags-only-I openssl`
  70. have_ssl_paths=yes
  71. AC_MSG_RESULT([found])
  72. else
  73. AC_MSG_RESULT([not found])
  74. fi
  75. fi
  76. ;;
  77. *)
  78. SSL_LDFLAGS=-L$ob_cv_with_ssl/lib$libsuff
  79. SSL_CPPFLAGS=-I$ob_cv_with_ssl/include
  80. ;;
  81. esac
  82. if test -z "$have_ssl_paths"; then
  83. sav_LDFLAGS=$LDFLAGS
  84. LDFLAGS="$LDFLAGS $SSL_LDFLAGS"
  85. AC_CHECK_LIB(dl, dlopen, [LIBDL=-ldl])
  86. AC_CHECK_LIB(crypto, X509_cmp, [LIBCRYPTO=-lcrypto])
  87. AC_CHECK_LIB(ssl, SSL_connect,
  88. [SSL_LIBS="-lssl $LIBCRYPTO $LIBDL" have_ssl_paths=yes])
  89. LDFLAGS=$sav_LDFLAGS
  90. fi
  91. sav_CPPFLAGS=$CPPFLAGS
  92. CPPFLAGS="$CPPFLAGS $SSL_CPPFLAGS"
  93. AC_CHECK_HEADER(openssl/ssl.h, , [have_ssl_paths=])
  94. CPPFLAGS=$sav_CPPFLAGS
  95. if test -z "$have_ssl_paths"; then
  96. if test -n "$ob_cv_with_ssl"; then
  97. AC_MSG_ERROR([OpenSSL libs and/or includes were not found where specified])
  98. fi
  99. else
  100. AC_DEFINE(HAVE_LIBSSL, 1, [if you have the OpenSSL libraries])
  101. CPPFLAGS="$CPPFLAGS $SSL_CPPFLAGS"
  102. LDFLAGS="$LDFLAGS $SSL_LDFLAGS"
  103. fi
  104. fi
  105. AC_SUBST(SSL_LIBS)
  106. have_sasl_paths=
  107. AC_ARG_WITH(sasl,
  108. AS_HELP_STRING([--with-sasl[=PATH]], [where to look for SASL [detect]]),
  109. [ob_cv_with_sasl=$withval])
  110. if test "x$ob_cv_with_sasl" != xno; then
  111. case $ob_cv_with_sasl in
  112. ""|yes)
  113. dnl FIXME: Try various possible paths here...
  114. ;;
  115. *)
  116. SASL_LDFLAGS=-L$ob_cv_with_sasl/lib$libsuff
  117. SASL_CPPFLAGS=-I$ob_cv_with_sasl/include
  118. ;;
  119. esac
  120. if test -z "$have_sasl_paths"; then
  121. sav_LDFLAGS=$LDFLAGS
  122. LDFLAGS="$LDFLAGS $SASL_LDFLAGS"
  123. AC_CHECK_LIB(sasl2, sasl_client_init,
  124. [SASL_LIBS="-lsasl2" have_sasl_paths=yes])
  125. LDFLAGS=$sav_LDFLAGS
  126. fi
  127. sav_CPPFLAGS=$CPPFLAGS
  128. CPPFLAGS="$CPPFLAGS $SASL_CPPFLAGS"
  129. AC_CHECK_HEADER(sasl/sasl.h, , [have_sasl_paths=])
  130. CPPFLAGS=$sav_CPPFLAGS
  131. if test -z "$have_sasl_paths"; then
  132. if test -n "$ob_cv_with_sasl"; then
  133. AC_MSG_ERROR([SASL libs and/or includes were not found where specified])
  134. fi
  135. else
  136. AC_DEFINE(HAVE_LIBSASL, 1, [if you have the SASL libraries])
  137. CPPFLAGS="$CPPFLAGS $SASL_CPPFLAGS"
  138. LDFLAGS="$LDFLAGS $SASL_LDFLAGS"
  139. fi
  140. fi
  141. AC_SUBST(SASL_LIBS)
  142. AC_CACHE_CHECK([for Berkeley DB >= 4.1], ac_cv_berkdb4,
  143. [ac_cv_berkdb4=no
  144. sav_LIBS=$LIBS
  145. LIBS="$LIBS -ldb"
  146. AC_TRY_LINK([#include <db.h>],
  147. [DB *db;
  148. db_create(&db, 0, 0);
  149. db->truncate(db, 0, 0, 0);
  150. db->open(db, 0, "foo", "foo", DB_HASH, DB_CREATE, 0)],
  151. [ac_cv_berkdb4=yes])
  152. LIBS=$sav_LIBS
  153. ])
  154. if test "x$ac_cv_berkdb4" = xyes; then
  155. AC_SUBST([DB_LIBS], ["-ldb"])
  156. AC_DEFINE(USE_DB, 1, [if Berkeley DB should be used])
  157. fi
  158. have_zlib=
  159. AC_ARG_WITH(zlib,
  160. AS_HELP_STRING([--with-zlib], [use zlib [detect]]),
  161. [ob_cv_with_zlib=$withval])
  162. if test "x$ob_cv_with_zlib" != xno; then
  163. AC_CHECK_LIB([z], [deflate],
  164. [AC_CHECK_HEADER(zlib.h,
  165. [have_zlib=1
  166. AC_SUBST([Z_LIBS], ["-lz"])
  167. AC_DEFINE([HAVE_LIBZ], 1, [if you have the zlib library])]
  168. )]
  169. )
  170. fi
  171. AC_ARG_ENABLE(compat,
  172. AC_HELP_STRING([--disable-compat], [don't include isync compatibility wrapper [no]]),
  173. [ob_cv_enable_compat=$enableval])
  174. if test "x$ob_cv_enable_compat" != xno; then
  175. AC_CHECK_FUNCS(getopt_long)
  176. fi
  177. AM_CONDITIONAL(with_compat, test "x$ob_cv_enable_compat" != xno -a "x$ac_cv_berkdb4" = xyes)
  178. AM_CONDITIONAL(with_mdconvert, test "x$ac_cv_berkdb4" = xyes)
  179. AC_CONFIG_FILES([Makefile src/Makefile src/compat/Makefile isync.spec])
  180. AC_OUTPUT
  181. AC_MSG_RESULT()
  182. if test -n "$have_ssl_paths"; then
  183. AC_MSG_RESULT([Using SSL])
  184. else
  185. AC_MSG_RESULT([Not using SSL])
  186. fi
  187. if test -n "$have_sasl_paths"; then
  188. AC_MSG_RESULT([Using SASL])
  189. else
  190. AC_MSG_RESULT([Not using SASL])
  191. fi
  192. if test -n "$have_zlib"; then
  193. AC_MSG_RESULT([Using zlib])
  194. else
  195. AC_MSG_RESULT([Not using zlib])
  196. fi
  197. if test "x$ac_cv_berkdb4" = xyes; then
  198. AC_MSG_RESULT([Using Berkeley DB])
  199. else
  200. AC_MSG_RESULT([Not using Berkeley DB])
  201. fi
  202. AC_MSG_RESULT()