configure.in 4.4 KB
dnl Process this file with autoconf to procude a configure script. -*-m4-*-
AC_INIT(mailbox/mailbox.c)
AM_INIT_AUTOMAKE(mailutils, 0.0.9)
AM_CONFIG_HEADER(config.h)

dnl Check for programs
AC_PROG_CC
AC_PROG_INSTALL
AC_PROG_LN_S
AM_PROG_LIBTOOL

dnl Check for arguments
AC_ARG_ENABLE(pam,
 [  --disable-pam           disable pam],
 [case "${enableval}" in
  yes) testpam=yes ;;
  no)  testpam=no ;;
  *)   AC_MSG_ERROR(bad value ${enableval} for --disable-pam) ;;
 esac],[testpam=yes])

AC_ARG_ENABLE(pthread,
 [  --disable-pthread       disable pthread],
 [case "${enableval}" in
  yes) usepthread=yes ;;
  no)  usepthread=no ;;
  *)   AC_MSG_ERROR(bad value ${enableval} for --disable-pthread) ;;
  esac],[usepthread=yes])

AC_ARG_WITH(readline,
 [  --without-readline      do not use readline],
 [case "${withval}" in
  yes) usereadline=yes ;;
  no)  usereadline=no ;;
  *)   AC_MSG_ERROR(bad value ${withval} for --without-readline) ;;
  esac],[usereadline=yes])

AC_ARG_WITH(db2,
 [  --with-db2              use Berkeley DB],
 [case "${withval}" in
  yes) usedb2=yes ;;
  no)  usedb2=no ;;
  *)   AC_MSG_ERROR(bad value ${withval} for --with-db) ;;
  esac],[usedb2=no])

AC_MSG_CHECKING(for log facility)
log_facility="LOG_MAIL"
AC_ARG_WITH(log-facility,
 [  --with-log-facility=facility   enable logging to the given facility],
 AC_TRY_COMPILE([#include <syslog.h>], int lf = $withval,
	log_facility=$withval))
AC_DEFINE_UNQUOTED(LOG_FACILITY, $log_facility)
AC_MSG_RESULT($log_facility)

dnl Check for headers
AC_HEADER_STDC
AC_HEADER_DIRENT
AM_C_PROTOTYPES
AC_CHECK_HEADERS(argp.h errno.h fcntl.h inttypes.h libgen.h limits.h malloc.h \
 paths.h shadow.h stdarg.h stdio.h stdlib.h string.h strings.h sys/file.h syslog.h \
 unistd.h)

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
AC_TYPE_SIGNAL
AC_DECL_SYS_SIGLIST

dnl Check for working functions

jm_FUNC_MALLOC
jm_FUNC_REALLOC
AC_FUNC_ALLOCA
# Not use.
#AC_FUNC_MEMCMP
AC_FUNC_MMAP
AC_FUNC_FNMATCH
if test "$ac_cv_func_fnmatch_works" = "no"; then
: LIBOBJS="$LIBOBJS fnmatch.o"
fi
AC_REPLACE_FUNCS(setenv snprintf strtok_r strncasecmp strcasecmp strsignal \
 vasprintf)
AC_CHECK_FUNCS(mkstemp sigaction sysconf)

dnl Check for libraries
AC_CHECK_FUNCS(argp_parse)
if test x"$ac_cv_func_argp_parse" != xyes; then
	AC_REPLACE_FUNCS(strndup strnlen strchrnul)
	ARGPLIBS="../argp/libargp.a"
	ARGPLIB="libargp.a"
	ARGPINCS='-I$(top_srcdir)/argp'
	AC_SUBST(ARGPLIBS)
	AC_SUBST(ARGPLIB)
	AC_SUBST(ARGPINCS)
fi

dnl Use either PAM or CRYPT, not both.
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
		AC_CHECK_LIB(pam, pam_start,
			AUTHLIBS="-lpam -ldl" ac_cv_have_libpam="yes",, -ldl)
		AC_DEFINE(USE_LIBPAM)
		AM_CONDITIONAL(USE_LIBPAM, test x"$ac_cv_have_libpam" != xno)
	fi
fi

if test x"$ac_cv_have_libpam" != x"yes"; then
	AC_CHECK_FUNCS(crypt)
	if test x"$ac_cv_func_crypt" = x"no"; then
		AC_CHECK_LIB(crypt, crypt, AUTHLIBS="-lcrypt",, -lcrypt)
	fi
fi
AC_SUBST(AUTHLIBS)

#When using thread support some platforms need -D_REENTRANT to get the
#right prototypes including errno.
dnl Check threading support
if test x"$usepthread" = x"yes"; then
	AC_CHECK_LIB(pthread, pthread_cancel, [AC_CHECK_HEADERS(pthread.h,
		AC_DEFINE(WITH_PTHREAD))
		LIBS="$LIBS -lpthread"
		AC_DEFINE(_REENTRANT)
		AC_CHECK_FUNCS(pthread_rwlock_init)],
		AC_SEARCH_LIBS(pthread_cancel, pthread,
			[AC_CHECK_FUNCS(pthread_rwlock_init)
			AC_CHECK_HEADERS(pthread.h, AC_DEFINE(WITH_PTHREAD))
			AC_DEFINE(_REENTRANT)]))
fi

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

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

dnl Check for GNU Readline
if test x"$usereadline" = x"yes"; then
	AC_CHECK_LIB(readline, readline,
		[AC_CHECK_HEADERS(readline/readline.h, AC_DEFINE(WITH_READLINE))
		LIBS="$LIBS -lreadline"])
fi

dnl Check for Berkeley DB
if test x"${usedb2}" = x"yes"; then
	AC_CHECK_LIB(db, db_open, [AC_CHECK_HEADERS(db.h, AC_DEFINE(WITH_BDB2))
		LIBS="$LIBS -ldb"])
fi

dnl Output Makefiles
AC_OUTPUT(Makefile mailutils.spec include/Makefile include/mailutils/Makefile
 m4/Makefile doc/Makefile argp/Makefile lib/Makefile mailbox/Makefile
 imap4d/Makefile mailbox/include/Makefile from/Makefile mail/Makefile
 pop3d/Makefile frm/Makefile)