Blame view

configure.ac 39.3 KB
1 2
dnl Configuration for GNU Mailutils -- a suite of utilities for electronic mail
dnl
Sergey Poznyakoff authored
3
dnl Copyright (C) 1999,2000,2001,2002,2003,2004,2005,
Wojciech Polak authored
4
dnl 2006,2007,2008,2009 Free Software Foundation, Inc.
Alain Magloire authored
5
dnl
6 7
dnl GNU Mailutils is free software; you can redistribute it and/or modify
dnl it under the terms of the GNU General Public License as published by
8
dnl the Free Software Foundation; either version 3, or (at your option)
9 10 11 12 13 14 15
dnl any later version.
dnl
dnl GNU Mailutils is distributed in the hope that it will be useful,
dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
dnl GNU General Public License for more details.
dnl
16 17 18
dnl You should have received a copy of the GNU General Public License along
dnl with GNU Mailutils; if not, write to the Free Software Foundation,
dnl Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19

20
AC_PREREQ(2.63)
Wojciech Polak authored
21
AC_INIT([GNU Mailutils], [2.0.90], [bug-mailutils@gnu.org], [mailutils])
22
AC_CONFIG_SRCDIR([mailbox/mailbox.c])
23
AC_CONFIG_AUX_DIR([build-aux])
24
AM_INIT_AUTOMAKE([gnits 1.11 dist-bzip2 std-options silent-rules])
25
AC_CONFIG_HEADERS([config.h])
26
AC_CONFIG_MACRO_DIR([m4])
Jeff Bailey authored
27

28
# Enable silent rules by default:
29
AM_SILENT_RULES([yes])
30

Sergey Poznyakoff authored
31 32 33
dnl Autobuild stuff
AB_INIT

34
dnl Library versioning
35
AC_SUBST(VI_CURRENT,  3)
36 37
AC_SUBST(VI_REVISION, 2)
AC_SUBST(VI_AGE,      1)
38 39

dnl Library paths
Wojciech Polak authored
40
AC_SUBST(MU_LIB_AUTH,'${top_builddir}/libmu_auth/libmu_auth.la')
41 42 43 44
AC_SUBST(MU_LIB_MAILUTILS,'${top_builddir}/mailbox/libmailutils.la')
AC_SUBST(MU_LIB_SQL,'${top_builddir}/sql/libsql.la')
AC_SUBST(MU_LIB_IMAP,'${top_builddir}/libproto/imap/libmu_imap.la')
AC_SUBST(MU_LIB_MAILDIR,'${top_builddir}/libproto/maildir/libmu_maildir.la')
Wojciech Polak authored
45
AC_SUBST(MU_LIB_MAILER,'${top_builddir}/libproto/mailer/libmu_mailer.la')
46 47 48 49
AC_SUBST(MU_LIB_MBOX,'${top_builddir}/libproto/mbox/libmu_mbox.la')
AC_SUBST(MU_LIB_MH,'${top_builddir}/libproto/mh/libmu_mh.la')
AC_SUBST(MU_LIB_NNTP,'${top_builddir}/libproto/nntp/libmu_nntp.la')
AC_SUBST(MU_LIB_POP,'${top_builddir}/libproto/pop/libmu_pop.la')
Wojciech Polak authored
50
AC_SUBST(MU_LIB_SIEVE,'${top_builddir}/libmu_sieve/libmu_sieve.la')
51 52
AC_SUBST(MU_LIB_SCM,'${top_builddir}/libmu_scm/libmu_scm.la')
AC_SUBST(MU_LIB_CPP,'${top_builddir}/libmu_cpp/libmu_cpp.la')
Wojciech Polak authored
53
AC_SUBST(MU_LIB_ARGP,'${top_builddir}/libmu_argp/libmu_argp.la')
54
AC_SUBST(MU_LIB_PY)
55

56
dnl Other variables
57 58
AC_SUBST(mu_aux_dir,'$(top_srcdir)/mu-aux')
AC_SUBST(MU_SIEVE_MODDIR,'$(libdir)/$(PACKAGE)')
59 60

AC_SUBST(MU_COMMON_LIBRARIES,'$(LTLIBINTL) $(LTLIBICONV)')
Wojciech Polak authored
61
AC_SUBST(MU_APP_LIBRARIES,'../libmu_argp/libmu_argp.a ../libmu_cfg/libmu_cfg.la ../lib/libmuaux.la')
62

63 64 65 66 67 68 69 70 71 72 73 74
# There are two sets of include directories: MU_LIB_COMMON_INCLUDES, used
# by the libraries, and MU_APP_COMMON_INCLUDES, which is used by applications.
# The principal difference between them is that the latter contains gnulib
# directory.
#
# Libraries are isolated from gnulib and are not allowed to include its
# header files. There are two exceptions, though. See NOTE before the
# AC_CONFIG_LINKS statements, below.

AC_SUBST(MU_LIB_COMMON_INCLUDES,'-I${top_builddir} -I${top_srcdir}/include  -I${top_builddir}/include -I${top_srcdir}/mailbox -I${top_srcdir}/libproto/include')

AC_SUBST(MU_APP_COMMON_INCLUDES,'-I${srcdir} -I${top_srcdir}/include -I${top_srcdir}/lib -I${top_builddir}/lib -I${top_builddir} -I${top_builddir}/include -I${top_srcdir}/mailbox -I${top_srcdir}/libmu_argp -I${top_srcdir}/libmu_cfg')
75

76
dnl Check for programs
Jeff Bailey authored
77
AC_PROG_CC
78
AM_PROG_CC_C_O
79
gl_EARLY
80
AC_PROG_CXX
Jeff Bailey authored
81 82
AC_PROG_INSTALL
AC_PROG_LN_S
83
AC_LIBTOOL_DLOPEN
84
AC_PROG_LIBTOOL
85 86
AC_PROG_YACC
AM_PROG_LEX
87
AM_PROG_LIBTOOL
Jeff Bailey authored
88

89 90 91 92 93 94 95
## Predefine several variables used to display configuration status
status_pam=no
status_ltdl=no
status_dbm=no
status_gsasl=no
status_mysql=no
status_pgsql=no
96
status_ldap=no
97
status_tcpwrap=maybe
98

99
dnl Internationalization macros.
100
AM_GNU_GETTEXT([external], [need-ngettext])
101
AM_GNU_GETTEXT_VERSION(0.17)
Sergey Poznyakoff authored
102
AM_ICONV
103 104 105 106 107 108 109 110 111 112
AC_CHECK_HEADERS(iconv.h)
AC_CHECK_TYPE(iconv_t,:,
              AC_DEFINE(iconv_t, int,
                        [Conversion descriptor type]),
              [
#ifdef HAVE_ICONV_H
# include <iconv.h>
#endif
])

113 114 115 116 117 118 119 120 121 122 123
# NOTE: Generally speaking, Mailutils libraries are not allowed to include
# gnulib headers.  The only exceptions are: gettext.h, which is needed for
# proper i18n, and intprops.h, which is used in mailbox/cfg_parser.y.
# This latter will probably be rewritten to remove the need for intprops.h.
#
# To make these two headers accessible for the libraries, they are linked
# to include/.
#
AC_CONFIG_LINKS(include/gettext.h:lib/gettext.h)
AC_CONFIG_LINKS(include/intprops.h:lib/intprops.h)

Sergey Poznyakoff authored
124 125 126 127
AH_BOTTOM([
#define DEFAULT_TEXT_DOMAIN PACKAGE
])

128 129
AC_SUBST(MU_LINK_POSTFLAGS,[`for opt in $LTLIBICONV; do case $opt in -[[lL]]*) echo $opt;; esac; done|tr '\n' ' '`])

130

131 132 133 134 135 136 137 138 139 140 141 142
dnl Escape defuns that force automake to add their arguments
dnl to LIBOBJS.
dnl All dependencies has been handled by gnulib-sync.

AC_DEFINE([GNULIB_ARGP_EXTERN_BASENAME],1,
          [Define to use our own version of __argp_base_name])

# Check for large file support
AC_SYS_LARGEFILE

gl_INIT

143
dnl Check for libraries
144
USE_LOADABLE_MODULES=no
145
AC_CHECK_LIB(resolv, res_query)
146 147
LTDL_LIB=
AC_SUBST(LTDL_LIB)
148 149 150 151 152
if test "$enable_shared" = yes; then
  AC_CHECK_LIB(ltdl, lt_dlinit,[
    AC_DEFINE(HAVE_LIBLTDL,
	      1,
	      [Define to 1 if you have the `ltdl' library (-lltdl).])
153
    status_ltdl=yes
154 155 156
    LTDL_LIB=-lltdl
    _USE_LOADABLE_MODULES=yes], # FIXME: Remove leading _ when ltd support
                                # is added to SQL.
157 158
    [LTDL_LIB=""])
fi
159 160 161 162 163
if test $USE_LOADABLE_MODULES = yes; then
  AC_DEFINE(USE_LOADABLE_MODULES,1,
            [Define if mailutils is able to use loadable modules])
fi

Sergey Poznyakoff authored
164
MU_DEBUG_MODE
Alain Magloire authored
165

166
# Initialize authlibs
167

168 169 170
AC_SUBST(MU_AUTHLIBS)
AC_SUBST(MU_AUTHLIBS_DEPENDENCY)
AC_SUBST(MU_AUTHINCS)
171

172
MU_AUTHLIBS=
Wojciech Polak authored
173
MU_AUTHLIBS_DEPENDENCY=../libmu_auth/libmu_auth.la
174

175
dnl Check for arguments
176 177 178 179 180
AC_ARG_ENABLE([pam],
              AC_HELP_STRING([--disable-pam],
                             [disable pam]),
              [
case "${enableval}" in
Jeff Bailey authored
181 182
  yes) testpam=yes ;;
  no)  testpam=no ;;
183 184 185
  *)   AC_MSG_ERROR([bad value ${enableval} for --disable-pam]) ;;
esac],[testpam=yes])

186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222
AC_ARG_WITH(tcp-wrappers,
	AC_HELP_STRING([--with-tcp-wrappers],
	               [compile with TCP wrappers (libwrap) support]),
	[status_tcpwrap=${withval}],
	[status_tcpwrap=maybe])

saved_LIBS=$LIBS
TCPWRAP_LIBRARIES=
case $status_tcpwrap in
 yes) AC_CHECK_LIB(wrap, main,,
                   [AC_MSG_ERROR([Required library libwrap not found])])
      AC_CHECK_LIB(nsl, main,
                   [TCPWRAP_LIBRARIES=-lnsl])
      AC_CHECK_HEADERS(tcpd.h,,
                       [AC_MSG_ERROR([Required header tcpd.h not found])])
      status_tcpwrap=yes
      ;;

 maybe)
      AC_CHECK_LIB(wrap, main,
                   [status_tcpwrap=yes],
                   [status_tcpwrap=no])
      AC_CHECK_LIB(nsl, main, [TCPWRAP_LIBRARIES=-lnsl])
      AC_CHECK_HEADERS(tcpd.h,
                       [status_tcpwrap=yes],
                       [status_tcpwrap=no])
      ;;
 no)  ;;
esac
LIBS=$saved_LIBS

if test "$status_tcpwrap" = "yes"; then
  AC_SUBST(TCPWRAP_LIBRARIES, "$TCPWRAP_LIBRARIES -lwrap")
  AC_DEFINE_UNQUOTED(WITH_LIBWRAP, 1,
                     [Define to 1 to use tcp wrappers.])
fi

223 224 225 226 227
AC_ARG_ENABLE([pthread],
              AC_HELP_STRING([--disable-pthread],
                             [disable pthread]),
              [
case "${enableval}" in
228 229 230
  yes) usepthread=yes ;;
  no)  usepthread=no ;;
  *)   AC_MSG_ERROR(bad value ${enableval} for --disable-pthread) ;;
231
esac],[usepthread=yes])
232

233 234 235 236 237
AC_ARG_WITH([readline],
            AC_HELP_STRING([--without-readline],
                           [do not use readline]),
            [
case "${withval}" in
Jeff Bailey authored
238 239 240
  yes) usereadline=yes ;;
  no)  usereadline=no ;;
  *)   AC_MSG_ERROR(bad value ${withval} for --without-readline) ;;
241
esac],[usereadline=yes])
Jeff Bailey authored
242

243
AC_SUBST(IMAP_AUTHOBJS)
244 245
AC_SUBST(SERV_AUTHLIBS)
AC_SUBST(SERV_AUTHINCS)
246

247 248 249 250 251
AC_ARG_WITH([gssapi],
            AC_HELP_STRING([--with-gssapi],
                           [use GSSAPI authentication]),
            [WITH_GSSAPI=$withval],
            [WITH_GSSAPI=no])
252 253 254 255 256 257 258

if test "x$WITH_GSSAPI" != "xno"; then
  MU_CHECK_GSSAPI($WITH_GSSAPI)
  if test "$GSSAPI_IMPL" = "none"; then
    AC_CACHE_SAVE
    AC_MSG_RESULT([GSSAPI libraries not found])
  else
259 260
    SERV_AUTHLIBS="$SERV_AUTHLIBS $GSSAPI_LIBS"
    SERV_AUTHINCS="$SERV_AUTHINCS $GSSAPI_CFLAGS"
261
    IMAP_AUTHOBJS="$IMAP_AUTHOBJS auth_gss.o"
262
    AC_DEFINE(WITH_GSSAPI,1,[Define if mailutils is using GSSAPI])
263 264
  fi
fi
265

Sergey Poznyakoff authored
266
MU_CHECK_GSASL(0.2.3, [
267
    AC_DEFINE(WITH_GSASL,1,[Define if mailutils is using GNU SASL])
268
    MU_AUTHLIBS="$MU_AUTHLIBS $GSASL_LIBS"
269 270
    IMAP_AUTHOBJS="$IMAP_AUTHOBJS auth_gsasl.o"
    status_gsasl=yes])
271

272 273
AC_SUBST(SITE_CRAM_MD5_PWD,"\$(sysconfdir)/cram-md5.pwd")

274 275 276 277 278 279 280 281 282
AC_ARG_WITH(cram-passwd,
            AC_HELP_STRING([--with-cram-passwd=FILE],
                           [use keep passwords for CRAM-MD5 authentication method in FILE (default $SITE_CRAM_MD5_PWD)]),
            [case "${withval}" in
            /*) SITE_CRAM_MD5_PWD="${withval}";;
            ./*|../*) AC_MSG_ERROR(Bad value for --with-cram-passwd);;
            *)  SITE_CRAM_MD5_PWD="\$(sysconfdir)/${withval}";;
            esac])

283 284
MU_CHECK_TLS
if test "$WITH_GNUTLS" != "no"; then
285
  MU_AUTHLIBS="$MU_AUTHLIBS $TLS_LIBS"
286 287 288 289
  AC_DEFINE(WITH_GNUTLS,1,[Define if mailutils is using GNU TLS])
  AC_DEFINE(WITH_TLS,1,[Define if mailutils is using TLS])
fi

290 291 292 293 294
AC_ARG_WITH([guile],
            AC_HELP_STRING([--without-guile],
                           [do not build guile interface]),
            [
case "${withval}" in
295 296 297
  yes) useguile=yes ;;
  no)  useguile=no ;;
  *)   AC_MSG_ERROR(bad value ${withval} for --without-guile) ;;
298
esac],[useguile=yes])
299

300
AC_SUBST(SITE_MAIL_RC)
301 302 303 304 305
AC_ARG_WITH([mail-rc],
            AC_HELP_STRING([--with-mail-rc=FILE],
                           [use FILE instead of $sysconfdir/mail.rc]),
            [
case "${withval}" in
306 307 308 309
  /*) SITE_MAIL_RC="${withval}";;
  *)  SITE_MAIL_RC="\$(sysconfdir)/${withval}";;
  esac],
 [SITE_MAIL_RC="\$(sysconfdir)/mail.rc"])
Alain Magloire authored
310

311
MU_CONF_MAILDIR=
312 313 314 315 316
AC_ARG_WITH([mail-spool],
            AC_HELP_STRING([--with-mail-spool=PATH],
                           [use PATH instead of /var/spool/mail]),
            [
case "$withval" in
317 318 319
  /*/) MU_CONF_MAILDIR="\"${withval}\"";;
  /*)  MU_CONF_MAILDIR="\"${withval}/\"";;
  *:*[[/=]]) MU_CONF_MAILDIR="\"${withval}\"";;
320
  *)  AC_MSG_ERROR(--with-mail-spool must be an absolute path or a valid URL);;
321
esac])
322 323

if test "x$MU_CONF_MAILDIR" != x; then
324
  AC_DEFINE_UNQUOTED(MU_CONF_MAILDIR,$MU_CONF_MAILDIR,
325
                     [Pathname of the mail spool directory])
326
fi
327 328 329 330 331 332 333 334

PATHDEFS_H=pathdefs.h
MU_CONFIG_PATHS($srcdir/paths,PATHDEFS_H)

AH_BOTTOM(
[/* Defaults for PATH_ variables.  */
#include <confpaths.h>

335 336 337
#ifdef MU_CONF_MAILDIR
# define MU_PATH_MAILDIR MU_CONF_MAILDIR
#else
338
# define MU_PATH_MAILDIR PATH_MAILDIR "/"
339
#endif])
340

341
use_dbm=no
342 343
AC_ARG_WITH([gdbm],
            AC_HELP_STRING([--with-gdbm],
344
                           [use GNU DBM]),
345 346
            [
case "${withval}" in
347 348 349
  yes) use_dbm=GDBM ;;
  no)  use_dbm=no ;;
  *)   AC_MSG_ERROR(bad value ${withval} for --with-gdbm) ;;
350
esac])
351

352
## Support --with-db2 for backward compatibility
Sergey Poznyakoff authored
353
if test "${with_db2+set}" = set; then
354 355 356
  case "${with_db2}" in
  yes) use_dbm=BDB2 ;;
  no)  use_dbm=no ;;
Sergey Poznyakoff authored
357
  *)   AC_MSG_ERROR(bad value ${with_db2} for --with-db2) ;;
358 359 360 361 362
  esac
fi

AC_ARG_WITH([berkeley-db],
            AC_HELP_STRING([--with-berkeley-db],
363 364 365
                           [use Berkeley DB]),
            [
case "${withval}" in
366
  yes) use_dbm=BDB ;;
367
  no)  use_dbm=no ;;
368
  *)   use_dbm=BDB="${withval}";;
369
esac])
370

371 372 373 374 375
AC_ARG_WITH([ndbm],
            AC_HELP_STRING([--with-ndbm],
                           [use NDBM]),
            [
case "${withval}" in
376 377 378
  yes) use_dbm=NDBM ;;
  no)  use_dbm=no ;;
  *)   AC_MSG_ERROR(bad value ${withval} for --with-ndbm) ;;
379
esac])
380

381 382 383 384 385 386 387 388 389 390
AC_ARG_WITH([tokyocabinet],
            AC_HELP_STRING([--with-tokyocabinet],
                           [use Tokyo Cabinet]),
            [
case "${withval}" in
  yes) use_dbm=TC ;;
  no)  use_dbm=no ;;
  *)   AC_MSG_ERROR(bad value ${withval} for --with-tokyocabinet) ;;
esac])

391 392
AC_MSG_CHECKING(for log facility)
log_facility="LOG_MAIL"
393 394 395 396 397
AC_ARG_WITH([log-facility],
            AC_HELP_STRING([--with-log-facility=facility],
                           [enable logging to the given facility]),
            [AC_TRY_COMPILE([#include <syslog.h>], int lf = $withval,
	     log_facility=$withval)])
398
AC_DEFINE_UNQUOTED(LOG_FACILITY, $log_facility,
399 400 401 402 403
                   [Default syslog facility])
fstr=`echo "$log_facility" | tr A-Z a-z | sed 's/log_//'`
AC_DEFINE_UNQUOTED(LOG_FACILITY_STRING, "$fstr",
                   [String representation of the default syslog facility])
		   
404 405
AC_MSG_RESULT($log_facility)

406
dnl Check for headers
Jeff Bailey authored
407
AC_HEADER_STDC
408
AC_HEADER_DIRENT
409
AC_CHECK_HEADERS(errno.h fcntl.h inttypes.h libgen.h limits.h\
410 411
 malloc.h obstack.h paths.h shadow.h socket.h sys/socket.h stdarg.h stdio.h\
 stdlib.h string.h strings.h sys/file.h sysexits.h syslog.h termcap.h\
412
 termios.h termio.h sgtty.h utmp.h utmpx.h unistd.h wchar.h)
Alain Magloire authored
413

414 415 416 417 418 419 420
dnl Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_TYPE_UID_T
AC_TYPE_MODE_T
AC_TYPE_OFF_T
AC_TYPE_PID_T
AC_TYPE_SIZE_T
421
AC_CHECK_TYPE(ssize_t, , AC_DEFINE(ssize_t, int, [Define to int if <sys/types.h> does not define]))
Alain Magloire authored
422
AC_TYPE_SIGNAL
423
AC_DECL_SYS_SIGLIST
424
AC_STRUCT_TIMEZONE
425 426 427 428 429 430 431 432 433 434 435 436 437 438
AC_CHECK_TYPE(ino_t, , AC_DEFINE(ino_t, unsigned long, [Define to unsigned long if <sys/types.h> does not define]))
AC_CHECK_TYPE(dev_t, , AC_DEFINE(dev_t, unsigned long, [Define to unsigned long if <sys/types.h> does not define]))
AC_CHECK_TYPE(socklen_t, , AC_DEFINE(socklen_t, int, [Define to int if <sys/types.h> does not define]),
[
#if HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif
#ifdef HAVE_SYS_SOCKET_H
# include <sys/socket.h>
#endif
#ifdef HAVE_SOCKET_H
# include <socket.h>
#endif
])
Alain Magloire authored
439 440
AC_CHECK_TYPE(long long, , AC_DEFINE(LONG_LONG, long, [Define to long if compiler does not support]))
AC_CHECK_TYPE(long double, , AC_DEFINE(LONG_DOUBLE, double, [Define to double if compiler does not support]))
441

442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458
AC_SUBST(MU_ULONG_MAX)
AC_RUN_IFELSE([AC_LANG_PROGRAM(
[#include <stdio.h>
#include <stdlib.h>
#include <limits.h>],
[
 FILE *f = fopen ("conftest.val", "w");
 if (! f)
    exit (1);
 fprintf(f, "%lu\n", ULONG_MAX);
 fclose(f);
 return 0;]
)],
 [MU_ULONG_MAX=`cat conftest.val`],
 [MU_ULONG_MAX=0],
 [MU_ULONG_MAX=0])

459 460 461 462 463
AC_STRUCT_TM
AC_CHECK_MEMBERS([struct tm.tm_zone, struct tm.tm_gmtoff, struct tm.tm_isdst],
                 ,,
                 [#include <sys/types.h>
#include <$ac_cv_struct_tm>])
Jeff Bailey authored
464

Jeff Bailey authored
465 466
dnl Check for working functions

467 468 469 470 471
#####
# Determine the size of off_t and define an equivalent mu_off_t type.
# We cannot use off_t in the library since its size depends on whether
# large file support is used or not, which will lead to arbitrary crashes
# if a user application and the library use off_t of different sizes.
472

473 474 475 476 477 478 479 480 481 482 483
AC_CHECK_SIZEOF(off_t)
AC_CHECK_SIZEOF(long)
AC_CHECK_SIZEOF(long long)
AC_SUBST(MU_OFF_TYPE)
if test $ac_cv_sizeof_off_t -eq $ac_cv_sizeof_long; then
  MU_OFF_TYPE=long
elif test $ac_cv_sizeof_off_t -eq $ac_cv_sizeof_long_long; then
  MU_OFF_TYPE="long long"
else
  AC_MSG_ERROR([Cannot find ${ac_cv_sizeof_off_t}-byte type, suitable for mu_off_t])
fi
484
AC_FUNC_MMAP
485

486 487
AC_CHECK_DECLS([strtok_r, strchrnul, strndup, asprintf, vasprintf, strsignal],
 , , [
488 489 490 491 492 493
#include <stdio.h>
#include <string.h>
#ifdef HAVE_STRINGS_H
# include <strings.h>
#endif])

494 495 496 497
AC_CHECK_DECLS(environ, , ,
  [ #include <unistd.h>
    #include <stdlib.h> ])

498 499 500
AH_BOTTOM([
#if !HAVE_DECL_STRTOK_R
extern char *strtok_r (char *s, const char *delim, char **save_ptr);
501 502 503 504 505
#endif
#if !HAVE_DECL_STRSIGNAL
extern char *strsignal (int);
#endif
])
506

507
AC_CHECK_FUNCS(mkstemp sigaction sysconf getdelim setreuid \
508
 setresuid seteuid setlocale vfork _exit)
Jeff Bailey authored
509

510
AC_FUNC_FSEEKO
511
AC_FUNC_SETVBUF_REVERSED
512

513
AH_BOTTOM([
514 515 516
#if !defined (HAVE_FSEEKO)
# define fseeko fseek
#endif
517 518 519 520 521 522 523
#if defined (SETVBUF_REVERSED)
# define SETVBUF(str,buf,mode,size) setvbuf(str,mode,buf,size)
#else
# define SETVBUF(str,buf,mode,size) setvbuf(str,buf,mode,size)
#endif
])

524
AC_CHECK_FUNCS(fgetpwent)
525

526 527 528
## Check for presence of utmp.h and utmp-related functions
MU_CHECK_UTMP

529
dnl Check for libraries
530

531 532 533 534 535
AH_BOTTOM([
/* program_name is used by lib/error.c */
#define program_name program_invocation_name
])

Sergey Poznyakoff authored
536 537 538

## FriBidi support

539 540
AC_CHECK_FUNCS(wcwidth)

Sergey Poznyakoff authored
541
AC_SUBST(FRIBIDI_LIBS)
542 543 544 545 546 547 548 549

use_fribidi=yes

AC_ARG_WITH([fribidi],
            AC_HELP_STRING([--without-fribidi],
                           [do not compile FriBidi support]),
            [use_fribidi=$withval])

Sergey Poznyakoff authored
550 551
AH_TEMPLATE(HAVE_LIBFRIBIDI,
            [Define to 1 if you have the `fribidi' library (-lfribidi).])
552 553 554
AH_TEMPLATE(HAVE_FRIBIDI_CHARSET_CAP_RTL,
            [Define to 1 if fribidi headers declare FRIBIDI_CHARSET_CAP_RTL type])
AH_BOTTOM([
Sergey Poznyakoff authored
555
#ifndef HAVE_FRIBIDI_CHARSET_CAP_RTL
556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573
# define FRIBIDI_CHARSET_CAP_RTL FRIBIDI_CHAR_SET_CAP_RTL
#endif])

if test "$use_fribidi" = "yes"; then
  AC_CHECK_HEADERS(fribidi/fribidi.h)
  if test $ac_cv_header_fribidi_fribidi_h = yes; then
    AC_CHECK_LIB(fribidi, fribidi_log2vis,
                 [AC_DEFINE(HAVE_LIBFRIBIDI,1)
                  FRIBIDI_LIBS=-lfribidi],
                 [use_fribidi=no])

    AC_RUN_IFELSE(AC_LANG_PROGRAM([#include <fribidi/fribidi.h>],
                                  [FriBidiCharSet s = FRIBIDI_CHARSET_CAP_RTL;]),
                  [AC_DEFINE(HAVE_FRIBIDI_CHARSET_CAP_RTL)])
                 
  else
    use_fribidi=no
  fi
Sergey Poznyakoff authored
574
fi
575

576

577
## SQL support
578 579 580

AH_TEMPLATE(USE_SQL,[Enables SQL support])
AH_TEMPLATE(HAVE_MYSQL,[Define if you have libmysql])
Alain Magloire authored
581
AH_TEMPLATE(HAVE_PGSQL,[Define if you have libpq])
582

583 584 585 586 587 588 589 590 591 592 593 594
SQL_MODULES=
AC_SUBST(SQL_MODULES)

SQL_LIBOBJS=
AC_SUBST(SQL_LIBOBJS)

SQL_LTLIBOBJS=
AC_SUBST(SQL_LTLIBOBJS)

BUILD_SQL=
AC_SUBST(BUILD_SQL)
AC_SUBST(SQLLIB)
595
AC_SUBST(SQLLIB_DEPENDENCY)
596

597 598 599 600 601 602 603 604 605 606 607
SQL_LOADABLE_MODULES=
AC_SUBST(SQL_LOADABLE_MODULES)

AC_DEFUN([MU_SQL_LDADD],[
  if test "$USE_LOADABLE_MODULES" = yes; then
    $1=$2
  else
    SQLLIB="$SQLLIB $2" 
  fi 			
])

608 609 610 611 612 613 614
add_sql_module() {
	case $SQL_MODULES in
	*$1*) AC_MSG_FAILURE([$1 specified twice]);;
	*)    SQL_MODULES="$SQL_MODULES $1";;
	esac
}

615 616 617 618 619 620 621 622 623 624 625
## *********
## MySQL
## *********
AC_SUBST(MYSQLLIBS)

mysql_init() {
  MU_CHECK_LIB(mysqlclient, 
	       mysql_real_connect, 
	       [-lm],
               [ AC_DEFINE(USE_SQL)
                 AC_DEFINE(HAVE_MYSQL)
626 627
	         MU_SQL_LDADD(MYSQLLIBS, $mu_cv_lib_mysqlclient)
                 status_mysql=yes ],
628 629 630 631 632 633 634 635
	       [ AC_MSG_FAILURE([The requested library libmysqlclient is not found or is unusable])],
               [/usr/local/lib/mysql /usr/lib/mysql])
}

AC_ARG_WITH(mysql,
	AC_HELP_STRING([--with-mysql],
	[Configure to work with MySQL]),
	[case $withval in
636
	 yes)   add_sql_module "mysql"
637 638 639 640 641 642 643 644 645 646 647 648 649
		;;
	 no)    ;;
        esac])


# *********
# Postgres
# *********

postgres_init() {
  MU_CHECK_LIB(pq, PQconnectStart, [],
	       [ AC_DEFINE(USE_SQL)
                 AC_DEFINE(HAVE_PGSQL)
650 651
	         MU_SQL_LDADD(POSTGRESLIBS, $mu_cv_lib_pq)
                 status_pgsql=yes ],
652 653 654 655 656 657 658 659
	       [ AC_MSG_FAILURE([The requested library libpq is not found or is unusable])],
               [/usr/local/pgsql/lib /usr/pgsql/lib])
}

AC_ARG_WITH(postgres,
	AC_HELP_STRING([--with-postgres],
	[Configure to work with Postgres]),
	[case $withval in
660
	 yes)	add_sql_module "postgres"
661 662 663 664
		;;
	 no)    ;;
        esac])

665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718

# *********
# ODBC
# *********
AH_TEMPLATE(USE_SQL_ODBC,[When defined, enable ODBC support])
AH_TEMPLATE(HAVE_LIBODBC,[Define if you have libodbc or libiodbc]) 
AC_SUBST(ODBCLIBS)

check_lib_odbc() {
  MU_CHECK_LIB(odbc, SQLAllocHandle, [],
	       [ AC_DEFINE(USE_SQL_ODBC)
                 AC_DEFINE(HAVE_LIBODBC)
	         MU_SQL_LDADD(ODBCLIBS, $mu_cv_lib_odbc)],
               [AC_MSG_FAILURE([The requested library libobdc is not found or is unusable])],
               [/usr/local/lib])
}

check_lib_iodbc() {
  MU_CHECK_LIB(iodbc, SQLAllocHandle, [],
	       [ AC_DEFINE(USE_SQL_ODBC)
                 AC_DEFINE(HAVE_LIBODBC)
		 MU_SQL_LDADD(ODBCLIBS, $mu_cv_lib_iodbc)],
               [AC_MSG_FAILURE([The requested library libiodbc is not found or is unusable])],
               [/usr/local/lib])
}

with_flag_used=odbc

odbc_init() {
         case $with_flag_used in
	 yes|odbc|ODBC)
		check_lib_odbc
		;;
	 iodbc|iODBC|IODBC)
		check_lib_iodbc
		;;
	 no)	;;
	 esac
}

AC_ARG_WITH(odbc,
	AC_HELP_STRING([--with-odbc[={odbc|iodbc}]],
	[Configure to work with ODBC]),
	[case $withval in
	 yes|odbc|ODBC|iodbc|iODBC|IODBC)
		add_sql_module "odbc"
		with_flag_used=$withval
		;;
	 no)    with_flag_used=$withval
		;;
	 *)	AC_MSG_ERROR([unsupported option value: $withval])
        esac])


719 720 721 722 723 724 725
### General SQL support
AC_ARG_WITH(sql,
        AC_HELP_STRING([--with-sql=modlist],
                       [Configure to work with SQL]),
	[for mod in `echo $withval | tr ':,' '  '`
         do
		if test -r $srcdir/sql/${mod}.c; then
726
			add_sql_module "${mod}"
727 728 729 730 731 732 733 734 735 736 737 738 739 740
		else
			AC_MSG_ERROR(No such SQL module: $mod)
		fi
	 done])

dummy_init() {
	:
}

if test -n "$SQL_MODULES"; then
  USE_SQL=1
  AC_DEFINE(USE_SQL)
  BUILD_SQL=libsql.la
  SQLLIB=../sql/libsql.la
741
  SQLLIB_DEPENDENCY=$SQLLIB
742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757

  for module in $SQL_MODULES
  do
    ${module:-dummy}_init
    if test $USE_LOADABLE_MODULES = yes; then
      SQL_LOADABLE_MODULES="$SQL_LOADABLE_MODULES ${module}.la"
    else
      SQL_LIBOBJS="$SQL_LIBOBJS ${module}.o"
    fi
  done
  S=`echo "$SQL_LIBOBJS" |
                  sed 's,\.[[^.]]* ,$U&,g;s,\.[[^.]]*$,$U&,'`
  SQL_LTLIBOBJS=`echo "$S" |
                  sed 's,\.[[^.]]* ,.lo ,g;s,\.[[^.]]*$,.lo,'`

  AC_CONFIG_COMMANDS([sql/modlist.h],
758
                     [$srcdir/mu-aux/sqlmod.sh $SQL_MODULES > sql/modlist.h],
759 760 761 762 763
                     [if test $USE_LOADABLE_MODULES = yes; then
			SQL_MODULES=
                      else
                        SQL_MODULES="$SQL_MODULES"
                      fi])
Alain Magloire authored
764 765
fi

766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785

# LDAP support
AC_ARG_WITH(ldap,
	AC_HELP_STRING([--with-ldap],
	[Configure to work with OpenLDAP]),
	[case $withval in
	 yes)	status_ldap=maybe
		;;
	 no)    status_ldap=no
                ;;
        esac],
        [status_ldap=maybe])

if test $status_ldap = maybe; then
  AC_CHECK_LIB(ldap, ldap_bind,[
   status_ldap=yes
   AC_DEFINE(WITH_LDAP, 1, [Define to 1 if you want to use -lldap])
   MU_AUTHLIBS="$MU_AUTHLIBS -lldap"],
   [status_ldap=no])
fi
786

787 788

# Virtual domain support
789 790 791 792 793 794 795 796 797 798
MU_ENABLE_SUPPORT(virtual-domains)
AC_SUBST(SITE_VIRTUAL_PWDDIR)
AC_ARG_WITH([virtual-pwddir],
             AC_HELP_STRING([--with-virtual-pwddir=DIR],
                              [use DIR instead of $sysconfdir/domain]),[
             case "${withval}" in
		/*) SITE_VIRTUAL_PWDDIR="${withval}";;
		*)  SITE_VIRTUAL_PWDDIR="\$(sysconfdir)/${withval}";;
	     esac],
             [SITE_VIRTUAL_PWDDIR="\$(sysconfdir)/domain"])
799 800
MU_ENABLE_SUPPORT(imap)
MU_ENABLE_SUPPORT(pop)
Alain Magloire authored
801
MU_ENABLE_SUPPORT(nntp)
802

803 804
AC_SUBST(MU_SMTP_PROGRAMS_BUILD)
AC_SUBST(MU_SMTP_DEJATOOL)
805

806 807 808
MU_ENABLE_SUPPORT(smtp,
                  [MU_SMTP_PROGRAMS_BUILD='$(MU_SMTP_PROGRAMS_LIST)'
                   MU_SMTP_DEJATOOL='$(SMTP_DEJATOOL)'])
809
MU_ENABLE_SUPPORT(sendmail)
810

811 812
MU_ENABLE_SUPPORT(prog)

813
MU_ENABLE_SUPPORT(mh)
814

815
MU_ENABLE_SUPPORT(maildir)
816

817
# FIXME: Should be --with-radius 
818
MU_ENABLE_SUPPORT(radius,
819 820 821 822
                  [AM_GNU_RADIUS(1.6,
		                 [MU_AUTHLIBS="$MU_AUTHLIBS -lgnuradius"
				  mu_cv_enable_radius=yes],
				 [mu_cv_enable_radius=no])]) 
823

824 825 826
AC_ARG_ENABLE([experimental],
              AC_HELP_STRING([--enable-experimental],
                             [build experimental and/or unfinished utilities]),
827 828
              [mu_build_experimental="${enableval}"],
              [mu_build_experimental=no])
829

Jeff Bailey authored
830 831 832
if test x"$testpam" = x"yes"; then
	AC_CHECK_HEADERS(security/pam_appl.h)
	if test x"$ac_cv_header_security_pam_appl_h" = x"yes"; then
833
		AC_CHECK_LIB(dl, dlopen, [LDL=-ldl], [LDL=])
834
		AC_CHECK_LIB(pam, pam_start,
835
			[MU_AUTHLIBS="$MU_AUTHLIBS -lpam $LDL"
836
                         ac_cv_have_libpam="yes"],, $LDL)
837
		AC_DEFINE(USE_LIBPAM,1,[Enable use of PAM])
838
		status_pam=yes
Jeff Bailey authored
839
	fi
840 841
fi

842
AC_CHECK_HEADERS(crypt.h)
843 844 845 846 847 848 849 850 851 852
AC_CHECK_DECLS(crypt, , ,[
#include <unistd.h>
#ifdef HAVE_CRYPT_H
# include <crypt.h>
#endif])
AH_BOTTOM([
#if !HAVE_DECL_CRYPT
char *crypt(const char *key, const char *salt);
#endif])

853
AC_CHECK_LIB(crypt, crypt)
854

855 856
#When using thread support some platforms need -D_REENTRANT to get the
#right prototypes including errno.
857
dnl Check threading support
Alain Magloire authored
858 859
# We have to rearrange things a little, it appears that the new autoconf
# does not like long cascading AC_CHECK_LIB.
860
if test x"$usepthread" = x"yes"; then
861
	AC_CHECK_LIB(pthread, pthread_cancel, have_libpthread=yes,
Alain Magloire authored
862 863
		 have_libpthread=no)
        if test x"$have_libpthread" = x"yes"; then
864 865 866
		AC_CHECK_HEADERS(pthread.h,
                                 AC_DEFINE(WITH_PTHREAD,1,
                                           [Define this to enable POSIX threads safety]))
Alain Magloire authored
867
			LIBS="$LIBS -lpthread"
868
			AC_DEFINE(_REENTRANT,1,[Reentrant calls])
Alain Magloire authored
869 870
			AC_CHECK_FUNCS(pthread_rwlock_init)
	else
871 872
		AC_SEARCH_LIBS(pthread_cancel, pthread,
			[AC_CHECK_FUNCS(pthread_rwlock_init)
Alain Magloire authored
873
				AC_CHECK_HEADERS(pthread.h,
874 875 876
					AC_DEFINE(WITH_PTHREAD,1,
                                                  [Define this to enable POSIX threads safety]))
					AC_DEFINE(_REENTRANT,1,[Reentrant calls])])
Alain Magloire authored
877
	fi
878 879
fi

880 881
dnl Do we need extra libs for networking?
AC_CHECK_FUNC(gethostbyname, [true],
882
	AC_CHECK_LIB(nsl, gethostbyaddr, LIBS="-lnsl $LIBS"))
883 884

AC_CHECK_FUNC(socket, [true],
885
	AC_CHECK_LIB(socket, socket, LIBS="-lsocket $LIBS"))
886

887
dnl Check for Curses libs.
888 889 890 891
for lib in ncurses curses termcap
do
	AC_CHECK_LIB($lib, tputs, [CURSES_LIBS="-l$lib"; break])
done
892 893 894

AC_SUBST(CURSES_LIBS)

895
dnl Check for GNU Readline
896
AC_SUBST(READLINE_LIBS)
897

Jeff Bailey authored
898
if test x"$usereadline" = x"yes"; then
899 900 901

	dnl FIXME This should only link in the curses libraries if it's
	dnl really needed!
Alain Magloire authored
902

903 904 905 906
	saved_LIBS=$LIBS
	LIBS="$LIBS $CURSES_LIBS"
	AC_CHECK_LIB(readline, readline, mu_have_readline=yes)
	LIBS=$saved_LIBS
Alain Magloire authored
907

908 909
	if test x"$mu_have_readline" = x"yes"; then
		AC_CHECK_HEADERS(readline/readline.h,
910
			AC_DEFINE(WITH_READLINE,1,[Enable use of readline]))
911 912 913 914 915 916 917 918 919
			READLINE_LIBS="-lreadline $CURSES_LIBS"
			saved_LIBS=$LIBS
			LIBS="$LIBS $READLINE_LIBS"
			AC_CHECK_FUNCS(rl_completion_matches)
			LIBS=$saved_LIBS
	else
		AC_MSG_WARN(readline requested but does not seem to be installed)
	fi

Jeff Bailey authored
920
fi
921

922 923 924 925 926
AH_BOTTOM([
/* Newer versions of readline have rl_completion_matches */
#ifndef HAVE_RL_COMPLETION_MATCHES
# define rl_completion_matches completion_matches
#endif])
Jeff Bailey authored
927

928 929
dnl Check for DBM

930 931 932
AH_TEMPLATE([WITH_BDB],
            [Define to the major version of Berkeley DB library to use])

933
## Set the variable status_dbm to $1 if:
934 935 936 937 938 939 940 941 942 943
##
##  1. Function $3 is defined in the library $2
##  2. Header file db.h is available
##
## Then check if the major version, minor version and patchlevel of the
## library matches those from the header. If so, define WITH_BDB
## to the version (i.e. $1 with all dots removed). Otherwise, report
## an error and stop.
##
check_bdb() {
944 945
        ver=`echo $1 | tr -d '.'`
	major=`expr $ver : '\(.\).*'`
946
	AC_CHECK_LIB($2, $3,
947 948 949 950
                     [AC_CHECK_HEADERS(db.h)
                      if test $ac_cv_header_db_h = yes; then
                        LIBS="$LIBS -l$2"
                        MU_DB2_CURSOR
951
                        status_dbm=$1
952
                      fi])
953
	if test "$status_dbm" = no; then
954 955 956 957 958 959
		:
	else
	  AC_RUN_IFELSE(
           [AC_LANG_PROGRAM([#include "db.h"],
            [int v_major, v_minor, v_patch;
             db_version(&v_major, &v_minor, &v_patch);
960 961
             return !(DB_VERSION_MAJOR == $major
                       && v_major == DB_VERSION_MAJOR
962 963 964 965
                       && v_minor == DB_VERSION_MINOR
                       && v_patch == DB_VERSION_PATCH);
            ])],
           [],
966 967
           [status_dbm=no])
           if test "$status_dbm" != no; then
968 969
	     AC_DEFINE_UNQUOTED(WITH_BDB,$ver)
           fi
970 971 972 973 974 975 976 977 978 979 980 981
	fi
}

## Check for the Berkeley DB library version $1, assuming Slackware-like
## installation layout (header files in /usr/incude/db$vn and library named
## libdb-$version.so, where $version is the library version and $vn is
## $version with all dots removed.
##
check_slackware_bdb() {
	dir=db`echo $1|tr -d '.'`
	save_CPPFLAGS=$CPPFLAGS
	CPPFLAGS="$CPPFLAGS -I/usr/include/$dir"
982
	check_bdb "$1" db-$1 db_create
983
	CPPFLAGS=$save_CPPFLAGS
984
	if test "$status_dbm" = "$1"; then
985 986 987 988
	    MU_COMMON_INCLUDES="$MU_COMMON_INCLUDES -I/usr/include/$dir"
	fi
}

989 990 991
case "$use_dbm" in
GDBM)
	AC_CHECK_LIB(gdbm, gdbm_open,
992 993 994
                     [AC_CHECK_HEADERS(gdbm.h,
                                       AC_DEFINE(WITH_GDBM,1,
                                                 [Enable use of GNU DBM library]))
995
                     LIBS="$LIBS -lgdbm"
996
                     status_dbm="GDBM"]);;
997

998 999
BDB2)   check_bdb 2 db db_open
        test -n "$status_dbm" && status_dbm="Berkeley DB v. $status_dbm";;
1000

1001 1002 1003 1004 1005 1006 1007
BDB)    for version in 4 3 2
	do
		case $version in
		4|3) func=db_create;;
		2)   func=db_open;;
		esac
		check_bdb $version db $func
1008 1009
		if test "$status_dbm" != no; then
                   status_dbm="Berkeley DB v. $status_dbm"
1010 1011 1012
		   break;
		fi
	done;;
1013 1014 1015 1016 1017

BDB=*)
	name=`expr $use_dbm : 'BDB=\(.*\)'`
	case $name in
	[[0-9]]*)  check_slackware_bdb $name;;
1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029
	*)	   for version in 4 3 2
	           do
			case $version in
			4|3) func=db_create;;
			2)   func=db_open;;
			esac
			check_bdb $version $name $func
			if test "$status_dbm" != no; then
		           status_dbm="Berkeley DB v. $status_dbm"
			   break;
			fi
		   done
1030 1031 1032 1033
		   ;;
	esac
        ;;

1034 1035
NDBM)
	AC_CHECK_LIB(ndbm, dbm_open,
1036 1037 1038
                     [AC_CHECK_HEADERS(ndbm.h,
                                       AC_DEFINE(WITH_NDBM,1,
                                                 [Enable use of NDBM]))
1039
                     LIBS="$LIBS -lndbm"
1040
                     status_dbm="NDBM"]);;
1041 1042 1043 1044 1045 1046 1047 1048

TC)
	AC_CHECK_LIB(tokyocabinet, tchdbnew,
                     [AC_CHECK_HEADERS(tchdb.h,
                                       AC_DEFINE(WITH_TOKYOCABINET,1,
                                                 [Enable use of Tokyo Cabinet]))
                     LIBS="$LIBS -ltokyocabinet -lz -lbz2 -lrt"
                     status_dbm="Tokyo Cabinet"]);;
1049
esac
1050

1051 1052 1053 1054 1055
AC_SUBST(POPAUTH)
if test "$status_dbm" != no; then
  POPAUTH='popauth$(EXEEXT)'
fi

1056
dnl Check for Guile
1057
AC_SUBST(GUILE_BINDIR)
Sergey Poznyakoff authored
1058
AC_SUBST(LIBMU_SCM)
1059
AC_SUBST(LIBMU_SCM_DEPS)
1060 1061 1062
AC_SUBST(MU_GUILE_SITE_DIR)
AC_SUBST(MU_GUILE_SIEVE_MOD_DIR)
AC_SUBST(MU_GUILE_SIEVE_MOD_DATA)
1063

1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095
if test "$useguile" != "no"; then
  MU_CHECK_GUILE(1.8,
         [useguile=yes
   	  AC_DEFINE(WITH_GUILE,1,[Enable Guile support])
          GUILE_BINDIR=`guile-config info bindir`
          LIBMU_SCM=../libmu_scm/libmu_scm.la
          LIBMU_SCM_DEPS='${MU_LIB_MBOX} ${MU_LIB_IMAP} ${MU_LIB_POP} ${MU_LIB_MH} ${MU_LIB_MAILDIR} ${MU_LIB_MAILER}'
          MU_GUILE_SITE_DIR='$(GUILE_SITE)/$(PACKAGE)'
          MU_GUILE_SIEVE_MOD_DIR='$(GUILE_SITE)/sieve-modules'
          MU_GUILE_SIEVE_MOD_DATA='$(MU_GUILE_SIEVE_MOD_DATA_X)'
  ],[useguile=no])

 if test "$useguile" = "yes"; then
  AC_ARG_WITH([guiledir],
           AC_HELP_STRING([--with-guiledir=DIR],
                          [Specify the directory to install guile modules to]),
           [case $withval in
            /*)  GUILE_SITE=$withval;;
            yes) GUILE_SITE=`$GUILE_CONFIG info pkgdatadir`/site;;
            *)   AC_MSG_ERROR([Argument to --with-guiledir must be an absolute directory name]);;
            esac],
            [GUILE_SITE=`$GUILE_CONFIG info pkgdatadir`/site
             pfx=$prefix
             test "$pfx" = NONE && pfx=$ac_default_prefix
             case $GUILE_SITE in
             $pfx/*) ;; # OK
             *)  AC_MSG_WARN([guile site directory "$GUILE_SITE" lies outside your current prefix ($pfx).])
                 GUILE_SITE='$(pkgdatadir)/$(VERSION)/guile'
                 AC_MSG_WARN([Falling back to ${GUILE_SITE} instead. Use --with-guiledir to force using site directory.])
                 ;;
             esac])
 fi 
1096 1097
fi

1098 1099
AM_CONDITIONAL([MU_COND_LIBMU_SCM],[test "$useguile" = "yes"])

1100 1101
AC_SUBST(GUILE_SITE)

1102 1103 1104 1105 1106 1107 1108 1109
dnl Check for Emacs site-lisp directory
AM_PATH_LISPDIR

if test "$EMACS" != "no"; then
	lisp_LISP='$(LISPSRC)'
fi
AC_SUBST(lisp_LISP)

1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120
# Check for Python
AC_ARG_WITH([python],
            AC_HELP_STRING([--without-python],
                           [do not build Python interface]),
            [
case "${withval}" in
  yes) status_python=yes ;;
  no)  status_python=no ;;
  *)   AC_MSG_ERROR(bad value ${withval} for --without-python) ;;
esac],[status_python=yes])

1121 1122 1123
AC_SUBST(PYTHON_LIBS)
AC_SUBST(PYTHON_INCLUDES)

1124 1125 1126 1127 1128 1129
if test "$status_python" = yes; then
  AM_PATH_PYTHON(2.5.0,, [status_python=no])
  if test "$status_python" = yes; then
    AC_ARG_VAR([PYTHON_CONFIG], [The name of python-config binary])
    AC_PATH_PROG([PYTHON_CONFIG], python-config)
    if test -n "$PYTHON_CONFIG"; then
1130 1131
      PYTHON_LIBS=`python-config --libs`
      PYTHON_INCLUDES=`python-config --includes`
1132 1133 1134 1135 1136
    else
      status_python=no     
    fi

    if test "$status_python" = yes; then
1137
      AC_DEFINE(WITH_PYTHON,1,[Enable Python support])
1138
      MU_LIB_PY='${top_builddir}/python/libmu_py/libmu_py.la'
1139 1140 1141
    fi
  fi
fi
1142
AM_CONDITIONAL([MU_COND_PYTHON], [test "$status_python" = yes])
1143

1144
AC_SUBST(MU_CXX_EXAMPLES_BUILD)
1145
MU_ENABLE_SUPPORT(cxx,
1146
  	          [MU_CXX_EXAMPLES_BUILD='$(MU_CXX_EXAMPLES_LIST)'])
1147
AM_CONDITIONAL([MU_COND_LIBMU_CPP], [test "$mu_cv_enable_cxx" = yes])
1148

1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171
# Default mailbox record
# Note: 1. Support for mbox type is always enabled.
#       2. Only local mailbox types are allowed for MU_DEFAULT_SCHEME
AC_ARG_VAR([MU_DEFAULT_SCHEME],
           [Default mailbox record. Allowed values are: mbox (default), mh, and maildir.])
if test -z "$MU_DEFAULT_SCHEME"; then
  MU_DEFAULT_SCHEME=mbox
fi  
case $MU_DEFAULT_SCHEME in
mbox)
   ;;
mh|maildir)
   eval testval=\$mu_cv_enable_$MU_DEFAULT_SCHEME
   if test "$testval" != yes; then
     AC_MSG_ERROR([Cannot set default mailbox record type: support for $MU_DEFAULT_SCHEME is disabled])
   fi
   ;;
*) AC_MSG_ERROR([Unknown or not allowed mailbox scheme: $MU_DEFAULT_SCHEME]);;
esac
AC_DEFINE_UNQUOTED(MU_DEFAULT_SCHEME, "$MU_DEFAULT_SCHEME",
                   [Default mailbox scheme.])
AC_SUBST(MU_DEFAULT_RECORD,mu_${MU_DEFAULT_SCHEME}_record)

1172 1173 1174 1175 1176 1177 1178 1179
AC_ARG_VAR([DEFAULT_CUPS_CONFDIR],
           [Set the location of CUPS configuration directory. Default is \$sysconfdir/cups])

AC_SUBST(DEFAULT_CUPS_CONFDIR)
if test -z "$DEFAULT_CUPS_CONFDIR"; then
  DEFAULT_CUPS_CONFDIR='$(sysconfdir)/cups'
fi

1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190
dnl ***********************************************************************
dnl Configure particular utilities
dnl ***********************************************************************

MU_ENABLE_BUILD(frm)
MU_ENABLE_BUILD(pop3d)
MU_ENABLE_BUILD(imap4d)
MU_ENABLE_BUILD(comsat)
MU_ENABLE_BUILD(maidag)
MU_ENABLE_BUILD(mail)
MU_ENABLE_BUILD(sieve)
1191
MU_ENABLE_BUILD(guimb,,,[test "$useguile" = yes])
1192 1193 1194 1195 1196 1197
MU_ENABLE_BUILD(messages)
MU_ENABLE_BUILD(readmsg)
MU_ENABLE_BUILD(dotlock)
MU_ENABLE_BUILD(movemail)
MU_ENABLE_BUILD(mimeview)

1198
MU_ENABLE_BUILD(mh,,,[test "$mu_cv_enable_mh" = yes])
1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212

AC_SUBST(MH_BIN_DIR)

AC_ARG_WITH([mh-bindir],
	    AC_HELP_STRING([--with-mh-bindir],
                           [Set the directory where to install the MH binaries. If it starts with '/' it is taken as an absolute path specification, otherwise ${prefix} is prepended to it. (Default: ${exec_prefix}/bin/mu-mh)]),
		    [case "${withval}" in
		     /*)  MH_BIN_DIR=${withval};;
                     *)   MH_BIN_DIR="\${prefix}/${withval}";;
                     esac],
                    [MH_BIN_DIR='${exec_prefix}/bin/mu-mh'])



1213 1214 1215 1216 1217 1218 1219
dnl Make sysconfdir available to the application
dnl This must be done LAST, since CPPFLAGS is passed by configure
dnl to build tests, but this relies on being run in make to
dnl get sysconfdir expanded.

CPPFLAGS="$CPPFLAGS -DSYSCONFDIR=\\\"\$(sysconfdir)\\\""

1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237
# Doc hints.
# Select a rendition level:
#  DISTRIB for stable releases (at most one dot in the version number)
#  and maintenance releases (two dots, patchlevel < 50)
#  PROOF for alpha releases.
#  PUBLISH can only be required manually when running make in doc/
AC_SUBST(RENDITION)
case `echo $VERSION|sed  's/[[^.]]//g'` in
""|".")  RENDITION=DISTRIB;;
"..")  if test `echo $VERSION | sed  's/.*\.//'` -lt 50; then
	 RENDITION=DISTRIB
       else
         RENDITION=PROOF
       fi;;
*)     RENDITION=PROOF;;
esac


1238 1239 1240 1241 1242 1243
AC_CONFIG_COMMANDS([status],[
cat <<EOF

*******************************************************************
GNU Mailutils configured with the following settings:

1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254
Default mailbox scheme ........ $status_scheme
Use PAM ....................... $status_pam
Use -ltdl ..................... $status_ltdl
Use DBM ....................... $status_dbm
Use GNU TLS ................... $status_gnutls
Use GSASL ..................... $status_gsasl
Use GSSAPI .................... $status_gssapi
Use TCP wrappers .............. $status_tcpwrap
Pthread support ............... $status_pthread
Readline support .............. $status_readline
MySQL support ................. $status_mysql
1255
PostgreSQL support ............ $status_pgsql
1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271
LDAP support .................. $status_ldap
Radius support ................ $status_radius
Support for virtual domains ... $status_virtual_domains

Interfaces:

Guile ......................... $status_guile
C++ ........................... $status_cxx
Python ........................ $status_python

Mailbox formats:

IMAP .......................... $status_imap
POP ........................... $status_pop
MH ............................ $status_mh
maildir ....................... $status_maildir
1272 1273 1274

Mailers:

1275 1276
SMTP .......................... $status_smtp
Sendmail ...................... $status_sendmail
1277 1278 1279 1280 1281 1282

*******************************************************************

Before proceeding, verify if these satisfy your requirements. 
EOF
],
1283 1284
[status_scheme=$MU_DEFAULT_SCHEME
status_pam=$status_pam
1285
status_ltdl=$status_ltdl
1286
status_dbm="$status_dbm"
1287
status_ldap=$status_ldap
1288 1289 1290 1291
status_gnutls=$WITH_GNUTLS
status_gsasl=$status_gsasl
status_gssapi=$WITH_GSSAPI
status_guile=$useguile
1292
status_python=$status_python
1293
status_cxx=$mu_cv_enable_cxx
1294
status_tcpwrap=$status_tcpwrap
1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308
status_pthread=$usepthread
status_readline=$usereadline
status_mysql=$status_mysql
status_pgsql=$status_pgsql
status_radius=$mu_cv_enable_radius
status_virtual_domains=$mu_cv_enable_virtual_domains
status_imap=$mu_cv_enable_imap
status_pop=$mu_cv_enable_pop
status_mh=$mu_cv_enable_mh
status_maildir=$mu_cv_enable_maildir
status_smtp=$mu_cv_enable_smtp
status_sendmail=$mu_cv_enable_sendmail
])

1309
dnl Output Makefiles
1310 1311 1312
AC_CONFIG_FILES([
 include/confpaths.h
 Makefile
1313
 sql/Makefile
1314
 comsat/Makefile
1315
 config/Makefile
1316 1317 1318 1319 1320 1321
 doc/Makefile
 doc/man/Makefile
 doc/rfc/Makefile
 doc/texinfo/Makefile
 dotlock/Makefile
 examples/Makefile
Wojciech Polak authored
1322 1323
 examples/config/Makefile
 examples/cpp/Makefile
1324
 examples/python/Makefile
Wojciech Polak authored
1325
 examples/scheme/Makefile
1326 1327 1328 1329 1330 1331 1332 1333
 frm/Makefile
 frm/testsuite/Makefile
 guimb/Makefile
 guimb/scm/Makefile
 imap4d/Makefile
 imap4d/testsuite/Makefile
 include/Makefile
 include/mailutils/Makefile
Alain Magloire authored
1334
 include/mailutils/sys/Makefile
1335
 include/mailutils/cpp/Makefile
1336
 lib/Makefile
Wojciech Polak authored
1337 1338 1339
 libmu_argp/Makefile
 libmu_auth/Makefile
 libmu_cfg/Makefile
1340
 libmu_cpp/Makefile
1341
 libmu_scm/Makefile
Wojciech Polak authored
1342 1343
 libmu_sieve/Makefile
 libmu_sieve/extensions/Makefile
1344 1345 1346 1347
 libproto/Makefile
 libproto/mbox/Makefile
 libproto/mh/Makefile
 libproto/maildir/Makefile
Wojciech Polak authored
1348
 libproto/mailer/Makefile
1349 1350 1351 1352
 libproto/pop/Makefile
 libproto/nntp/Makefile
 libproto/imap/Makefile
 libproto/include/Makefile
1353
 maidag/Makefile
1354 1355
 mail/Makefile
 mail/testsuite/Makefile
Sam Roberts authored
1356
 mailbox/Makefile
1357
 mailbox/testsuite/Makefile
Sam Roberts authored
1358
 messages/Makefile
1359
 messages/testsuite/Makefile
1360
 mh/Makefile
Sergey Poznyakoff authored
1361
 mimeview/Makefile
uid65697 authored
1362
 movemail/Makefile
1363 1364 1365
 po/Makefile.in
 pop3d/Makefile
 pop3d/testsuite/Makefile
1366
 python/Makefile
1367
 python/libmu_py/Makefile
1368
 python/mailutils/Makefile
1369 1370
 readmsg/Makefile
 readmsg/testsuite/Makefile
1371 1372
 mu-aux/Makefile
 mu-aux/mailutils.spec
1373 1374 1375
 sieve/Makefile
 sieve/testsuite/Makefile
 testsuite/Makefile
1376 1377
 ])
AC_OUTPUT
1378