configure.ac 6.0 KB

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