libetpan - fdik
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

786 lines
24 KiB

10 years ago
7 years ago
10 years ago
9 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
8 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
  1. # -*- Autoconf -*-
  2. # Process this file with autoconf to produce a configure script.
  3. m4_define([maj_version], [1])
  4. m4_define([min_version], [6])
  5. m4_define([api_current], [18])
  6. m4_define([api_revision], [0])
  7. m4_define([api_compatibility], [17])
  8. dnl API version
  9. dnl 1. If you have changed any of the sources for this library, the revision
  10. dnl number must be incremented. This is a new revision of the current
  11. dnl interface.
  12. dnl 2. If the interface has changed, then current must be incremented, and
  13. dnl revision reset to `0'. This is the first revision of a new interface.
  14. dnl 3. If the new interface is a superset of the previous interface (that is,
  15. dnl if the previous interface has not been broken by the changes in this new
  16. dnl release), then age must be incremented. This release is backwards
  17. dnl compatible with the previous release.
  18. dnl 4. If the new interface has removed elements with respect to the previous
  19. dnl interface, then you have broken backward compatibility and age must be
  20. dnl reset to `0'. This release has a new, but backwards incompatible
  21. dnl interface.
  22. dnl age = api_current - api_compatiblity
  23. AC_PREREQ(2.61)
  24. AC_INIT([libetpan],[maj_version.min_version],[libetpan-devel@lists.sourceforge.net])
  25. AC_CONFIG_SRCDIR([src/main/libetpan_version.h.in])
  26. AC_CONFIG_MACRO_DIR([m4])
  27. AC_CONFIG_HEADER([config.h])
  28. AM_INIT_AUTOMAKE
  29. AM_MAINTAINER_MODE
  30. AC_CANONICAL_HOST
  31. dnl Version major and minor
  32. VERSION_MAJOR=maj_version
  33. VERSION_MINOR=min_version
  34. dnl required version of libcurl
  35. libcurl_major_required=0
  36. libcurl_minor_required=0
  37. dnl API version
  38. dnl 1. If you have changed any of the sources for this library, the revision
  39. dnl number must be incremented. This is a new revision of the current
  40. dnl interface.
  41. dnl 2. If the interface has changed, then current must be incremented, and
  42. dnl revision reset to `0'. This is the first revision of a new interface.
  43. dnl 3. If the new interface is a superset of the previous interface (that is,
  44. dnl if the previous interface has not been broken by the changes in this new
  45. dnl release), then age must be incremented. This release is backwards
  46. dnl compatible with the previous release.
  47. dnl 4. If the new interface has removed elements with respect to the previous
  48. dnl interface, then you have broken backward compatibility and age must be
  49. dnl reset to `0'. This release has a new, but backwards incompatible
  50. dnl interface.
  51. API_CURRENT=api_current
  52. API_REVISION=api_revision
  53. API_COMPATIBILITY=api_compatibility
  54. AC_SUBST(API_CURRENT)
  55. AC_SUBST(API_COMPATIBILITY)
  56. AC_SUBST(API_REVISION)
  57. API_AGE=`expr $API_CURRENT - $API_COMPATIBILITY`
  58. API_VERSION="$API_CURRENT:$API_REVISION:$API_AGE"
  59. AC_SUBST(API_VERSION)
  60. dnl FIXME: This should be the git revision.
  61. BUILD_REVISION=0
  62. AC_SUBST(BUILD_REVISION)
  63. BUILD_TIMESTAMP=`date +'%Y-%m-%dT%H:%M%z'`
  64. AC_SUBST(BUILD_TIMESTAMP)
  65. changequote(,)dnl
  66. BUILD_FILEVERSION=`echo "${VERSION_MAJOR}.${VERSION_MINOR}.0" | sed 's/\([0-9.]*\).*/\1./;s/\./,/g'`
  67. changequote([,])dnl
  68. BUILD_FILEVERSION="${BUILD_FILEVERSION}${BUILD_REVISION}"
  69. AC_SUBST(BUILD_FILEVERSION)
  70. # Architecture specific.
  71. have_w32_system=no
  72. case "${host}" in
  73. *-mingw32*)
  74. have_w32_system=yes
  75. CFLAGS="$CFLAGS -mms-bitfields -I\${top_srcdir}/src/windows"
  76. ## Currently we export all symbols indiscriminately.
  77. ## Eventually, this can be limited to those which should be
  78. ## exported (which helps to hide our internal mmap stubs, for
  79. ## example), but before this can happen, the missing export
  80. ## declarations have to be added to all header files. Also, it
  81. ## should first be verified that exporting data members from a
  82. ## DLL is safe. To reenable discriminate exports, uncomment
  83. ## the following line and replace the "@ifdef _MSC_VER" around the
  84. ## export/import declaration stuff in libetpan.h.in by
  85. ## "@if WIN32".
  86. # CFLAGS="$CFLAGS -DLIBETPAN_DLL"
  87. # We use winsock2.
  88. LIBS="$LIBS -lws2_32"
  89. ;;
  90. *)
  91. ;;
  92. esac
  93. if test "$have_w32_system" = yes; then
  94. AC_DEFINE(HAVE_MINGW32_SYSTEM, 1, [Defined if we run on a W32 API based system])
  95. fi
  96. AM_CONDITIONAL(HAVE_MINGW32_SYSTEM, test "$have_w32_system" = yes)
  97. # Check the C compiler.
  98. AC_PROG_CC
  99. AC_PROG_CXX
  100. # Compiler flags.
  101. AC_ARG_ENABLE(debug, [ --enable-debug setup flags (gcc) for debugging (default=no)],
  102. if test "x$enable_debug" = xyes; then
  103. CFLAGS="$CFLAGS -O2 -g"
  104. fi
  105. CPPFLAGS="$CPPFLAGS -DDEBUG"
  106. LDFLAGS="$LDFLAGS",)
  107. AC_ARG_ENABLE(optim, [ --enable-optim setup flags (gcc) for optimizations (default=no)],
  108. if test "x$enable_debug" != "xyes" ; then
  109. if test "x$GCC" = xyes; then
  110. CFLAGS="$CFLAGS -O2 -ffast-math -funroll-loops -g0"
  111. fi
  112. CPPFLAGS="$CPPFLAGS"
  113. LDFLAGS="$LDFLAGS -s"
  114. else
  115. AC_MSG_WARN([enable-optim and enable-debug are incompatible -- disabling optimizations])
  116. fi,)
  117. if test "x$GCC" = xyes; then
  118. CFLAGS="$CFLAGS -W -Wall"
  119. fi
  120. AC_ARG_ENABLE(syntax, [ --enable-unstrict-syntax be lazy on syntax checking for protocols (default=no)], , [AC_DEFINE(UNSTRICT_SYNTAX, 1, [Define to be lazy on protocol syntax])])
  121. AH_VERBATIM([CONFIG_H_FIRST], [/* Check for Linux's /usr/include/features.h
  122. */
  123. #ifdef _FEATURES_H
  124. # error config.h must be first file included
  125. #endif])
  126. AC_C_INLINE
  127. # Checks for programs.
  128. AC_LIBTOOL_WIN32_DLL
  129. LT_AC_PROG_RC
  130. AC_LIBTOOL_RC
  131. AC_PROG_LIBTOOL
  132. AC_PROG_MKDIR_P
  133. dnl Can't use AC_PROG_INSTALL
  134. INSTALL='$(SHELL) $(top_srcdir)/install-sh -c'
  135. AC_SUBST(INSTALL)
  136. # Checks for header files.
  137. AC_HEADER_STDC
  138. AC_CHECK_HEADERS(fcntl.h unistd.h ctype.h sys/types.h sys/stat.h sys/mman.h limits.h)
  139. AC_CHECK_HEADERS(netdb.h netinet/in.h sys/socket.h)
  140. AC_CHECK_HEADERS(sys/param.h sys/select.h inttypes.h)
  141. AC_CHECK_HEADERS(arpa/inet.h winsock2.h)
  142. # Checks for typedefs, structures, and compiler characteristics.
  143. # Checks for library functions.
  144. AC_FUNC_MMAP
  145. dnl Network libs
  146. AC_CHECK_FUNC(connect, checksocket=no, checksocket=yes)
  147. if test "x$checksocket" = "xyes"; then
  148. case "x$LIBS" in
  149. *-lsocket*);;
  150. *) AC_CHECK_LIB(socket, connect) ;;
  151. esac
  152. fi
  153. AC_CHECK_FUNC(inet_ntoa, checknsl=no, checknsl=yes)
  154. if test "x$checknsl" = "xyes"; then
  155. case "x$LIBS" in
  156. *-lnsl*);;
  157. *) AC_CHECK_LIB(nsl, inet_ntoa) ;;
  158. esac
  159. fi
  160. AC_CHECK_FUNC(setenv, AC_DEFINE(HAVE_SETENV, 1, [Define to use setenv]),)
  161. # Check for getopt_long; if not found, use included source.
  162. AC_CHECK_FUNCS([getopt_long], has_getopt_long=no, has_getopt_long=yes)
  163. if test "x$has_getoptlong" = "xyes"; then
  164. AC_DEFINE([HAVE_GETOPT_LONG], 1, [Define to use getopt_long])
  165. fi
  166. dnl OpenSSL -- very primitive right now
  167. AC_ARG_WITH(openssl, [ --with-openssl[=DIR] include OpenSSL support (default=auto)],
  168. [], [with_openssl=yes])
  169. if test "x$with_openssl" != "xno"; then
  170. OCPPFLAGS="$CPPFLAGS"
  171. OLDFLAGS="$LDFLAGS"
  172. if test "x$with_openssl" != "xyes" ; then
  173. CPPFLAGS="$CPPFLAGS -I$with_openssl/include"
  174. LDFLAGS="$LDFLAGS -L$with_openssl/lib"
  175. fi
  176. with_openssl=no
  177. SSLLIBS=""
  178. AC_CHECK_HEADER(openssl/ssl.h, [
  179. AC_CHECK_LIB(rsaref, main, [SSLLIBS="-lrsaref"])
  180. AC_CHECK_LIB(crypto, main, [SSLLIBS="-lcrypto $SSLLIBS"], [], [$SSLLIBS])
  181. AC_CHECK_LIB(ssl, SSL_library_init, with_openssl=yes, [], [$SSLLIBS])])
  182. if test "x$with_openssl" != "xyes"; then
  183. CPPFLAGS="$OCPPFLAGS"
  184. LDFLAGS="$OLDFLAGS"
  185. else
  186. with_gnutls="no"
  187. fi
  188. fi
  189. if test "x$with_openssl" = "xyes"; then
  190. AC_DEFINE([USE_SSL], 1, [Define to use OpenSSL])
  191. SSLLIBS="-lssl $SSLLIBS"
  192. else
  193. SSLLIBS=""
  194. fi
  195. AC_SUBST(SSLLIBS)
  196. dnl GNUTLS
  197. AC_ARG_WITH(gnutls, [ --with-gnutls[=DIR] include GnuTLS support (default=auto)],
  198. [], [with_gnutls=no])
  199. if test "x$with_gnutls" != "xno"; then
  200. OCPPFLAGS="$CPPFLAGS"
  201. OLDFLAGS="$LDFLAGS"
  202. if test "x$with_gnutls" != "xyes" ; then
  203. CPPFLAGS="CPPFLAGS -I$with_gnutls/include"
  204. LDFLAGS="$LDFLAGS -L$with_gnutls/lib"
  205. fi
  206. GNUTLSLIB=""
  207. AC_CHECK_HEADER(gnutls/gnutls.h, [
  208. AC_CHECK_LIB(gnutls, gnutls_global_deinit, with_gnutls=yes, [GNUTLSLIB="-lgnutls"])
  209. ])
  210. if test "x$with_gnutls" != "xyes"; then
  211. CPPFLAGS="$OCPPFLAGS"
  212. LDFLAGS="$OLDFLAGS"
  213. else
  214. with_openssl="no"
  215. fi
  216. fi
  217. if test "x$with_gnutls" = "xyes"; then
  218. AC_DEFINE([USE_GNUTLS],1, [Define to use GnuTLS])
  219. AC_DEFINE([USE_SSL], 1, [Define to use OpenSSL])
  220. GNUTLSLIB="-lgnutls -lgcrypt -lgpg-error -lz"
  221. else
  222. GNUTLSLIB=""
  223. fi
  224. AC_SUBST(GNUTLSLIB)
  225. if test "x$with_openssl" = "xno"; then
  226. if test "x$with_gnutls" = "xno"; then
  227. AC_MSG_WARN([OpenSSL support disabled.])
  228. fi
  229. fi
  230. dnl iconv
  231. LIBICONV=""
  232. AC_ARG_ENABLE(iconv,
  233. [ --disable-iconv make a version not using iconv],
  234. enable_iconv=no, enable_iconv=yes)
  235. if test x$enable_iconv = xyes; then
  236. dnl get prototype
  237. AC_CHECK_HEADER(iconv.h, [ICONV_HEADER=1], [ICONV_HEADER=0])
  238. ICONV_PROTO=no
  239. AC_MSG_CHECKING([checking iconv() prototype])
  240. if test "x$ICONV_HEADER" = x1 ; then
  241. SAVED_CPPFLAGS="$CPPFLAGS"
  242. CPPFLAGS="-std=c99 $CPPFLAGS"
  243. AC_TRY_COMPILE([#include <iconv.h>
  244. size_t iconv (iconv_t cd, char ** restrict inbuf,
  245. size_t * restrict inbytesleft,
  246. char ** restrict outbuf,
  247. size_t * restrict outbytesleft);],
  248. [],
  249. [ICONV_PROTO=noconst]
  250. [])
  251. AC_TRY_COMPILE([#include <iconv.h>
  252. size_t iconv (iconv_t cd, const char ** restrict inbuf,
  253. size_t * restrict inbytesleft,
  254. char ** restrict outbuf,
  255. size_t * restrict outbytesleft);],
  256. [],
  257. [ICONV_PROTO=const]
  258. [])
  259. CPPFLAGS="$SAVED_CPPFLAGS"
  260. fi
  261. dnl try to link
  262. ICONV_LINKED=NO
  263. if test "$ICONV_PROTO" != "xno" ; then
  264. AC_MSG_RESULT([ok])
  265. AC_MSG_CHECKING([for iconv])
  266. ICONV_LINKED=0
  267. AC_TRY_LINK([#include <stdlib.h>
  268. #include <iconv.h>],
  269. [iconv_t cd = iconv_open("","");
  270. iconv(cd,NULL,NULL,NULL,NULL);
  271. iconv_close(cd);],
  272. [ICONV_LINKED=1],
  273. [])
  274. saved_LIBS="$LIBS"
  275. for lib in iconv ; do
  276. if test "x$ICONV_LINKED" = "x0" ; then
  277. LIBS=-l$lib
  278. AC_TRY_LINK([#include <stdlib.h>
  279. #include <iconv.h>],
  280. [iconv_t cd = iconv_open("","");
  281. iconv(cd,NULL,NULL,NULL,NULL);
  282. iconv_close(cd);],
  283. [LIBICONV="$LIBS" ; ICONV_LINKED=1],
  284. [])
  285. fi
  286. done
  287. LIBS="$saved_LIBS"
  288. if test "x$ICONV_LINKED" = "x1" ; then
  289. AC_MSG_RESULT([found])
  290. else
  291. AC_MSG_RESULT([not found])
  292. fi
  293. else
  294. AC_MSG_RESULT([failed])
  295. fi
  296. if test "x$ICONV_LINKED" = "x1" ; then
  297. AC_DEFINE(HAVE_ICONV, 1, [Define if you have the iconv() function.])
  298. fi
  299. ICONV_PROTO_CONST=0
  300. if test "x$ICONV_PROTO" = "xconst" ; then
  301. AC_DEFINE_UNQUOTED(HAVE_ICONV_PROTO_CONST, 1,
  302. [prototype of iconv() has const parameters])
  303. fi
  304. fi
  305. AC_SUBST(LIBICONV)
  306. dnl Berkeley DB
  307. DBVERS=0
  308. DBLINKED=0
  309. DBLIB=""
  310. AC_ARG_ENABLE(db, [ --disable-db disable Berkeley DB (default=try to detect DB)],[enable_db=$enableval],[enable_db=yes])
  311. dnl Check for a presence of Berkeley DB header
  312. if test "x$enable_db" != "xyes"; then
  313. AC_MSG_WARN(cache support disabled)
  314. else
  315. AC_CHECK_HEADER(db.h, [DB_HEADER=1], [DB_HEADER=0])
  316. fi
  317. if test "x$DB_HEADER" = "x1"; then
  318. dnl Check for version of Berkeley DB
  319. AC_MSG_CHECKING([version of Berkeley DB])
  320. dnl check for version 3 and above
  321. AC_TRY_COMPILE(
  322. [#include <db.h>],
  323. [#if DB_VERSION_MAJOR < 3
  324. #error DB version 3 or above needed
  325. #endif],
  326. [DBVERS=3]
  327. [])
  328. dnl check for version 2
  329. if test "x$DBVERS" = "x0"; then
  330. AC_TRY_COMPILE([#include <db.h>],
  331. [#if DB_VERSION_MAJOR != 2
  332. #error DB version 2 needed
  333. #endif],
  334. [DBVERS=2]
  335. [])
  336. fi
  337. if test "x$DBVERS" = "x0"; then
  338. dnl assume version 1
  339. DBVERS=1
  340. fi
  341. dnl test linkage with Berkeley DB
  342. dnl Look for db3 or superior with db_create call
  343. case "$DBVERS" in
  344. 3)
  345. AC_MSG_RESULT([version 3.x or above])
  346. for lib in db-5.3 db-5.1 db-5.0 db-4.8 db-4.7 db-4.6 db-4.5 db-4.4 db-4.3 db-4.2 db-4.1 db-4.0 db-4 db4 db-3.2 db-3 db3 db; do
  347. if test "x$DBLINKED" = "x0"; then
  348. dnl AC_CHECK_LIB($lib, db_create, [DBLIB="-l$lib"; DBLINKED=1], [])
  349. dnl installations of libdb4 function names are defined in db.h
  350. dnl to other symbols
  351. AC_MSG_CHECKING([for db_create() in -l$lib])
  352. LIBS=-l$lib
  353. AC_TRY_LINK(
  354. [#include <db.h>],
  355. [db_create(0,0,0)],
  356. [DBLIB="-l$lib"; DBLINKED=1; AC_MSG_RESULT([found])],
  357. [AC_MSG_RESULT([not found])])
  358. fi
  359. done
  360. LIBS=""
  361. ;;
  362. dnl Look for db2 with db_open call
  363. 2)
  364. AC_MSG_RESULT([version 2.x])
  365. for lib in db2 db; do
  366. if test "x$DBLINKED" = "x0"; then
  367. AC_CHECK_LIB($lib, db_open, [DBLIB="-l$lib"; DBLINKED=1], [])
  368. fi
  369. done
  370. ;;
  371. *)
  372. dnl Look for db1 with dbopen call in -ldb or in libc (bsds)
  373. AC_MSG_RESULT([version 1.x])
  374. AC_CHECK_FUNC(dbopen, [DBLINKED=1], [])
  375. for lib in db-1 db1 db; do
  376. if test "x$DBLINKED" = "x0"; then
  377. AC_CHECK_LIB($lib, dbopen, [DBLIB="-l$lib"; DBLINKED=1], [])
  378. fi
  379. done
  380. ;;
  381. dnl fi
  382. esac
  383. fi
  384. if test "x$DBLINKED" = "x0"; then
  385. DBVERS=0
  386. if test "x$enable_db" = "xyes"; then
  387. AC_MSG_WARN(cache support disabled (Berkeley DB is missing).)
  388. fi
  389. fi
  390. AC_DEFINE_UNQUOTED(DBVERS, $DBVERS,
  391. [Define to detected Berkeley DB major version number])
  392. AC_SUBST(DBLIB)
  393. dnl Threading support, if enabled
  394. AC_ARG_ENABLE(threads, [ --disable-threads do not include multithreading support using pthread],,[enable_threads=yes])
  395. AC_ARG_ENABLE(windows-threads, [ --enable-windows-threads include multithreading support using windows threads],[enable_windows_threads=yes],)
  396. if test "x$enable_windows_threads" = "xyes"; then
  397. AC_CHECK_HEADERS(pthread.h, [], [])
  398. AC_DEFINE([LIBETPAN_REENTRANT], 1, [Define to include multithreading support])
  399. LIBSUFFIX=
  400. REENTRANT=1
  401. elif test "x$enable_threads" = "xyes"; then
  402. dnl Try to find a good CFLAGS/LDFLAGS for pthreads
  403. AC_CHECK_HEADERS(pthread.h, [], [AC_MSG_ERROR([pthread support required])])
  404. CPPFLAGS="$CPPFLAGS -D_REENTRANT"
  405. checkpthread=yes
  406. AC_MSG_CHECKING([for pthread_create with libc])
  407. AC_TRY_LINK([], [pthread_create();],
  408. [pthflag=yes; checkpthread=no],
  409. [pthflag=no])
  410. AC_MSG_RESULT($pthflag)
  411. for flag in "pthreads" "pthread"; do
  412. if test "x$checkpthread" = "xyes"; then
  413. AC_MSG_CHECKING([for pthread_create with -$flag])
  414. OLDLIBS="$LIBS"
  415. LIBS="$LIBS -$flag"
  416. AC_TRY_LINK([], [pthread_create();],
  417. [pthflag=yes; checkpthread=no],
  418. [pthflag=no; LIBS="$OLDLIBS"])
  419. AC_MSG_RESULT($pthflag)
  420. fi
  421. done
  422. # pthreadGC2 is provided by pthreads-w32 on mingw32 platforms.
  423. for lib in "c_r" "pthread" "pthreadGC2" ; do
  424. if test "x$checkpthread" = "xyes"; then
  425. case "x$LIBS" in
  426. *-l$lib*);;
  427. *) AC_CHECK_LIB($lib, pthread_create, [LIBS="$LIBS -l$lib"; checkpthread=no]) ;;
  428. esac
  429. fi
  430. done
  431. if test "x$checkpthread" = "xyes"; then
  432. AC_CHECK_FUNC(pthread_create, checkpthread=no)
  433. text "x$checkpthread" = "xyes" && AC_MSG_ERROR([pthread library required])
  434. fi
  435. AC_DEFINE([LIBETPAN_REENTRANT], 1, [Define to include multithreading support])
  436. LIBSUFFIX=
  437. REENTRANT=1
  438. else
  439. REENTRANT=0
  440. LIBSUFFIX=-no-mt
  441. fi
  442. AC_SUBST(LIBSUFFIX)
  443. AC_SUBST(REENTRANT)
  444. dnl liblockfile on debian systems
  445. AC_ARG_ENABLE(lockfile, [ --disable-lockfile do not use liblockfile for locking mailboxes])
  446. if test "x$enable_lockfile" != "xno"; then
  447. AC_CHECK_LIB(lockfile, lockfile_create,, [
  448. if test "x$enable_lockfile" = "xyes"; then
  449. AC_MSG_ERROR([liblockfile not found])
  450. fi ])
  451. fi
  452. AC_DEFINE_UNQUOTED(LIBETPAN_VERSION_MAJOR, $VERSION_MAJOR,
  453. [Define this to the major version of libEtPan])
  454. AC_DEFINE_UNQUOTED(LIBETPAN_VERSION_MINOR, $VERSION_MINOR,
  455. [Define this to the minor version of libEtPan])
  456. AC_SUBST(VERSION_MAJOR)
  457. AC_SUBST(VERSION_MINOR)
  458. dnl Cyrus SASL
  459. AC_ARG_WITH(sasl, [ --with-sasl[=DIR] include SASL support (default=auto)],
  460. [], [with_sasl=yes])
  461. if test "x$with_sasl" != "xno"; then
  462. OCPPFLAGS="$CPPFLAGS"
  463. OLDFLAGS="$LDFLAGS"
  464. if test "x$with_sasl" != "xyes" ; then
  465. CPPFLAGS="$CPPFLAGS -I$with_sasl/include"
  466. LDFLAGS="$LDFLAGS -L$with_sasl/lib"
  467. fi
  468. with_sasl=no
  469. SASLLIBS="$SSLLIBS"
  470. AC_CHECK_HEADER(sasl/sasl.h, [
  471. AC_CHECK_LIB(sasl2, sasl_client_init, with_sasl=yes, [], [$SASLLIBS])])
  472. if test "x$with_sasl" != "xyes"; then
  473. CPPFLAGS="$OCPPFLAGS"
  474. LDFLAGS="$OLDFLAGS"
  475. fi
  476. fi
  477. if test "x$with_sasl" = "xyes"; then
  478. AC_DEFINE([USE_SASL], 1, [Define to use SASL])
  479. SASLLIBS="-lsasl2 $SASLLIBS"
  480. else
  481. AC_MSG_WARN([SASL support disabled.])
  482. SASLLIBS=""
  483. fi
  484. AC_SUBST(SASLLIBS)
  485. dnl IPv6 support
  486. enable_ipv6=maybe
  487. AC_ARG_ENABLE(ipv6, AC_HELP_STRING([--enable-ipv6], [enable IPv6 support]), enable_ipv6=$enableval)
  488. AC_MSG_CHECKING([whether to use IPv6])
  489. AC_MSG_RESULT($enable_ipv6)
  490. if test "x$enable_ipv6" != "xno"; then
  491. dnl check for IPv6 support
  492. AC_MSG_CHECKING([for IPv6 support])
  493. AC_TRY_COMPILE([#define INET6
  494. #include <sys/types.h>
  495. #include <netinet/in.h>],
  496. [int x = IPPROTO_IPV6; struct in6_addr a;],
  497. ipv6_support=yes, ipv6_support=no)
  498. AC_MSG_RESULT($ipv6_support)
  499. if test "x$ipv6_support" = "xno"; then
  500. if test "x$enable_ipv6" = "xyes"; then
  501. AC_MSG_ERROR([cannot enable IPv6 support])
  502. fi
  503. else
  504. AC_DEFINE(HAVE_IPV6, 1, [Define to enable IPv6 support.])
  505. dnl check for getaddrinfo and freeaddrinfo function presence
  506. for func in "getaddrinfo" "freeaddrinfo"; do
  507. AC_MSG_CHECKING([for $func])
  508. AC_TRY_LINK([#include <netdb.h> ],
  509. [$func;],
  510. [func_present=yes],
  511. [func_present=no])
  512. AC_MSG_RESULT($func_present)
  513. if test "x$func_present" = "xno"; then
  514. AC_MSG_ERROR([$func function required for IPv6 support])
  515. fi
  516. done
  517. fi
  518. fi
  519. dnl libcurl
  520. libcurl=no
  521. AC_ARG_WITH(curl, [ --with-curl[=DIR] curl install directory (default=auto)],
  522. [], [with_curl=auto])
  523. if test "x$with_curl" != "xno"; then
  524. :
  525. elif test "x$with_curl" != "xauto"; then
  526. OCPPFLAGS="$CPPFLAGS"
  527. OLDFLAGS="$LDFLAGS"
  528. if test "x$with_curl" != "xyes" ; then
  529. CPPFLAGS="$CPPFLAGS -I$with_curl/include"
  530. LDFLAGS="$LDFLAGS -L$with_curl/lib -lcurl -lz"
  531. fi
  532. AC_CHECK_HEADER(curl/curl.h, [libcurl=yes])
  533. if test "x$libcurl" = "xyes"; then
  534. AC_MSG_CHECKING([whether with-curl compiles and links fine])
  535. AC_TRY_LINK([], [curl_easy_init();], [libcurl=yes], [libcurl=no])
  536. AC_MSG_RESULT([$libcurl])
  537. fi
  538. if test "x$libcurl" = "xno"; then
  539. CPPFLAGS="$OCPPFLAGS"
  540. LDFLAGS="$OLDFLAGS"
  541. fi
  542. else
  543. AC_PATH_PROG(libcurlconfig, [curl-config])
  544. if test "x$libcurlconfig" != "x"; then
  545. CPPFLAGS="$CPPFLAGS `$libcurlconfig --cflags 2>/dev/null`"
  546. AC_CHECK_HEADER(curl/curl.h, [libcurl=yes])
  547. if test "x$libcurl" = "xyes"; then
  548. AC_MSG_CHECKING([whether curl-config hints compiles and links fine])
  549. OLDFLAGS="$LDFLAGS"
  550. LDFLAGS="$LDFLAGS `$libcurlconfig --libs 2>/dev/null`"
  551. AC_TRY_LINK([], [curl_easy_init();], [libcurl=yes], [libcurl=no])
  552. AC_MSG_RESULT([$libcurl])
  553. if test "x$libcurl" = "xno"; then
  554. LDFLAGS="$OLDFLAGS"
  555. fi
  556. fi
  557. libcurl_major_version=`$libcurlconfig --version | \
  558. sed 's/^.* \([[0-9]]*\)\.\([[0-9]]*\).*$/\1/'`
  559. libcurl_minor_version=`$libcurlconfig --version | \
  560. sed 's/^.* \([[0-9]]*\)\.\([[0-9]]*\).*$/\2/'`
  561. if test "$libcurl_major_version" -lt "$libcurl_major_required" ; then
  562. libcurl=no
  563. fi
  564. if test "$libcurl_major_version" -eq "$libcurl_major_required" ; then
  565. if test "$libcurl_minor_version" -lt "$libcurl_minor_required" ; then
  566. libcurl=no
  567. fi
  568. fi
  569. fi
  570. fi
  571. if test "x$libcurl" = "xyes" ; then
  572. AC_DEFINE([HAVE_CURL], 1, [Define to use curl])
  573. fi
  574. dnl expat
  575. libexpat=no
  576. AC_ARG_WITH(expat, [ --with-expat[=DIR] expat install directory (default=auto)],
  577. [], [with_expat=auto])
  578. if test "x$with_expat" != "xno"; then
  579. :
  580. elif test "x$with_expat" != "xauto"; then
  581. OCPPFLAGS="$CPPFLAGS"
  582. OLDFLAGS="$LDFLAGS"
  583. if test "x$with_expat" != "xyes" ; then
  584. CPPFLAGS="$CPPFLAGS -I$with_expat/include"
  585. LDFLAGS="$LDFLAGS -L$with_expat/lib -lexpat"
  586. fi
  587. AC_CHECK_HEADER(expat.h, [libexpat=yes])
  588. if test "x$libexpat" = "xyes"; then
  589. AC_MSG_CHECKING([whether with-expat compiles and links fine])
  590. AC_TRY_LINK([], [XML_SetElementHandler();], [libexpat=yes], [libexpat=no])
  591. AC_MSG_RESULT([$libexpat])
  592. fi
  593. if test "x$libexpat" = "xno"; then
  594. CPPFLAGS="$OCPPFLAGS"
  595. LDFLAGS="$OLDFLAGS"
  596. fi
  597. else
  598. AC_CHECK_HEADER(expat.h, [libexpat=yes])
  599. if test "x$libexpat" = "xyes"; then
  600. AC_MSG_CHECKING([whether libexpat compiles and links fine])
  601. OLDFLAGS="$LDFLAGS"
  602. LDFLAGS="$LDFLAGS -lexpat"
  603. AC_TRY_LINK([], [XML_SetElementHandler();], [libexpat=yes], [libexpat=no])
  604. AC_MSG_RESULT([$libexpat])
  605. if test "x$libexpat" = "xno"; then
  606. LDFLAGS="$OLDFLAGS"
  607. fi
  608. fi
  609. fi
  610. if test "x$libexpat" = "xyes" ; then
  611. AC_DEFINE([HAVE_EXPAT], 1, [Define to use expat])
  612. fi
  613. AC_ARG_WITH([zlib],
  614. [AS_HELP_STRING([--with-zlib],
  615. [include classes for streaming compressed data in and out @<:@default=check@:>@])],
  616. [],[with_zlib=check])
  617. # Check for zlib.
  618. HAVE_ZLIB=0
  619. AS_IF([test "$with_zlib" != no], [
  620. AC_MSG_CHECKING([zlib version])
  621. # First check the zlib header version.
  622. AC_COMPILE_IFELSE(
  623. [AC_LANG_PROGRAM([[
  624. #include <zlib.h>
  625. #if !defined(ZLIB_VERNUM) || (ZLIB_VERNUM < 0x1204)
  626. # error zlib version too old
  627. #endif
  628. ]], [])], [
  629. AC_MSG_RESULT([ok (1.2.0.4 or later)])
  630. # Also need to add -lz to the linker flags and make sure this succeeds.
  631. AC_SEARCH_LIBS([zlibVersion], [z], [
  632. AC_DEFINE([HAVE_ZLIB], [1], [Enable classes using zlib compression.])
  633. HAVE_ZLIB=1
  634. LDFLAGS="$LDFLAGS -lz"
  635. ], [
  636. AS_IF([test "$with_zlib" != check], [
  637. AC_MSG_FAILURE([--with-zlib was given, but no working zlib library was found])
  638. ])
  639. ])
  640. ], [
  641. AS_IF([test "$with_zlib" = check], [
  642. AC_MSG_RESULT([headers missing or too old (requires 1.2.0.4)])
  643. ], [
  644. AC_MSG_FAILURE([--with-zlib was given, but zlib headers were not present or were too old (requires 1.2.0.4)])
  645. ])
  646. ])
  647. ])
  648. AM_CONDITIONAL([HAVE_ZLIB], [test $HAVE_ZLIB = 1])
  649. dnl Version
  650. VERSION="$VERSION_MAJOR.$VERSION_MINOR"
  651. test -d .git && VERSION="$VERSION-dev-"`date +'%Y%m%d'`
  652. AC_DEFINE_UNQUOTED(LIBETPAN_VERSION, "$VERSION",
  653. [Define this to the version of libEtPan])
  654. AC_SUBST(VERSION)
  655. # Further checks.
  656. AC_CONFIG_FILES(libetpan-config
  657. Makefile
  658. build-windows/Makefile
  659. include/Makefile
  660. src/Makefile
  661. src/bsd/Makefile
  662. src/windows/Makefile
  663. src/data-types/Makefile
  664. src/low-level/Makefile
  665. src/low-level/feed/Makefile
  666. src/low-level/imap/Makefile
  667. src/low-level/imf/Makefile
  668. src/low-level/maildir/Makefile
  669. src/low-level/mbox/Makefile
  670. src/low-level/mh/Makefile
  671. src/low-level/mime/Makefile
  672. src/low-level/nntp/Makefile
  673. src/low-level/pop3/Makefile
  674. src/low-level/smtp/Makefile
  675. src/driver/Makefile
  676. src/driver/implementation/Makefile
  677. src/driver/implementation/data-message/Makefile
  678. src/driver/implementation/db/Makefile
  679. src/driver/implementation/feed/Makefile
  680. src/driver/implementation/hotmail/Makefile
  681. src/driver/implementation/imap/Makefile
  682. src/driver/implementation/maildir/Makefile
  683. src/driver/implementation/mbox/Makefile
  684. src/driver/implementation/mh/Makefile
  685. src/driver/implementation/mime-message/Makefile
  686. src/driver/implementation/nntp/Makefile
  687. src/driver/implementation/pop3/Makefile
  688. src/driver/interface/Makefile
  689. src/driver/tools/Makefile
  690. src/main/Makefile
  691. src/main/libetpan_version.h
  692. src/engine/Makefile
  693. src/versioninfo.rc
  694. doc/Makefile
  695. tests/Makefile)
  696. # We collect all files which could potentially install public header
  697. # files via HEADERS. Updating any of these files will trigger
  698. # rebuilding the header link farm. See rules.mk for what we do with
  699. # this information. Because pmake does not support $(addprefix
  700. # $(top_builddir), $(cfg_files), we need to calculate absolute path
  701. # names here for automatic dependency tracking to work properly.
  702. cfg_files=
  703. crd="`pwd`"
  704. for cfg_file in ${ac_config_files}; do
  705. cfg_files="${cfg_files} ${crd}/${cfg_file}"
  706. done
  707. AC_SUBST(cfg_files)
  708. AC_OUTPUT
  709. cp -f ${crd}/src/main/libetpan_version.h ${crd}/build-windows
  710. cd build-windows ; ./gen-public-headers.sh > build_headers.list ; cd ..