configure.ac 5.9 KB

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