configure.ac 7.5 KB

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