configure.ac 7.3 KB

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