configure.ac 6.8 KB

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