dnl Process this file with autoconf to produce a configure script. dnl dnl $Id: configure.in,v 1.153 2007/10/14 00:19:54 mrsam Exp $ dnl dnl Copyright 1998 - 2007 Double Precision, Inc. See COPYING for dnl distribution information. AC_PREREQ(2.59) AC_INIT(courier-authlib, 0.60.2, [courier-users@lists.sourceforge.net]) AC_CONFIG_SRCDIR([courierauth.h]) AM_CONFIG_HEADER([courier_auth_config.h]) AM_INIT_AUTOMAKE >confdefs.h # Kill PACKAGE_ macros LPATH="$PATH:/usr/local/bin" dnl Checks for programs. AC_PROG_AWK AC_PROG_CC AC_PROG_CPP AC_PROG_INSTALL AC_PROG_LN_S AC_PROG_SYSCONFTOOL AC_LIBLTDL_INSTALLABLE AC_LIBTOOL_DLOPEN AM_PROG_LIBTOOL AC_SUBST(LTDLINCL) AC_SUBST(LIBLTDL) AC_PATH_PROGS(PERL, perl5 perl, perl, $LPATH) AC_PATH_PROGS(COURIERCONFIG, courier-config, courier-config, $LPATH) if test "$PERL" = "perl" then AC_MSG_ERROR(Perl is required) fi test "x$prefix" = xNONE && prefix=$ac_default_prefix test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' eval "prefix=$prefix" eval "exec_prefix=$exec_prefix" eval "sysconfdir=$sysconfdir" eval "bindir=$bindir" eval "sbindir=$sbindir" eval "localstatedir=$localstatedir" eval "libexecdir=$libexecdir" AC_ARG_WITH(redhat, [], [ redhat=$withval ], [redhat=no]) if test "$srcdir" = "." then case `./config.guess` in *-redhat-*) if test "$redhat" = "no" then hash='#' AC_MSG_WARN(=== I think you are trying to run this configure script) AC_MSG_WARN([=== on Red Hat/Fedora. You're doing too much work!]) AC_MSG_WARN([=== It's much faster to create installable binary RPMs]) AC_MSG_WARN([=== like this: http://www.courier-mta.org/FAQ.html${hash}rpm]) AC_MSG_WARN(=== When you do this you may find that RPM will tell you) AC_MSG_WARN([=== to install some other software first, before trying to]) AC_MSG_WARN([=== build this one, and even tell you the name of RPMs you]) AC_MSG_WARN([=== need to install from the distribution CD. That's much]) AC_MSG_WARN([=== easier than trying to figure out the same from some]) AC_MSG_WARN([=== cryptic error message.]) AC_MSG_WARN([]) AC_MSG_WARN([=== Even if you don't intend to use everything you need to]) AC_MSG_WARN([=== have in order to build via RPM, you should still do as]) AC_MSG_WARN([=== you're told. All the extra stuff (LDAP, SQL, etc...)]) AC_MSG_WARN([=== goes into RPM sub-packages, which do not need to be]) AC_MSG_WARN([=== installed.]) AC_MSG_WARN([=== But, if you insist, you can simply add '--with-redhat']) AC_MSG_WARN(=== parameter to this configure script and not see this) AC_MSG_WARN(=== error message. You should also do this when upgrading) AC_MSG_WARN([=== and you didn't use RPM with the older version.]) AC_MSG_ERROR(... in either case you better know what you're doing!) fi ;; *) ;; esac fi AC_PATH_PROGS(EXPECT, expect, expect, $LPATH) if test "$EXPECT" = "expect" then AC_MSG_WARN(-----------------------------------------------------) AC_MSG_WARN(expect not found - will not be able to change passwds) AC_MSG_WARN(in webmail) AC_MSG_WARN(-----------------------------------------------------) sleep 5 else AC_DEFINE_UNQUOTED(HAVE_EXPECT, 1, [ Whether expect(1) is installed ]) fi AC_PATH_PROGS(PASSWD, passwd, passwd, $LPATH) AC_SUBST(PASSWD) if test "$GCC" = "yes" then CFLAGS="$CFLAGS -Wall" fi CFLAGS="$CFLAGS -I.. -I${srcdir}/.." AC_MSG_CHECKING(whether -lm is needed for floor) AC_TRY_LINK_FUNC(floor, AC_MSG_RESULT(no), LIBM="-lm" AC_MSG_RESULT(yes)) AC_ARG_WITH(pkgconfdir, [ --with-pkgconfdir=d Install config files in directory ], [pkgconfdir="$withval"], [pkgconfdir="$sysconfdir/authlib"]) SASL_LIST="SASL(\"PLAIN\", authsasl_plain, authsaslclient_plain) SASL(\"LOGIN\", authsasl_login, authsaslclient_login)" dnl ######################################################################### dnl Check if the MD5 library is available dnl ######################################################################### if test -d ${srcdir}/md5 then MD5=1 AC_DEFINE_UNQUOTED(HAVE_MD5LIB, 1, [ Whether we have the MD5 library available ]) MD5LIB=md5/libmd5.la if test -d ${srcdir}/md5 then SASL_LIST="SASL(\"CRAM-MD5\", authsasl_cram, authsaslclient_crammd5) $SASL_LIST" fi else MD5LIB="" MD5=0 fi AC_SUBST(MD5LIB) AM_CONDITIONAL(HAVE_MD5, test "$MD5" = 1) dnl ######################################################################### dnl Check if the SHA1 library is available dnl ######################################################################### if test -d ${srcdir}/sha1 then SHA1=1 AC_DEFINE_UNQUOTED(HAVE_SHA1LIB, 1, [ Whether we have the SHA1 library available ]) SHA1LIB=sha1/libsha1.la if test -d ${srcdir}/sha1 then SASL_LIST="SASL(\"CRAM-SHA1\", authsasl_cram, authsaslclient_cramsha1) $SASL_LIST" SASL_LIST="SASL(\"CRAM-SHA256\", authsasl_cram, authsaslclient_cramsha256) $SASL_LIST" fi else SHA1LIB="" SHA1=0 fi AC_SUBST(SHA1LIB) AM_CONDITIONAL(HAVE_SHA1, test "$SHA1" = 1) dnl ######################################################################### dnl Check if the HMAC library is available dnl ######################################################################### if test -d ${srcdir}/libhmac then HMAC=1 AC_DEFINE_UNQUOTED(HAVE_HMACLIB, 1, [ Whether we have the HMAC library available ]) HMACLIB=libhmac/libhmac.la else HMACLIB="" HMAC=0 fi AC_SUBST(HMACLIB) AM_CONDITIONAL(HAVE_HMACLIB, test "$HMAC" = 1) saveLIBS="$LIBS" NETLIBS="" USENSL=no AC_CHECK_LIB(socket,socket,result=yes,result=no) if test $result = yes; then NETLIBS="-lsocket" else AC_CHECK_LIB(socket,socket,result=yes,result=no,-lnsl) if test $result = yes; then NETLIBS = "-lsocket -lnsl" USENSL=yes else AC_CHECK_LIB(socket,connect,result=yes,result=no) if test $result = yes; then NETLIBS="-lsocket" else AC_CHECK_LIB(socket,connect,result=yes,result=no,-lnsl) if test $result = yes; then NETLIBS="-lsocket -lnsl" USENSL=yes fi fi fi fi if test $USENSL != yes; then LIBS="$LIBS $NETLIBS" AC_TRY_LINK_FUNC(inet_addr, [ : ], [ AC_CHECK_LIB(nsl,inet_addr,result=yes,result=no) if test $result = yes; then NETLIBS="$NETLIBS -lnsl" fi ]) fi LIBS="$saveLIBS" AC_SUBST(NETLIBS) dnl ######################################################################### dnl Prepare authuserdb module if userdb library is available dnl ######################################################################### AC_ARG_WITH(db, [ --with-db=gdbm Use the GDBM library. --with-db=db Use the libdb.a library.], db="$withval", needs_withdb=1) case "$db" in gdbm) ;; db) ;; "") ;; *) AC_MSG_ERROR(Invalid --with-db option.) ;; esac saveLIBS="$LIBS" if test "$db" != "db" then AC_CHECK_LIB(gdbm, gdbm_open, [ LIBGDBM=-lgdbm ; LIBS="-lgdbm $LIBS" ]) AC_CHECK_FUNC(gdbm_open, [ HAVE_GDBM=y ]) fi LIBS="$saveLIBS" if test "$db" != "gdbm" then AC_CHECK_LIB(db, dbopen, [ LIBDB=-ldb ; LIBS="-ldb $LIBS" ], [ AC_CHECK_LIB(db, db_open, [ LIBDB=-ldb ; LIBS="-ldb $LIBS"], [ AC_CHECK_LIB(db, db_env_create, [ LIBDB=-ldb; LIBS="-ldb $LIBS"]) ] )]) AC_CHECK_FUNC(dbopen, HAVE_BDB=1) AC_CHECK_FUNC(db_open, HAVE_BDB=1) AC_CHECK_FUNC(db_env_create, HAVE_BDB=1) fi LIBS="$saveLIBS" if test "$HAVE_GDBM$HAVE_BDB" = "" then AC_MSG_ERROR(Cannot find either the gdbm or the db library.) fi USE_GDBM=0 USE_DB=0 if test "$HAVE_GDBM" = "y" then LIBDB="" USE_GDBM=1 DBSUBDIR=gdbmobj if test "$needs_withdb" = 1 then ac_configure_args="$ac_configure_args --with-db=gdbm" fi dblibrary=gdbmobj/libgdbmobj.la else LIBGDBM="" USE_DB=1 DBSUBDIR=bdbobj if test "$needs_withdb" = 1 then ac_configure_args="$ac_configure_args --with-db=db" fi dblibrary=bdbobj/libbdbobj.la fi AC_SUBST(DBSUBDIR) AC_SUBST(USE_GDBM) AC_SUBST(USE_DB) AC_SUBST(LIBDB) AC_SUBST(LIBGDBM) AC_ARG_WITH(authuserdb, [ --without-authuserdb Do not include the authuserdb module ], doauthuserdb="$withval", doauthuserdb="no" if test -d ${srcdir}/userdb then doauthuserdb="yes" fi) if test "$doauthuserdb" = "no" then AUTHUSERDB="" else AUTHUSERDB="authuserdb" LIBAUTHUSERDB="libauthuserdb.la" fi AC_ARG_WITH(makedatprog, [ ], [ : ], [ ac_configure_args="$ac_configure_args --with-makedatprog=$libexecdir/courier-authlib/makedatprog" ]) cat >dbobj.config < #if HAVE_NETINET_IN_H #include #endif #include void (*func)()= (void (*)())res_query; ], [ (*func)(); ]), AC_MSG_RESULT(no), [ LIBS="-lresolv $LIBS" AC_LINK_IFELSE(AC_LANG_PROGRAM([ #include #if HAVE_NETINET_IN_H #include #endif #include void (*func)()= (void (*)())res_query; ], [ (*func)(); ]), [ LDAPLIBS="-lresolv $LDAPLIBS" HAVE_LDAP=1 AC_MSG_RESULT(yes) ], AC_MSG_ERROR(Cannot find function res_query)) ]) AC_CHECK_LIB(lber, ber_scanf, [ LDAPLIBS="-llber $LDAPLIBS" LIBS="-llber $LIBS" ]) AC_CHECK_LIB(ldap, ldap_open, [ LDAPLIBS="-lldap $LDAPLIBS" ; LIBS="-lldap $LIBS" ]) AC_CHECK_FUNC(ldap_search_st, HAVE_LDAP=1, HAVE_LDAP=0) AC_CHECK_FUNC(ldap_start_tls_s, HAVE_LDAP_TLS=1, HAVE_LDAP_TLS=0) AC_CHECK_FUNC(ldap_result2error, HAVE_LDAP_RESULT2ERROR=1, HAVE_LDAP_RESULT2ERROR=0) AC_CHECK_FUNC(ldap_parse_result, HAVE_LDAP_PARSE_RESULT=1, HAVE_LDAP_PARSE_RESULT=0) LIBS="$saveLIBS" fi AC_ARG_WITH(authldaprc, [ --with-authldaprc=filename Expect to find authldaprc here ], authldaprc="$withval", authldaprc="$pkgconfdir/authldaprc") AC_SUBST(authldaprc) LIBAUTHLDAP="" if test "$HAVE_LDAP" = 1 then LIBAUTHLDAP="libauthldap.la" else authldaprc="" fi AC_SUBST(LDAPLIBS) AC_SUBST(LIBAUTHLDAP) AM_CONDITIONAL(HAVE_LDAP, test "$HAVE_LDAP" = 1) AC_DEFINE_UNQUOTED(HAVE_LDAP_TLS,$HAVE_LDAP_TLS, [ Whether we have ldap_start_tls_s ]) AC_DEFINE_UNQUOTED(HAVE_LDAP_RESULT2ERROR, $HAVE_LDAP_RESULT2ERROR, [ Whether we have ldap_result2error() function ]) AC_DEFINE_UNQUOTED(HAVE_LDAP_PARSE_RESULT, $HAVE_LDAP_PARSE_RESULT, [ Whether we have ldap_parse_result() function]) dnl ######################################################################### dnl Prepare authpwd module dnl ######################################################################### AC_ARG_WITH(authpwd, [ --without-authpwd Do not include the authpwd module ], doauthpwd="$withval", doauthpwd="yes" test "$HAVE_PAM" = 1 && doauthpwd="no" test "$HAVE_LDAP" = 1 && doauthpwd="no" ) HAVE_PWD=1 if test "$doauthpwd" = "no" then HAVE_PWD=0 fi AC_CHECK_FUNCS(endpwent) dnl ######################################################################### dnl Prepare authshadow module if shadow functions are available. dnl ######################################################################### AC_ARG_WITH(authshadow, [ --without-authshadow Do not include the authshadow module ], doauthshadow="$withval", doauthshadow="yes" test "$HAVE_PAM" = 1 && doauthshadow="no" test "$HAVE_LDAP" = 1 && doauthshadow="no") AC_CHECK_HEADERS(shadow.h) saveLIBS="$LIBS" SHADOWLIBS="" AC_CHECK_LIB(shadow, getspent, [ SHADOWLIBS="-lshadow" ; LIBS="-lshadow $LIBS" ]) AC_CHECK_FUNCS(endspent getspent) LIBS="$saveLIBS" if test "$doauthshadow" = "no" then HAVE_SHADOW=0 else saveLIBS="$LIBS" AC_CHECK_LIB(shadow, getspent) AC_CHECK_FUNC(getspent, HAVE_SHADOW=1, HAVE_SHADOW=0) LIBS="$saveLIBS" fi LIBAUTHSHADOW="" if test "$HAVE_SHADOW" = 1 then LIBAUTHSHADOW="libauthshadow.la" fi AC_SUBST(SHADOWLIBS) AC_SUBST(LIBAUTHSHADOW) LIBAUTHPWD="" if test "$HAVE_PWD" = 1 then LIBAUTHPWD="libauthpwd.la" fi AC_SUBST(LIBAUTHPWD) dnl ######################################################################### dnl Prepare authvchkpw module if vchkpw is installed. dnl ######################################################################### changequote(<<,>>) vpopmail_home=`$PERL -e '@a=getpwnam("vpopmail"); print "$a[7]";'` changequote([,]) AC_ARG_WITH(authvchkpw, [ --without-authvchkpw Do not include the authvchkpw module ], doauthvchkpw="$withval", doauthvchkpw=no if test "$vpopmail_home" != "" then doauthvchkpw=yes fi) if test "$doauthvchkpw" = "no" then HAVE_VCHKPW=0 vpopmail_home=. else HAVE_VCHKPW=1 cat < #endif #if HAVE_UNISTD_H #include #endif int crypt(int, int); ], [], userdb_cv_NEED_CRYPT_PROTOTYPE=1, userdb_cv_NEED_CRYPT_PROTOTYPE=0 ) ) AC_DEFINE_UNQUOTED(NEED_CRYPT_PROTOTYPE, $userdb_cv_NEED_CRYPT_PROTOTYPE, [ Whether we must a prototype for crypt()] ) AC_SUBST(CRYPTLIBS) dnl ######################################################################### dnl Prepare the authdaemon module. dnl ######################################################################### AC_ARG_WITH(authdaemonrc, [ --with-authdaemonrc=filename Expect to find authdaemonrc here ], authdaemonrc="$withval", authdaemonrc="$pkgconfdir/authdaemonrc") AC_SUBST(authdaemonrc) AC_ARG_WITH(authdaemonvar, [ --with-authdaemonvar=directory Directory where authdaemon.pid and the listening socket is created], authdaemonvar="$withval", authdaemonvar="$localstatedir/spool/authdaemon") AC_SUBST(authdaemonvar) AC_SUBST(LIBM) AC_DEFINE_UNQUOTED(SASL_LIST,$SASL_LIST, [ This macro is used to build the list of SASL modules ]) rm -f authdaemonrc.h authldaprc.h authmysqlrc.h authpgsqlrc.h vpopmail_config.h dnl dnl Need to settle on our uid/gids here dnl result="" if test -x "$COURIERCONFIG" then $COURIERCONFIG >conftest.out || exit 1 sed -n '/^mail/p' conftest2.out || exit 1 . conftest2.out rm -f conftest.out conftest2.out cmailuser="$mailuser" cmailgroup="$mailgroup" result=" (from courier-config)" fi if test -x "$bindir/courierauthconfig" then $bindir/courierauthconfig --configfiles >conftest.out || exit 1 sed -n '/^mail/p' conftest2.out || exit 1 . conftest2.out rm -f conftest.out conftest2.out cmailuser="$mailuser" cmailgroup="$mailgroup" result=" (from previous courierauthconfig)" fi changequote() LB='[' RB=']' changequote([,]) AC_MSG_CHECKING(for mail userid) AC_ARG_WITH(mailuser,[ --with-mailuser=user Specify mail user name (defaults to courier, daemon, admin, bin, or root)], mailuser="$withval", if test "$cmailuser" = "" then AC_TRY_RUN([ #include #include #include static const char *ids $LB $RB={"courier","daemon","adm","bin","root", 0}; int main() { int i; FILE *f; char *p; for (i=0; ids $LB i $RB; i++) if (getpwnam(ids $LB i $RB)) break; f=fopen("conftest.out", "w"); if (f && ids $LB i $RB) { fprintf(f, "%s\n", ids $LB i $RB); fclose(f); exit(0); } fclose(f); exit (1); return (1); } ], mailuser=`cat conftest.out`, AC_MSG_ERROR(Cannot determine mail user, use --with-mailuser.), AC_MSG_ERROR(Must use --with-mailuser when cross compiling.)) else mailuser="$cmailuser" fi ac_configure_args="$ac_configure_args --with-mailuser=$mailuser") AC_MSG_RESULT([$mailuser $result]) AC_MSG_CHECKING(for mail group id) AC_ARG_WITH(mailgroup, [ --with-mailgroup=group Specify mail group name (defaults to courier, daemon, sys, adm, or root)], mailgroup="$withval", if test "$cmailgroup" = "" then AC_TRY_RUN([ #include #include #include static const char *ids $LB $RB={"courier", "daemon","sys","adm", "root", 0}; int main() { int i; FILE *f; for (i=0; ids $LB i $RB; i++) if (getgrnam(ids $LB i $RB)) break; f=fopen("conftest.out", "w"); if (f && ids $LB i $RB) { fprintf(f, "%s\n", ids $LB i $RB); fclose(f); exit(0); } fclose(f); exit (1); return (1); } ], mailgroup=`cat conftest.out`, AC_MSG_ERROR(Cannot determine mail group, use --with-mailgroup.), AC_MSG_ERROR(Must use --with-mailgroup when cross compiling.)) else mailgroup="$cmailgroup" fi ac_configure_args="$ac_configure_args --with-mailgroup=$mailgroup" ) AC_MSG_RESULT([$mailgroup $result]) AC_SUBST(mailuser) AC_SUBST(mailgroup) rm -f conftest.out AC_ARG_WITH(stdheaderdir, [ --without-stdheaderdir Header files will be installed into a directory not in the compiler's default search path.], [ if test "$withval" = "no" then AC_DEFINE_UNQUOTED(HAVE_NOSTDHEADERDIR, 1, [ Whether header installation directory is nontstandard ]) fi ]) AC_CACHE_CHECK([for socklen_t], authlib_cv_hassocklen_t, AC_COMPILE_IFELSE( AC_LANG_SOURCE( [ #include #include socklen_t sl_t; ],[ accept(0, 0, &sl_t); ]), authlib_cv_hassocklen_t=yes, authlib_cv_hassocklen_t=no) ) socklen_t="int" if test $authlib_cv_hassocklen_t = yes then : else AC_DEFINE_UNQUOTED(socklen_t, int, [ Default definition for socklen_t ]) fi if test x"$enable_ltdl_install" = x"yes" then LIBLTDL_SUBDIR=libltdl fi AC_SUBST(LIBLTDL_SUBDIR) AC_ARG_WITH(repository, [], REPOSITORY="$withval") AC_SUBST(REPOSITORY) AM_CONDITIONAL(HAVE_SGML, test -d ${srcdir}/docbook) AC_CONFIG_SUBDIRS(libltdl bdbobj gdbmobj md5 sha1 libhmac numlib makedat userdb rfc822 random128 liblock liblog) AC_CONFIG_FILES(Makefile authdaemond authdaemonrc authsystem.passwd README.authdebug.html dbobj.h authmigrate courier-authlib.spec courier-authlib.lpspec courier-authlib.sysvinit userdb-test-cram-md5.pl) AC_OUTPUT