configure.ac 7.6 KB

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