]#------------------------------------------------------------------------------
#
#	$Sendmail: ./configure.ac,v 8.14.3 2009/03/01 05:10:00 cowboy Exp $
#
#	Copyright (c) 1998-2009 Richard Nelson.  All Rights Reserved.
#
#	Debian configure file for building Sendmail
#	  Note: this file supports Sendmail 8.15 and later
#			and has been tested on autoconf 2.12, 2.13, 2.50, 2.52, 2.53
#
#	  Note: Most of this file is vanilla 2.12, but the copyright and
#			ac_init portion are dual-pathed to better support 2.50+
#
#------------------------------------------------------------------------------
define([_SM_CPYRT],  [2010])dnl
define([_SM_VERS],	[8.17.1])dnl
define([_SM_DATE],	[2010-10-11 17:53:00])dnl
define([_SM_MAXVERS],[9.0.0])dnl
define([_SM_MINVERS],[8.15.0])dnl

dnl #-------------------------------------------------------------------
dnl # Obtain version of GNU Autoconf and automake (don't look)
dnl #-------------------------------------------------------------------
ifdef([AC_COPYRIGHT],
[define([_ac_version], m4_PACKAGE_VERSION)]
,[define([_ac_version], AC_ACVERSION)])
m4_ifdef([AM_AUTOMAKE_VERSION],[dnl
dnl m4_define([_MY_TMP_], m4_defn([AM_AUTOMAKE_VERSION]))dnl
dnl delete a char $2 from a string $1 if it is there
dnl m4_define([_DELCHAR_],[m4_define([_IDX_],[m4_index([$1],[$2])])[]m4_define([_I_],[m4_eval(_IDX_ >= 0)])[]m4_if(_I_,[1],[m4_substr([$1],0,_IDX_)[]m4_substr([$1],m4_eval(_IDX_+1))],[$1])])dnl
dnl delete a char $2 (and everything before it from a string $1 if it is there
dnl m4_define([_DELPFX_],[m4_define([_IDX_],[m4_index([$1],[$2])])[]m4_define([_I_],[m4_eval(_IDX_ >= 0)])[]m4_if(_I_,[1],[m4_substr([$1],m4_eval(_IDX_+1))],[$1])])dnl
dnl m4_define([_am_version], [_DELCHAR_(_DELPFX_(_MY_TMP_,["]),["])])dnl
],[dnl
define([_am_version],[<=1.5])
])dnl

dnl #-------------------------------------------------------------------
dnl #	Redefine AC_{COPYRIGHT,INIT_BINSH} to provide RCS IDs and copyright
dnl #	notice at top of generated configure script.  Prints simple copyright.
dnl #-------------------------------------------------------------------
ifdef([AC_COPYRIGHT],
[AC_COPYRIGHT(
[[#
#	$]Sendmail[$
#	   from] translit([$Sendmail: ./configure.ac,v] _SM_VERS _SM_DATE [$], $")] [
#
cat <<EOF

   Copyright (c) 1998-_SM_CPYRT Richard Nelson.	All Rights Reserved.

   Sendmail _SM_VERS
   Generated by Autoconf _ac_version,  Automake _am_version

   Debian configure script for building Sendmail
	 Note: this file supports Sendmail _SM_MINVERS - _SM_MAXVERS
		   and has been tested on autoconf 2.12, 2.13, 2.50, 2.52, 2.53


EOF
])],
[define([AC_INIT_BINSH],
[[#! /bin/sh
#	$]Sendmail[$
#	   from] translit([$Sendmail: ./configure.ac,v] _SM_VERS _SM_DATE [$], $")] [
#
cat <<EOF

   Copyright (c) 1998-_SM_CPYRT Richard Nelson.	All Rights Reserved.

   Sendmail _SM_VERS
   Generated by Autoconf _ac_version,  Automake _am_version

   Debian configure script for building Sendmail
	 Note: this file supports Sendmail _SM_MINVERS - _SM_MAXVERS
		   and has been tested on autoconf 2.12, 2.13, 2.50, 2.52, 2.53

EOF
])dnl])

#-------------------------------------------------------------------
#	Configure.in for Sendmail
#-------------------------------------------------------------------
AC_REVISION([$Revision: ]_SM_VERS[ $])
define([AC_INIT_BINSH],)dnl
ifdef([AC_COPYRIGHT],[
AC_INIT([Sendmail],[_SM_VERS],[bug/reportbug or sendmail@packages.debian.org])
AC_CONFIG_MACRO_DIR(./build)
AC_CONFIG_SRCDIR([./build/site.config.m4.in])dnl
],[
AC_INIT(./build/site.config.m4.in)
[PACKAGE='Sendmail';]		# For earlier automake versions
[PACKAGE_NAME='Sendmail';]
AC_SUBST(PACKAGE_NAME) AC_SUBST(PACKAGE_STRING)
])dnl
AC_CONFIG_AUX_DIR([./build])dnl
AC_CANONICAL_TARGET
AC_ARG_PROGRAM
AC_PROG_MKDIR_P
AC_PROG_MAKE_SET
AM_INIT_AUTOMAKE([foreign])
AM_MAINTAINER_MODE
ac_version="_ac_version";
am_version="_am_version";
AC_SUBST(ac_version) AC_SUBST(am_version)
ifdef([AM_AUTOMAKE_VERSION],[
[am_version="$am__api_version";]
],[
[am_version='<=1.5';]
])dnl


dnl #-------------------------------------------------------------------
dnl # Set current, min, max versions supported
dnl #-------------------------------------------------------------------
SM_VERS='_SM_VERS';
SM_DATE='_SM_DATE';
SM_MINVERS='_SM_MINVERS';
SM_MAXVERS='_SM_MAXVERS';
SM_CPYRT='_SM_CPYRT';
AC_SUBST([SM_VERS]) AC_SUBST([SM_DATE])
AC_SUBST([SM_MINVERS]) AC_SUBST([SM_MAXVERS])
AC_SUBST([SM_CPYRT])

dnl #-------------------------------------------------------------------
dnl # Set default prefix to the FHS standard location: /usr/
dnl #-------------------------------------------------------------------
AC_PREFIX_DEFAULT([/usr])

#-------------------------------------------------------------------
#	Determine date/time of build
#-------------------------------------------------------------------
#sm_date=[`date --iso-8601=seconds`]; # <== Not valid on older systems !!!
changelog_stamp=[$(dpkg-parsechangelog -lchangelog -S Date)]
changelog_tz=[$(echo "${changelog_stamp##* }" | tr +- -+ | sed 's/^/UTC/;s/00$//')]
sm_date=[$(TZ="$changelog_tz" date +%Y-%m-%dT%H:%M:%S%z --date="$changelog_stamp")]
sm_utc=[$(expr	"$sm_date" : '.*T.*\([+-].*\)');]
sm_time=[$(expr "$sm_date" : '.*T\(.*\)[+-]');]
sm_date=[$(expr "$sm_date" : '\(.*\)T');]
AC_SUBST(sm_date) AC_SUBST(sm_time) AC_SUBST(sm_utc)

#-------------------------------------------------------------------
#	Determine sendmail version
#-------------------------------------------------------------------
sm_source_tree="$PWD/.."
if test -f "$sm_source_tree"/sendmail/version.c; then
	version_file="$sm_source_tree"'/sendmail/version.c';
	sm_version=[`sed -ne "s/char[[:space:]]*Version\[\] = \"\([^\"]*\)\";/\1/p"] $version_file`;
else
	curr_dir=[$(echo `pwd` | sed -e 's/\/debian$//' -);]
	version=[$(expr "${curr_dir}" : '.*-\([0-9.].*\)');]
	beta_version=[$(expr "${curr_dir}" : '.*[+~]\([0-9.].*\)');]
	if test -z "$beta_version"; then
		sm_version="$version";
	else
		sm_version="$beta_version";
		fi;
	fi;
if test -z "$sm_version"; then
	version_file='./build/version.c';
	if test -f $version_file; then
		sm_version=[`sed -ne "s/char[[:space:]]*Version\[\] = \"\([^\"]*\)\";/\1/p" $version_file`;]
		fi;
	fi;

if test -z "$sm_version"; then
	AC_MSG_ERROR([could not determine Sendmail version])
	fi;
[PACKAGE_VERSION="${sm_version}";
PACKAGE_STRING="${PACKAGE_NAME} ${PACKAGE_VERSION}";]

#
# break the version into pieces for easier comparisons
#	v,r   = separate components (8.12.0.Beta7 = 8 12)
#	major = 1st two components (8.9.3 -> 8.9)
#	minor = last component (8.9.3 -> 3)
#	beta  = suffix for beta version (8.12.0.Beta7 -> 7)
#	math  = for numeric (<, >=, etc.) comparisons
#		 9.0.0	 = 589824  (9.0  = 589824)
#		 8.15.1  = 528129  (8.15 = 528128)
#		 8.14.3  = 527875  (8.14 = 527872)
#		 8.13.1  = 527617  (8.13 = 527616)
#		 8.12.11 = 527371  (8.12 = 527360)
#		 8.11.7  = 527111  (8.11 = 527104)
#		 8.10.2  = 526850  (8.10 = 526848)
#		 8.9.3	 = 526595  (8.9	 = 526592)
#		 8.8.8	 = 526344  (8.8	 = 526336)
#		 8.7.6	 = 526086  (8.7	 = 526080)
v2i () {[
	sm_version_test=`expr 65536 \* $(expr "$1" : '\([0-9]*\)') + \
				   256 \* $(expr "$1" : '[0-9]*\.\([0-9]*\)') + \
						  $(expr "$1" : '[0-9]*\.[0-9]*\.\([0-9]*\)')`;
	#echo "v2i($1)=$sm_version_test";
	]};
i2v () {[
	val=$1;
	major=`expr $val / 65536`;
	val=`expr $val % 65536`;
	minor=`expr $val / 256`;
	val=`expr $val % 256`;
	result="$major.$minor.$val";
	#echo "i2v($1)=$result";
	#return $result;
	]};
sm_version_v=[`expr $sm_version : '\([0-9]*\)'`];
sm_version_r=[`expr $sm_version : '[0-9]*\.\([0-9]*\)'`];
sm_version_major=["$sm_version_v.$sm_version_r"];
sm_version_minor=[`expr $sm_version : '[0-9]*\.[0-9]*\.\([0-9]*\)'`];
sm_version_beta=[`expr $sm_version : '[0-9]*\.[0-9]*\.[0-9]*\.Beta\([0-9]*\)'`];
sm_version_math=[`expr 65536 \* $sm_version_v \
					+	 256 \* $sm_version_r \
					+	 $sm_version_minor`];
AC_SUBST(sm_version)		AC_SUBST(sm_version_v)		AC_SUBST(sm_version_r)
AC_SUBST(sm_version_major)	AC_SUBST(sm_version_minor)
AC_SUBST(sm_version_beta)	AC_SUBST(sm_version_math)

#-------------------------------------------------------------------
#	Configuration for Sendmail
#-------------------------------------------------------------------
#checks for programs
#checks for libraries
#checks for header files
#checks for typedefs
#checks for structures
#checks for compiler characteristics
#checks for library functions
#checks for system services

#-------------------------------------------------------------------
#	Initialize variables
#-------------------------------------------------------------------
#
# Initialize variables - value is one of:
#	no:		don't even try to include support for
#	yes:	require support for
#	auto:	support if present, warn if not
#
#-------------------------------------------------------------------
AC_ARG_WITH(buildtree, [[  --with-buildtree=.......Build directory [.]]],
	[buildtree="$withval"], [buildtree='.'])
AC_ARG_WITH(revision,  [[  --with-revision=........Package revision ['']]],
	[sm_revision="$withval"], [sm_revision=''])
AC_ARG_WITH(custom,    [[  --with-custom=..........Custom package name ['']]],
	[sm_custom="$withval"], [sm_custom=''])
AC_ARG_ENABLE(regex,   [[  --enable-regex=.........Allow REGEX maps [auto]]],
	[sm_enable_regex="$enableval"], [sm_enable_regex=auto])
AC_ARG_ENABLE(ndbm,    [[  --enable-ndbm=..........Allow NDBM maps [auto]]],
	[sm_enable_ndbm="$enableval"], [sm_enable_ndbm=auto])
AC_ARG_ENABLE(newdb,   [[  --enable-newdb=.........Allow NEWDB maps [auto]]],
	[sm_enable_newdb="$enableval"], [sm_enable_newdb=auto])
AC_ARG_ENABLE(nis,	   [[  --enable-nis=...........Allow NIS maps [auto]]],
	[sm_enable_nis="$enableval"], [sm_enable_nis=auto])
AC_ARG_ENABLE(nisplus, [[  --enable-nisplus=.......Allow NISPLUS maps [auto]]],
	[sm_enable_nisplus="$enableval"], [sm_enable_nisplus=auto])
AC_ARG_ENABLE(ldap,    [[  --enable-ldap=..........Allow LDAP maps [auto]]],
	[sm_enable_ldap="$enableval"], [sm_enable_ldap=auto])
AC_ARG_ENABLE(hesiod,  [[  --enable-hesiod=........Allow HESIOD maps [auto]]],
	[sm_enable_hesiod="$enableval"], [sm_enable_hesiod=auto])
AC_ARG_ENABLE(tcpd,    [[  --enable-tcpd=..........Allow TCP wrappers [auto]]],
	[sm_enable_tcpd="$enableval"], [sm_enable_tcpd=auto])
AC_ARG_ENABLE(bind,    [[  --enable-bind=..........Allow BIND usage [auto]]],
	[sm_enable_bind="$enableval"], [sm_enable_bind=auto])
AC_ARG_ENABLE(ipv6,    [[  --enable-ipv6=..........Allow IPv6 usage [auto]]],
	[sm_enable_ipv6="$enableval"], [sm_enable_ipv6=auto])
AC_ARG_ENABLE(maillock,[[  --enable-maillock=......Allow maillock [auto]]],
	[sm_enable_maillock="$enableval"], [sm_enable_maillock=auto])
AC_ARG_ENABLE(milter,  [[  --enable-milter=........Allow milter [auto]]],
	[sm_enable_milter="$enableval"], [sm_enable_milter=auto])
AC_ARG_ENABLE(sfio,    [[  --enable-sfio=..........Allow SFIO usage [auto]]],
	[sm_enable_sfio="$enableval"], [sm_enable_sfio=auto])
AC_ARG_ENABLE(auth,    [[  --enable-auth=..........Allow SMTP auth [auto]]],
	[sm_enable_auth="$enableval"], [sm_enable_auth=auto])
AC_ARG_ENABLE(tls,	   [[  --enable-tls=...........Allow TLS/SSL [auto]]],
	[sm_enable_tls="$enableval"], [sm_enable_tls=auto])
AC_ARG_ENABLE(shm,	   [[  --enable-shm=...........Allow shared memory [auto]]],
	[sm_enable_shm="$enableval"], [sm_enable_shm=auto])

#-------------------------------------------------------------------
#	Resolve variables for sendmail Makefiles and .m4 where
#	exec_prefix=${prefix} will not work...
#-------------------------------------------------------------------
#eval PACKAGE_VERSION="${PACKAGE_VERSION}"
#eval PACKAGE_STRING="${PACKAGE_STRING}"
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 bindir="${bindir}";
eval sbindir="${sbindir}";
eval libexecdir="${libexecdir}";
eval sysconfdir="${sysconfdir}";
eval sharedstatedir="${sharedstatedir}";
eval localstatedir="${localstatedir}";
eval libdir="${libdir}";
eval includedir="${includedir}";
eval oldincludedir="${oldincludedir}";
eval datarootdir="${datarootdir}";
eval datadir="${datadir}";
eval infodir="${infodir}";
eval mandir="${mandir}";
eval docdir="${docdir}";
eval srcdir="${srcdir}";

AC_SUBST(sm_revision)
test -n "$sm_custom" && sm_custom_s="+${sm_custom}";
AC_SUBST(sm_custom)  AC_SUBST(sm_custom_s)
eval buildtree="${buildtree}";	AC_SUBST(buildtree)

#-------------------------------------------------------------------
#	Determine Distribution and version to build for
#-------------------------------------------------------------------
sm_dist_name='';				AC_SUBST(sm_dist_name)
sm_dist_vers='';				AC_SUBST(sm_dist_vers)
DEBIAN='';						AC_SUBST(DEBIAN)
DEBIAN_DH='';					AC_SUBST(DEBIAN_DH)
AC_MSG_CHECKING(for Debian)
if test ! -f /etc/debian_version ; then
	DEBIAN='no';
	AC_MSG_RESULT(["$DEBIAN"])
else
	DEBIAN='yes';
	sm_dist_name='Debian';
	sm_dist_vers=`cat /etc/debian_version`;
	# Determine which level of debhelper we're building with
	DEBIAN_DH='9';
	if test -x /usr/bin/dh_testversion; then
		# Must run this test above the debian directory
		if (cd .. && dh_testversion 4.1.0 2>/dev/null); then
			DEBIAN_DH='4.1';
		elif (cd .. && dh_testversion 4.0.0 2>/dev/null); then
			DEBIAN_DH='4';
		elif (cd .. && dh_testversion 3.0.0 2>/dev/null); then
			DEBIAN_DH='3';
		elif (cd .. && dh_testversion 2.0.40 2>/dev/null); then
			DEBIAN_DH='2';
		else
			DEBIAN_DH='1';
			fi;
		fi;
	if test -x /usr/bin/dpkg-architecture; then
		eval `dpkg-architecture -s`;
		fi;
	sm_build_arch="$DEB_BUILD_ARCH"
	sm_host_arch="$DEB_HOST_ARCH"
	AC_SUBST(DEB_BUILD_ARCH)	   AC_SUBST(DEB_BUILD_GNU_CPU)
	AC_SUBST(DEB_BUILD_GNU_SYSTEM) AC_SUBST(DEB_BUILD_GNU_TYPE)
	AC_SUBST(DEB_HOST_ARCH)		   AC_SUBST(DEB_HOST_GNU_CPU)
	AC_SUBST(DEB_HOST_GNU_SYSTEM)  AC_SUBST(DEB_HOST_GNU_TYPE)
	AC_SUBST(DEB_HOST_MULTIARCH)
	AC_MSG_RESULT([$DEBIAN, using debhelper v$DEBIAN_DH])
	fi;

#-------------------------------------------------------------------
# Announce our presence...
#-------------------------------------------------------------------
AC_SUBST(sm_build_arch) AC_SUBST(sm_host_arch)
echo ""
echo "Sendmail ${sm_version}${sm_custom_s}${sm_revision} (${sm_version_math}) \
on ${sm_dist_name} ${sm_dist_vers} ${sm_build_arch}/${sm_host_arch}.";
echo "Generated by Autoconf ${ac_version},	Automake ${am_version}.";
echo "";

#-------------------------------------------------------------------
#	Required programs
#		cc, cpp
#		install
#		egrep
#		std includes
#-------------------------------------------------------------------
dnl AC_CANONICAL_HOST
AC_PROG_CC
AC_PROG_CPP
AC_PROG_INSTALL
AC_PROG_LN_S
ifdef([AC_PROG_EGREP],
[AC_PROG_EGREP]
)
AC_HEADER_STDC

#-------------------------------------------------------------------
# Variables used in site.config.m4.in to set corresponding Build vars
#-------------------------------------------------------------------
# Global
sm_incdirs='';				AC_SUBST(sm_incdirs)
sm_mapdef='';				AC_SUBST(sm_mapdef)
sm_envdef='';				AC_SUBST(sm_envdef)
sm_libs='';					AC_SUBST(sm_libs)
# editmap
sm_editmap_envdef='';		AC_SUBST(sm_editmap_envdef)
sm_editmap_libs='';			AC_SUBST(sm_editmap_libs)
# libmilter
sm_libmilter_envdef='-fPIC';	AC_SUBST(sm_libmilter_envdef)
sm_libmilter_libs='';		AC_SUBST(sm_libmilter_libs)
sm_libmilter_version=0;		AC_SUBST(sm_libmilter_version)
# libsm
sm_libsm_envdef='-fPIC';			AC_SUBST(sm_libsm_envdef)
sm_libsm_libs='';			AC_SUBST(sm_libsm_libs)
# libsmdb
sm_libsmdb_envdef='';		AC_SUBST(sm_libsmdb_envdef)
sm_libsmdb_libs='';			AC_SUBST(sm_libsmdb_libs)
# libsmutil
sm_libsmutil_envdef='-fPIC';		AC_SUBST(sm_libsmutil_envdef)
sm_libsmutil_libs='';		AC_SUBST(sm_libsmutil_libs)
# mail.local
sm_mail_local_envdef='-DLDA_USE_LOCKF';	AC_SUBST(sm_mail_local_envdef)
sm_mail_local_libs='';		AC_SUBST(sm_mail_local_libs)
# mailstats
sm_mailstats_envdef='';		AC_SUBST(sm_mailstats_envdef)
sm_mailstats_libs='';		AC_SUBST(sm_mailstats_libs)
# makemap
sm_makemap_envdef='';		AC_SUBST(sm_makemap_envdef)
sm_makemap_libs='';			AC_SUBST(sm_makemap_libs)
# praliases
sm_praliases_envdef='';		AC_SUBST(sm_praliases_envdef)
sm_praliases_libs='';		AC_SUBST(sm_praliases_libs)
# rmail
sm_rmail_envdef='';			AC_SUBST(sm_rmail_envdef)
sm_rmail_libs='';			AC_SUBST(sm_rmail_libs)
# sendmail
sm_sendmail_envdef='';		AC_SUBST(sm_sendmail_envdef)
sm_sendmail_libs='';		AC_SUBST(sm_sendmail_libs)
# smrsh
sm_smrsh_envdef='';			AC_SUBST(sm_smrsh_envdef)
sm_smrsh_libs='';			AC_SUBST(sm_smrsh_libs)
# vacation
sm_vacation_envdef='';		AC_SUBST(sm_vacation_envdef)
sm_vacation_libs='';		AC_SUBST(sm_vacation_libs)

#-------------------------------------------------------------------
# Auxilliary variables
#-------------------------------------------------------------------
sm_databases='';			AC_SUBST(sm_databases)
sm_features='';				AC_SUBST(sm_features)
sm_badepends='';			AC_SUBST(sm_badepends)
sm_depends='';				AC_SUBST(sm_depends)
sm_recommends='';			AC_SUBST(sm_recommends)
sm_suggests='';				AC_SUBST(sm_suggests)
sm_newdb_lib='';			AC_SUBST(sm_newdb_lib)
sm_ldap_lib='';				AC_SUBST(sm_ldap_lib)
sm_hesiod_parms='';			AC_SUBST(sm_hesiod_parms)
sm_ffr='';					AC_SUBST(sm_ffr)
sm_m4_ffr='';				AC_SUBST(sm_m4_ffr)

#-------------------------------------------------------------------
# Override default/specified values
#-------------------------------------------------------------------
#	Change pid from /var/run to /var/run/sendmail/mta to alleviate clutter
sm_sendmail_envdef="$sm_sendmail_envdef \
-D_PATH_SENDMAILPID=\\\"${localstatedir}/run/sendmail/mta/sendmail.pid\\\"";
#	Set paths for smrsh
sm_smrsh_envdef="$sm_smrsh_envdef \
-DCMDDIR=\\\"${sysconfdir}/mail/smrsh\\\"";
sm_smrsh_envdef="$sm_smrsh_envdef -DPATH=\\\"/usr/bin:/bin\\\"";
#
# Everything we'll build on has strerror(3)
# sm_envdef="$sm_envdef -DHASSTRERROR=1";
#
# The next two require a patch to {include/sm,sendmail,src}/conf.h
# and would give duplicate definition warnings if left herein
#sm_envdef="$sm_envdef -DUSESETEUID=1 -DHASGETUSERSHELL=1";
sm_envdef="$sm_envdef -DHASFCHMOD=1 -DHASSETRLIMIT=1";
#
# Back by request...
#sm_envdef="$sm_envdef -DPICKY_HELO_CHECK";
#
sm_envdef="$sm_envdef -DHASFLOCK=1";
sm_libsm_envdef="$sm_libsm_envdef -DHAVE_NANOSLEEP=1";
sm_ffr="$sm_ffr -D_FFR_QUEUE_SCHED_DBG"; # %%%%%% TESTING %%%%%%%%
sm_ffr="$sm_ffr -D_FFR_REJECT_NUL_BYTE";
#
	sm_ffr="$sm_ffr -D_FFR_SKIP_DOMAINS";
	sm_mapdef="$sm_mapdef -DSOCKETMAP";
	sm_envdef="$sm_envdef -DUSESETEUID=1 -DHASGETUSERSHELL=1";
	sm_ffr="$sm_ffr -D_FFR_NO_PIPE";
	sm_ffr="$sm_ffr -D_FFR_SHM_STATUS";
	sm_ffr="$sm_ffr -D_FFR_RHS";
	sm_ffr="$sm_ffr -D_FFR_MAIL_MACRO";
	sm_m4_ffr="$sm_m4_ffr [define(\`_FFR_MAIL_MACRO')]";
	sm_ffr="$sm_ffr -D_FFR_BADRCPT_SHUTDOWN";
	sm_ffr="$sm_ffr -D_FFR_TLS_ALTNAMES -D_FFR_MTA_STS";

	# SRCROUTE works quite well with glibc 2.1+ (should test for this...)
	sm_sendmail_envdef="$sm_sendmail_envdef -DIP_SRCROUTE=1";
	# Allow setting Hostname from $j...
	sm_ffr="$sm_ffr -D_FFR_RESET_MACRO_GLOBALS";
	sm_mail_local_envdef="$sm_mail_local_envdef -DCONTENTLENGTH";
	# Note: the next line is commented to *prevent* mode 660 files in /var/mail
	#sm_mail_local_envdef="$sm_mail_local_envdef -DMAILGID=8";

# Shared memory support (on 8.12, but needs a recent kernel)
# Note: there is a race condition where sometimes sendmail can't
#	use shared memory because the prior pid didn't delete it
#	but we override the linux default for performance reasons
#	(or rather we would, if most users weren't on kernels that
#	don't properly support it - < 2.2.19 or 2.4.1)
#	*ANY* arch still on a 2.2.x; x<19 must *NOT* enable this...
if test "$sm_enable_shm" != "no"; then
	if test "arm" = "${sm_host_arch}"; then
		sm_enable_shm=no;
		fi;
	fi;
if test "$sm_enable_shm" != "no"; then
	sm_enable_shm=yes;
	fi;
AC_SUBST(sm_enable_shm)

# Milter (_FFR_ on 8.10, 8.11, native on 8.12+)
if test "$sm_enable_milter" != "no"; then
	sm_libmilter_envdef="$sm_libmilter_envdef -DSM_CONF_POLL=1";

	# Determin which level of the milter interface we're using
	sm_libmilter_version=0;
	old_cflags="$CFLAGS";
	old_cppflags="$CFLAGS";
	export CFLAGS="$CFLAGS -I $sm_source_tree/include";
	export CPPFLAGS="$CPPFLAGS -I $sm_source_tree/include";
	AC_CHECK_HEADERS(libmilter/mfapi.h,
		[sm_have_mfapi=yes]
		,[sm_have_mfapi=no
          sm_libmilter_version=0])
	if test "$sm_have_mfapi" = 'yes'; then
		AC_MSG_CHECKING([libmilter version])
		AC_RUN_IFELSE([[
			/*
			 *  This hack will compile and run a program
			 *  to determine what level of libmilter should
			 *  be used for this package
			 */
			#include <stdlib.h>
			#include <stdio.h>
			#include <string.h>
			#include "libmilter/mfapi.h"
			char vers[30] = "0";
			int main (void) {
				FILE *confout = fopen("conftest.out","w");
				if (!confout)
					return 1;
				snprintf(vers
				        ,sizeof(vers)
				        ,"%d%c%d%c%d"
				        ,SM_LM_VRS_MAJOR(SMFI_VERSION)
				        ,'.'
				        ,SM_LM_VRS_MINOR(SMFI_VERSION)
				        ,'.'
				        ,SM_LM_VRS_PLVL(SMFI_VERSION)
				        );
				fprintf(confout
				       ,"%s\n"
				       ,vers
				       );
				fclose(confout);
				return 0;
				}
			]]
			,[sm_libmilter_version=`cat conftest.out`]
			,[sm_libmilter_version=0]
			)
		 AC_MSG_RESULT([$sm_libmilter_version])
		fi;
	export CFLAGS="$old_cflags";
	export CPPFLAGS="$old_cppflags";

		sm_enable_milter=yes;
				sm_sendmail_envdef="$sm_sendmail_envdef -DMILTER";
				sm_libmilter_envdef="$sm_libmilter_envdef \
-D_FFR_MILTER_ROOT_UNSAFE";
			sm_libmilter_libs="$sm_libmilter_libs"
	fi;
AC_SUBST(sm_enable_milter)

# SFIO (required for TLS and security layer of SASL on 8.11)
# We'll let it go through here on any version (to check headers), but
# issue no messages unless needed...
if test "$sm_enable_tls" != "no"; then
	if test $sm_enable_sfio != no; then
		sm_enable_sfio=auto;
		fi;
elif test $sm_enable_sfio != no; then
	sm_enable_sfio=no;
	fi;

#-------------------------------------------------------------------
#
# Check for presence of REGEX headers
#
sm_have_regex=no;
if test $sm_enable_regex != no; then
	AC_CHECK_HEADERS(regex.h,
		[sm_have_regex=yes]
		,[sm_have_regex=no])

	if test $ac_cv_header_regex_h = yes ; then
		AC_CHECK_FUNC(regfree,
			:
			,AC_MSG_ERROR([POSIX regex required.])
			)
		fi;

	if test $sm_have_regex = yes; then
		sm_databases="$sm_databases, REGEX";
		sm_mapdef="$sm_mapdef -DMAP_REGEX";
	elif test $sm_enable_regex = auto; then
		AC_MSG_WARN([Could not locate REGEX package])
	else
		AC_MSG_ERROR([Could not locate REGEX package])
		fi;
	fi;
sm_enable_regex=$sm_have_regex;		AC_SUBST(sm_enable_regex)

#-------------------------------------------------------------------
#
# Check for presence of NDBM headers
#
sm_have_ndbm=no;
if test $sm_enable_ndbm != no; then
	AC_CHECK_HEADERS(ndbm.h db1/ndbm.h,
		[sm_have_ndbm=yes]
		,[sm_have_ndbm=no])

	if test $sm_have_ndbm != no; then
		AC_EGREP_CPP(DBM_PAGFNO_NOT_AVAILABLE,[
			#if defined(HAVE_DB1_NDBM_H)
				#include <db1/ndbm.h>
			#elif defined(HAVE_NDBM_H)
				#include <ndbm.h>
				#endif
			dbm_pagfno(0);
			], [sm_have_ndbm=no])

		if test $sm_have_ndbm = no; then
			AC_MSG_WARN([DB emulation of ndbm not sufficient, -lndbm ignored])
			fi;
		fi;

	if test $sm_have_ndbm != no; then
		AC_CHECK_LIB(ndbm, main,
			[sm_have_ndmb=yes]
			,[sm_have_ndmb=no])

		if test $sm_have_ndbm = no; then
			AC_MSG_WARN([Could not find -lndbm])
			fi;
		fi;

	# only libsmdb and sendmail #include <ndbm.h>, but libsmdb is needed
	# by most of the other components
	if test $sm_have_ndbm = yes; then
		sm_databases="$sm_databases, DBM";
		sm_mapdef="$sm_mapdef -DNDBM";
		sm_editmap_libs="$sm_editmap_libs -lndbm";
		sm_makemap_libs="$sm_makemap_libs -lndbm";
		sm_praliases_libs="$sm_praliases_libs -lndbm";
		sm_sendmail_libs="$sm_sendmail_libs -lndbm";
		sm_vacation_libs="$sm_vacation_libs -lndbm";
	elif test $sm_enable_ndbm = auto; then
		AC_MSG_WARN([Could not locate NDBM package])
	else
		AC_MSG_ERROR([Could not locate NDBM package])
		fi;
	fi;
sm_enable_ndbm=$sm_have_ndbm;		AC_SUBST(sm_enable_ndbm)

#-------------------------------------------------------------------
#
# Check for presence of NEWDB headers (and determine version)
#
sm_have_newdb=no;
sm_use_185=no;
sm_newdb_lib=;
if test $sm_enable_newdb != no; then
	AC_CHECK_HEADERS(db.h db4/db.h db3/db.h db2/db.h db1/db.h \
					 db_185.h db4/db_185.h db3/db_185.h db2/db_185.h \
					 db1/db_185.h)
	if [[ $ac_cv_header_db_h = yes ]] \
	|| [[ $ac_cv_header_db4_db_h = yes ]] \
	|| [[ $ac_cv_header_db3_db_h = yes ]] \
	|| [[ $ac_cv_header_db2_db_h = yes ]] \
	|| [[ $ac_cv_header_db1_h = yes ]]; then
		sm_have_newdb=yes;
		fi;

	if test $sm_have_newdb = yes; then
		AC_MSG_CHECKING([newdb version])
		AC_EGREP_CPP(sm_newdb_lib=4,[
			#if defined(HAVE_DB4_DB_H)
				#include <db4/db.h>
			#elif defined(HAVE_DB_H)
				#include <db.h>
				#endif
			#if DB_VERSION_MAJOR >= 4
				sm_newdb_lib=4
				#endif
			], [sm_newdb_lib=db4], [
			AC_EGREP_CPP(sm_newdb_lib=3,[
				#if defined(HAVE_DB3_DB_H)
					#include <db3/db.h>
				#elif defined(HAVE_DB_H)
					#include <db.h>
					#endif
				#if DB_VERSION_MAJOR >= 3
					sm_newdb_lib=3
					#endif
				], [sm_newdb_lib=db3], [
				AC_EGREP_CPP(sm_newdb_lib=2,[
					#if defined(HAVE_DB2_DB_H)
						#include <db2/db.h>
					#elif defined(HAVE_DB_H)
						#include <db.h>
						#endif
					#if DB_VERSION_MAJOR >= 2
						sm_newdb_lib=2
						#endif
					], [sm_newdb_lib=db2], [
					AC_EGREP_CPP(sm_newdb_lib=1,[
						#if defined(HAVE_DB1_DB_H)
							#include <db1/db.h>
						#elif defined(HAVE_DB_H)
							#include <db.h>
							#endif
						#ifndef DB_VERSION_MAJOR
							#define DB_VERSION_MAJOR 1
							#endif
						#if DB_VERSION_MAJOR >= 1
							sm_newdb_lib=1
							#endif
						], [sm_newdb_lib=db1])
					])
				])
			])
		AC_MSG_RESULT([$sm_newdb_lib])
		if test "X$sm_newdb_lib" = "X"; then
			AC_MSG_WARN([NEWDB version unknown, omitting support!])
			sm_have_newdb=no;
			fi;
		fi;

	# Check first for a library matching the db version (-ldb4, etc)
	# then check to see if -ldb will work
	if test $sm_have_newdb != no; then
		sm_old_libs="$LIBS";
		if test $sm_newdb_lib = db4; then
			AC_CHECK_LIB(db, db_create, [sm_newdb_lib='db'], [
			sm_have_newdb=no])dnl
		elif test $sm_newdb_lib = db3; then
			AC_CHECK_LIB($sm_newdb_lib, db_create, [:], [
				AC_CHECK_LIB(db, db_create,
					[sm_newdb_lib='db'], [sm_have_newdb=no])dnl
				])dnl
		elif test $sm_newdb_lib = db2; then
			AC_CHECK_LIB($sm_newdb_lib, db_open, [:], [
				AC_CHECK_LIB(db, db_open,
					[sm_newdb_lib='db'], [sm_have_newdb=no])dnl
				])dnl
		else
			AC_CHECK_LIB($sm_newdb_lib, dbopen, [:], [
				AC_CHECK_LIB(db, dbopen,
					[sm_newdb_lib='db'], [sm_have_newdb=no])dnl
				])dnl
			fi;
		LIBS="$sm_old_libs";

		if test $sm_have_newdb != yes; then
			AC_MSG_WARN([Could not find -l$sm_newdb_lib (or -ldb)])
			fi;
		fi;

	# only libsmdb and sendmail #include <db.h>, but libsmdb is needed
	# by most of the other components
	if test $sm_have_newdb = yes; then
		if test \( $ac_cv_header_db4_db_h = yes -a $sm_newdb_lib = db4 \) \
			-o	\( $ac_cv_header_db3_db_h = yes -a $sm_newdb_lib = db3 \) \
			-o	\( $ac_cv_header_db2_db_h = yes -a $sm_newdb_lib = db2 \) \
			-o	\( $ac_cv_header_db1_db_h = yes -a $sm_newdb_lib = db1 \); then
			sm_libsmdb_envdef="$sm_libsmdb_envdef -I/usr/include/$sm_newdb_lib";
			sm_sendmail_envdef="$sm_sendmail_envdef -I/usr/include/$sm_newdb_lib";
			fi;
		if test $sm_use_185 = yes; then
			:
			#sm_libsmdb_envdef="$sm_libsmdb_envdef -Ddb.h db_185.h";
			#sm_sendmail_envdef="$sm_sendmail_envdef -Ddb.h db_185.h";
			fi;
		junk=$(echo "${sm_newdb_lib}" | sed -e 's/^db\(-\)\?//');
		sm_databases="$sm_databases, DB";
		if test "$junk" != 1; then
			sm_badepends="$sm_badepends, libdb${junk}-dev";
			fi;
		sm_mapdef="$sm_mapdef -DNEWDB";
		junk=$(echo "${sm_newdb_lib}" | sed -e 's/^db//');
		sm_newdb_lib="-ldb${junk}";
		sm_editmap_libs="$sm_editmap_libs $sm_newdb_lib";
		sm_makemap_libs="$sm_makemap_libs $sm_newdb_lib";
		sm_praliases_libs="$sm_praliases_libs $sm_newdb_lib";
		sm_sendmail_libs="$sm_sendmail_libs $sm_newdb_lib";
		sm_vacation_libs="$sm_vacation_libs $sm_newdb_lib";
	elif test $sm_enable_newdb = auto; then
		AC_MSG_WARN([Could not locate NEWDB (libdb{4,3,2,1,}-dev) package])
	else
		AC_MSG_ERROR([Could not locate NEWDB (libdb{4,3,2,1,}-dev) package])
		fi;
	fi;
sm_enable_newdb=$sm_have_newdb;		AC_SUBST(sm_enable_newdb)
AC_SUBST(sm_newdb_lib)

#-------------------------------------------------------------------
#
# Check for libnsl.pc to get the correct cflags/libs for libnsl
# If it is not available, check for the standard -lnsl
#
if test $sm_enable_nis != no || $sm_enable_nisplus != no; then
	PKG_CHECK_MODULES([LIBNSL], [libnsl],
		[
			sm_libnsl_inc="$LIBNSL_CFLAGS"
			sm_libnsl_libs="$LIBNSL_LIBS"
			sm_badepends="$sm_badepends, libnsl-dev";
		],
		[
			sm_libnsl_inc=""
			AC_CHECK_LIB(nsl, main,
				[
					sm_libnsl_inc=""
					sm_libnsl_libs="-lnsl"
				],
				[AC_MSG_WARN([Could not find -lnsl])])
		])
	fi;

#-------------------------------------------------------------------
#
# Check for presence of NIS headers
#
sm_have_nis=no;
if test $sm_enable_nis != no; then
	CPPFLAGS_SAVE="$CPPFLAGS";
	CPPFLAGS="$CPPFLAGS $sm_libnsl_inc"
	AC_CHECK_HEADERS(rpcsvc/ypclnt.h,
		[sm_have_nis=yes]
		,[sm_have_nis=no])
	CPPFLAGS="$CPPFLAGS_SAVE";

	if test $sm_have_nis = yes; then
		sm_databases="$sm_databases, NIS";
		sm_mapdef="$sm_mapdef -DNIS";
		sm_incdirs="$sm_incdirs $sm_libnsl_inc";
		sm_sendmail_libs="$sm_sendmail_libs $sm_libnsl_libs";
	elif test $sm_enable_nis = auto; then
		AC_MSG_WARN([Could not locate NIS package])
	else
		AC_MSG_ERROR([Could not locate NIS package])
		fi;
	fi;
sm_enable_nis=$sm_have_nis;		AC_SUBST(sm_enable_nis)

#-------------------------------------------------------------------
#
# Check for presence of NISPLUS headers
#
sm_have_nisplus=no;
if test $sm_enable_nisplus != no; then
	CPPFLAGS_SAVE="$CPPFLAGS";
	CPPFLAGS="$CPPFLAGS $sm_libnsl_inc"
	AC_CHECK_HEADERS(rpcsvc/nis.h,
		[sm_have_nisplus=yes]
		,[sm_have_nisplus=no])
	CPPFLAGS="$CPPFLAGS_SAVE";

	if test $sm_have_nisplus = yes; then
		sm_databases="$sm_databases, NIS+";
		sm_mapdef="$sm_mapdef -DNISPLUS";
		if test $sm_have_nis != yes; then
			sm_incdirs="$sm_incdirs $sm_libnsl_inc";
			sm_sendmail_libs="$sm_sendmail_libs $sm_libnsl_libs";
			fi;
	elif test $sm_enable_nisplus = auto; then
		AC_MSG_WARN([Could not locate NISPLUS package])
	else
		AC_MSG_ERROR([Could not locate NISPLUS package])
		fi;
	fi;
sm_enable_nisplus=$sm_have_nisplus;		AC_SUBST(sm_enable_nisplus)

#-------------------------------------------------------------------
#
# Check for presence of LDAP headers (support OpenLDAP v2/v1, Umich)
#
sm_have_ldap=no;
sm_have_ldap_init=no;
sm_have_ldap_memfree=no;
sm_ldap_inc=;
sm_ldap_lib=;
sm_ldap_pkg=;
if test $sm_enable_ldap != no; then
	AC_CHECK_HEADERS(ldap.h umich-ldap/ldap.h)

	if test $ac_cv_header_ldap_h = yes; then
		AC_CHECK_LIB(ldap, main,
			[sm_have_ldap=yes]
			,[sm_have_ldap=no]
			,[-llber])
		AC_CHECK_LIB(ldap, ldap_init,
			[sm_have_ldap_init=yes]
			,[sm_have_ldap_init=no]
			,[-llber])
		AC_CHECK_LIB(ldap, ldap_memfree,
			[sm_have_ldap_memfree=yes]
			,[sm_have_ldap_memfree=no]
			,[-llber])

		if test $sm_have_ldap = yes; then
			AC_CHECK_LIB(lber, main,
				[sm_have_ldap=yes]
				,[sm_have_ldap=no])
			fi;

		if test $sm_have_ldap = yes; then
			AC_MSG_CHECKING([for openldap package])
			AC_EGREP_CPP([sm_ldap_version=3], [
					#if defined(HAVE_LDAP_H)
						#include <ldap.h>
						#if defined(LDAP_VERSION3)
							sm_ldap_version=3
						#else
							sm_ldap_version=2
						#endif
					#endif
				], sm_ldap_pkg="libldap2-dev"
				, sm_ldap_pkg="libopenldap-dev")
			AC_MSG_RESULT([$sm_ldap_pkg])
			fi;

		if test $sm_have_ldap = yes; then
			sm_badepends="$sm_badepends, $sm_ldap_pkg"
			sm_ldap_lib="-lldap -llber";
		else
			AC_MSG_WARN([Could not find OpenLDAP -lldap or -llber])
			fi;
		fi;

	if [[ "X$ac_cv_header_umich_ldap_ldap_h" = Xyes ]] \
	&& [[ $sm_have_ldap != yes ]]; then
		AC_CHECK_LIB(umich_ldap, main,
			[sm_have_ldap=yes]
			,[sm_have_ldap=no]
			,[-lumich_lber])

		if test $sm_have_ldap = yes; then
			AC_CHECK_LIB(umich_lber, main,
				[sm_have_ldap=yes]
				,[sm_have_ldap=no])
			fi;

		if test $sm_have_ldap = yes; then
			sm_badepends="$sm_badepends, umich-libldap-dev";
			sm_ldap_inc="-I/usr/include/umich-ldap";
			sm_ldap_lib="-lumich_ldap -lumich_lber";
		else
			AC_MSG_WARN([Could not find UMich -lldap or -llber])
			fi;
		fi;

	if test $sm_have_ldap = yes; then
		#
		# sendmail/conf.h includes LDAP, so everything does...
		sm_databases="$sm_databases, LDAP";
		sm_mapdef="$sm_mapdef -DLDAPMAP";
		sm_incdirs="$sm_incdirs $sm_ldap_inc";
		#sm_libs="$sm_libs $sm_ldap_lib";
		sm_editmap_libs="$sm_editmap_libs $sm_ldap_lib";
		sm_libsm_libs="$sm_libsm_libs $sm_ldap_lib";
		sm_mail_local_libs="$sm_mail_local_libs $sm_ldap_lib";
		sm_mailstats_libs="$sm_mailstats_libs $sm_ldap_lib";
		sm_makemap_libs="$sm_makemap_libs $sm_ldap_lib";
		sm_praliases_libs="$sm_praliases_libs $sm_ldap_lib";
		sm_rmail_libs="$sm_rmail_libs $sm_ldap_lib";
		sm_sendmail_libs="$sm_sendmail_libs $sm_ldap_lib";
		sm_smrsh_libs="$sm_smrsh_libs $sm_ldap_lib";
		sm_vacation_libs="$sm_vacation_libs $sm_ldap_lib";
		sm_libsm_envdef="$sm_libsm_envdef -D_LDAP_EXAMPLE_";
		if test $sm_have_ldap_init = yes; then
			sm_libsm_envdef="$sm_libsm_envdef -DLDAP_REFERRALS";
			sm_sendmail_envdef="$sm_sendmail_envdef -DLDAP_REFERRALS";
			sm_libsm_envdef="$sm_libsm_envdef -DLDAP_DEPRECATED";
			sm_sendmail_envdef="$sm_sendmail_envdef -DLDAP_DEPRECATED";
			fi;
		if test $sm_have_ldap_memfree = yes; then
			sm_libsm_envdef="$sm_libsm_envdef -DSM_CONF_LDAP_MEMFREE";
			fi;
	elif test $sm_enable_ldap = auto; then
		AC_MSG_WARN([Could not locate LDAP (libldap2-dev) package])
	else
		AC_MSG_ERROR([Could not locate LDAP (libldap2-dev) package])
		fi;
	fi;
sm_enable_ldap=$sm_have_ldap;		AC_SUBST(sm_enable_ldap)
AM_CONDITIONAL(SM_ENABLE_LDAP, test x$sm_enable_ldap = xyes)

#-------------------------------------------------------------------
#
# Check for presence of resolve(and/or bind) headers
# if found, enable other maps dependant upon resolver libraries
#
# Since GLIBC 2.2.1 has mucked with resolv.h, we must build w/bind 8.2.2p7
# Unfortunately, this will fsck up HESIOD (bind 8.2 only has partial support)
# It also messed with openLDAP - making it not work ;(
#
# We're now using resolv.h - as it seems to be working (w/sendmail changes)
#
sm_have_resolve=no;
sm_have_bind=no;
resolve_lib='';
resolve_inc='';
#if test $sm_enable_resolv != no; then
	AC_CHECK_HEADERS(resolv.h bind/resolv.h)
	if test $ac_cv_header_resolv_h = yes; then
		sm_have_resolve=yes;
		fi;
	if test $ac_cv_header_bind_resolv_h = yes; then
		sm_have_bind=yes;
		fi;

	if test $ac_cv_header_resolv_h = yes; then
		AC_CHECK_LIB(resolv, __res_query,
			[sm_have_resolve=yes]
			, [AC_CHECK_LIB(resolv, res_query,
				[sm_have_resolve=yes]
				,[sm_have_resolve=no])]
			)

		if test $sm_have_resolve = yes; then
			resolve_inc='';
			resolve_lib='-lresolv';
		else
			AC_MSG_WARN([Could not find -lresolv])
			fi;
		fi;

	if test $ac_cv_header_bind_resolv_h = yes; then
		AC_CHECK_LIB(bind, __res_query,
			[sm_have_bind=yes]
			,[sm_have_bind=no])

		if test $sm_have_bind = yes; then
			if test $sm_enable_bind = yes; then
				sm_badepends="$sm_badepends, bind-dev";
				resolve_inc='-I/usr/include/bind';
				resolve_lib='-lbind -lresolv';
			else
				sm_have_bind=no;
				fi;
		else
			AC_MSG_WARN([Could not find -lbind (bind-dev)])
			fi;
	fi;

	if test $sm_have_resolve = yes; then
			sm_databases="$sm_databases, DNS";
		#sm_incdirs="$sm_incdirs $resolve_inc";
		#sm_libs="$sm_libs "$resolve_lib";
		sm_sendmail_envdef="$sm_sendmail_envdef $resolve_inc";
		sm_sendmail_libs="$sm_sendmail_libs $resolve_lib";
	else
		AC_MSG_ERROR([Could not locate RESOLV package])
		fi;
#	fi;
sm_enable_bind=$sm_have_bind;		AC_SUBST(sm_enable_bind)

#-------------------------------------------------------------------
#
# Check for presence of HESIOD headers
#	Note: if using libhesiod, we should have HES_GETMAILHOST
#	  if using libbind, it doesn't have HES_GETMAILHOST ;-{
#
sm_have_hesiod=no;
sm_hesiod_parms='';
if test $sm_enable_hesiod != no; then
	AC_CHECK_HEADERS(hesiod.h bind/hesiod.h)
	if test $ac_cv_header_hesiod_h = yes; then
		sm_have_hesiod=yes;
	elif [[ $ac_cv_header_bind_hesiod_h = yes ]] \
	&&   [[ $sm_have_bind = yes ]]; then
		sm_have_hesiod=yes;
		fi;

	if test $sm_have_hesiod = yes; then
		AC_MSG_CHECKING([for hes_getmailhost])
		CPPFLAGS_SAVE="$CPPFLAGS";
		CPPFLAGS="$resolve_inc";
		AC_EGREP_CPP([hes_getmailhost\(], [
				#include <hesiod.h>
			], sm_hesiod_parms="-DHES_GETMAILHOST")
		CPPFLAGS="$CPPFLAGS_SAVE";
		if test -z "$sm_hesiod_parms"; then
			AC_MSG_RESULT([no])
		else
			AC_MSG_RESULT([yes])
			fi;
		fi;

	if test $sm_have_hesiod = yes; then
		sm_databases="$sm_databases, HESIOD";
		sm_badepends="$sm_badepends, libhesiod-dev";
		sm_mapdef="$sm_mapdef -DHESIOD";
		sm_libsmutil_envdef="$sm_libsmutil_envdef $resolve_inc";
		sm_sendmail_envdef="$sm_sendmail_envdef $sm_hesiod_parms";
		# Need following if not using bind headers
		if	test -z "$resolve_inc"; then
			sm_sendmail_libs="$sm_sendmail_libs -lhesiod";
			fi;
	elif test $sm_enable_hesiod = auto; then
		AC_MSG_WARN([Could not locate HESIOD (libhesiod-dev) package])
	else
		AC_MSG_ERROR([Could not locate HESIOD (libhesiod-dev) package])
		fi;
	fi;
sm_enable_hesiod=$sm_have_hesiod;		AC_SUBST(sm_enable_hesiod)

#-------------------------------------------------------------------
#
# Check for presence of TCP Wrapper headers
#
sm_have_tcpd=no;
if test $sm_enable_tcpd != no; then
	AC_CHECK_HEADERS(tcpd.h,
		[sm_have_tcpd=yes]
		,[sm_have_tcpd=no])

	if test $ac_cv_header_tcpd_h = yes ; then
		AC_COMPILE_IFELSE([
			AC_LANG_PROGRAM([[
				#include <tcpd.h>
				extern int allow_severity;
				extern int deny_severity;
				struct request_info *request;
				]]
				,[[hosts_access(request);]]
				)]
			,[sm_have_tcpd=yes]
			,[sm_have_tcpd=no])
		fi;

	if test $sm_have_tcpd = yes; then
		AC_CHECK_LIB(wrap, main,
			[sm_have_tcpd=yes]
			,[sm_have_tcpd=no])

		if test $sm_have_tcpd != yes; then
			AC_MSG_WARN([Could not find -lwrap (libwrap0-dev)])
			fi;
		fi;

	if test $sm_have_tcpd = yes; then
		sm_features="$sm_features, TCPWrappers";
		sm_badepends="$sm_badepends, libwrap0-dev";
		sm_sendmail_envdef="$sm_sendmail_envdef -DTCPWRAPPERS";
		sm_sendmail_libs="$sm_sendmail_libs -lwrap";
	elif test $sm_enable_tcpd = auto; then
		AC_MSG_WARN([TCPD(libwrap0-dev) protection not supported!])
	else
		AC_MSG_ERROR([TCPD(libwrap0-dev) protection not supported!])
		fi;
	fi;
sm_enable_tcpd=$sm_have_tcpd;		AC_SUBST(sm_enable_tcpd)

#-------------------------------------------------------------------
#
# Check for presence of IPV6 headers
#
sm_have_ipv6=no;
if test $sm_enable_ipv6 != no; then
	AC_CHECK_HEADERS(netinet/ip6.h,
		[sm_have_ipv6=yes]
		,[sm_have_ipv6=no])

	if test $ac_cv_header_netinet_ip6_h = yes ; then
		AC_EGREP_CPP(sm_have_ipv6=yes, [
			#include <netdb.h>
			#if defined(AI_DEFAULT)
				sm_have_ipv6=yes
			#endif
			], sm_have_ipv6=yes, [
				AC_EGREP_CPP(sm_have_ipv6=yes, [
				#include <bind/netdb.h>
				#if defined(AI_DEFAULT)
					sm_have_ipv6=yes
				#endif
				], sm_have_ipv6=yes,
				,[sm_have_ipv6=no])
			])
		if test $sm_have_ipv6 = no; then
			AC_MSG_ERROR([Your level of netdb precludes IPv6 support])
			fi;
		fi;

# sendmail does not use getaddrinfo()
#	if test $sm_have_ipv6 = yes; then
#		AC_CHECK_FUNCS(getaddrinfo,
#			[sm_have_ipv6=yes]
#			,[sm_have_ipv6=no])
#		if test $sm_have_ipv6 = no; then
#			AC_MSG_ERROR([IPv6 support requires getaddrinfo])
#			fi;
#		fi;

# sendmail supports gethostbyname2()
	if test $sm_have_ipv6 = yes; then
		AC_CHECK_FUNCS(gethostbyname2,
			[sm_have_ipv6=yes]
			,[sm_have_ipv6=no])
		if test $sm_have_ipv6 = no; then
			AC_MSG_ERROR([IPv6 support requires gethostbyname2])
		else
			sm_envdef="$sm_envdef -DHAS_GETHOSTBYNAME2=1"
		fi;
	fi;

	if test $sm_have_ipv6 = yes; then
			sm_features="$sm_features, IPv6";
			# Needed by sendmail, libmilter, maybe others
			sm_envdef="$sm_envdef -DNETINET6";
			# Need following if using bind headers
			if	test ! -z "$resolve_inc"; then
				sm_envdef="$sm_envdef -DNEEDSGETIPNODE=0";
				fi;
	elif test $sm_enable_ipv6 = auto; then
		AC_MSG_WARN([Could not locate IPv6 package])
	else
		AC_MSG_ERROR([Could not locate IPv6 package])
		fi;
	fi;
sm_enable_ipv6=$sm_have_ipv6;		AC_SUBST(sm_enable_ipv6)

#-------------------------------------------------------------------
#
# Check for presence of maillock headers
#
sm_have_maillock=no;
if test $sm_enable_maillock != no; then
	AC_CHECK_HEADERS(maillock.h,
		[sm_have_maillock=yes]
		,[sm_have_maillock=no])

	if test $ac_cv_header_maillock_h = yes ; then
		AC_CHECK_LIB(lockfile, main,
			[sm__have_maillock=yes]
			,[sm_have_maillock=no])

		if test $sm_have_maillock != yes; then
			AC_MSG_WARN([Could not find -llockfile (liblockfile-dev)])
			fi;
		fi;

	if test $sm_have_maillock = yes; then
		sm_features="$sm_features, LockFile";
		sm_badepends="$sm_badepends, liblockfile-dev";
		sm_mail_local_envdef="$sm_mail_local_envdef -DMAILLOCK";
		sm_mail_local_libs="$sm_mail_local_libs -llockfile";
	elif test $sm_enable_maillock = auto; then
		AC_MSG_WARN([Could not locate liblockfile-dev package])
	else
		AC_MSG_ERROR([Could not locate liblockfile-dev package])
		fi;
	fi;
sm_enable_maillock=$sm_have_maillock;		AC_SUBST(sm_enable_maillock)

#-------------------------------------------------------------------
#
# Check for presence of SFIO headers
#	Note: required for TLS and security layer of SASL on 8.11)
#	Note: SFIO is *only* used if required, but we allow the checks
#		on any version (for header test) - just issue no messages
#		unless needed
#
sm_have_sfio=no;
if test $sm_enable_sfio != no; then
	CPPFLAGS_SAVE="$CPPFLAGS";
	CPPFLAGS="-I/usr/include/sfio"
	AC_CHECK_HEADERS(sfio/stdio.h,
		[sm_have_sfio=yes]
		,[sm_have_sfio=no])
	CPPFLAGS="$CPPFLAGS_SAVE";

	if test $ac_cv_header_sfio_stdio_h = yes ; then
		AC_CHECK_LIB(sfio, main,
			[sm_have_sfio=yes]
			,[sm_have_sfio=no])

		if test $sm_have_sfio != yes; then
			AC_MSG_WARN([Could not find -lsfio (sfio-dev)])
			fi;
		fi;

	# SFIO is only required for TLS/SASL on 8.11, ignore it otherwise
	# when using it, however, it hits *everything*, put it in the front!
	if test "$sm_version_major" = "8.11"; then
		if test $sm_have_sfio = yes; then
			sm_badepends="$sm_badepends, sfio-dev";
			sm_incdirs="-I/usr/include/sfio $sm_incdirs";
			sm_envdef="-DSFIO $sm_envdef";
			sm_libs="-lsfio $sm_libs";
		elif test $sm_enable_sfio = auto; then
			AC_MSG_WARN([SFIO, and therefore TLS not supported!])
		else
			AC_MSG_ERROR([SFIO, and therefore TLS not supported!])
			fi;
	else
		sm_have_sfio=no;
		fi;
	fi;
sm_enable_sfio=$sm_have_sfio;		AC_SUBST(sm_enable_sfio)

#-------------------------------------------------------------------
#
# Check for presence of SASL headers (for SMTP auth)
#
sm_have_auth=no;
sm_auth_lib='?';
if test $sm_enable_auth != no; then
	AC_CHECK_HEADERS(sasl/sasl.h sasl.h)

	if test $ac_cv_header_sasl_sasl_h = yes \
	   -o	$ac_cv_header_sasl_h = yes; then
		sm_have_auth=yes;
	else
		sm_have_auth=no;
		fi;

	if test $sm_have_auth = yes; then
		AC_MSG_CHECKING([sasl version])
		AC_EGREP_CPP(sm_auth_lib=2,[
			#if defined(HAVE_SASL_SASL_H)
				#include <sasl/sasl.h>
			#elif defined(HAVE_SASL_H)
				#include <sasl.h>
				#endif
			#if SASL_VERSION_MAJOR >= 2
				sm_auth_lib=2
				#endif
			], [sm_auth_lib=2], [sm_auth_lib=1])
		AC_MSG_RESULT([$sm_auth_lib])
		if test "X$sm_auth_lib" = "X"; then
			AC_MSG_WARN([SASL version unknown, omitting support!])
			sm_have_auth=no;
			fi;
		fi;

	if test $sm_auth_lib = 2; then
		junk='sasl2';
	else
		junk='sasl';
		fi;

	AC_CHECK_LIB($junk, sasl_client_init,
		[sm_have_auth=yes]
		,[sm_have_auth=no])

	if test $sm_have_auth != yes; then
		AC_MSG_WARN([Could not find -l${junk} (lib${junk}-dev)])
		fi;

	if test $sm_have_auth = yes; then
		sm_features="$sm_features, SMTP AUTH(SASL)";
		sm_badepends="$sm_badepends, lib${junk}-dev";
		sm_suggests="$sm_suggests, ${junk}-bin";
		sm_suggests="$sm_suggests, lib${junk}-modules";
		sm_sendmail_envdef="$sm_sendmail_envdef -DSASL";
		if test $ac_cv_header_sasl_sasl_h = yes; then
			sm_sendmail_envdef="$sm_sendmail_envdef -I/usr/include/sasl";
			fi;
		if test "$sm_version_major" = "8.12"; then
			:;
		elif test "$sm_version_major" = "8.11"; then
			sm_ffr="$sm_ffr -D_FFR_UNSAFE_SASL=1";
			sm_ffr="$sm_ffr -D_FFR_SASL_OPTS=1";
			sm_ffr="$sm_ffr -D_FFR_DEFAUTHINFO_MECHS=1";
		elif test "$sm_version_major" = "8.10"; then
			sm_ffr="$sm_ffr -D_FFR_UNSAFE_SASL=1";
			sm_ffr="$sm_ffr -D_FFR_SASL_OPTS=1";
			sm_ffr="$sm_ffr -D_FFR_DEFAUTHINFO_MECHS=1";
			fi;
		sm_sendmail_libs="$sm_sendmail_libs -l${junk}";
	elif test $sm_enable_auth = auto; then
		AC_MSG_WARN([SMTP authentication not supported!])
	else
		AC_MSG_ERROR([SMTP authentication not supported!])
		fi;
	fi;
sm_enable_auth=$sm_have_auth;		AC_SUBST(sm_enable_auth)
AC_SUBST(sm_auth_lib)
AM_CONDITIONAL(SM_ENABLE_AUTH, test x$sm_enable_auth = xyes)

#-------------------------------------------------------------------
#
# Check for presence of SSL headers
#
sm_have_tls=no;
if test $sm_enable_tls != no; then
	AC_CHECK_HEADERS(openssl/ssl.h,
		[sm_have_tls=yes]
		,[sm_have_tls=no])

	if test $ac_cv_header_openssl_ssl_h = yes; then

		tmp_libs="$LIBS"
		LIBS="$LIBS -lssl"
		AC_LINK_IFELSE(
			       [AC_LANG_PROGRAM([[#include <openssl/ssl.h>]],
						[[SSL_library_init();]])],
						[sm_have_tls="yes";],
						[sm_have_tls="no";])

		LIBS=$tmp_libs
		if test $sm_have_tls != yes; then
			AC_MSG_WARN([Could not find -lssl (libssl-dev)])
			fi;
		fi;

	# SFIO is required for TLS/SSL support on 8.11
	if test $sm_have_tls = yes; then
		if [[ $sm_have_sfio != yes ]] \
		&& [[ "$sm_version_major" = '8.11' ]]; then
			AC_MSG_WARN([SFIO is required for SSL privacy protection!])
			sm_have_tls=no;
			fi;
		fi;

	if test $sm_have_tls = yes; then
			sm_features="$sm_features, STARTTLS(SSL)";
			sm_badepends="$sm_badepends, libssl-dev";
			sm_suggests="$sm_suggests, openssl";
			sm_sendmail_envdef="$sm_sendmail_envdef -DSTARTTLS";
			sm_sendmail_envdef="$sm_sendmail_envdef -DDANE=1"
			sm_sendmail_libs="$sm_sendmail_libs -lcrypto -lssl";
			sm_ffr="$sm_ffr -D_FFR_TLS_EC";
	elif test $sm_enable_tls = auto; then
		AC_MSG_WARN([SSL/TLS privacy protection not supported!])
	else
		AC_MSG_ERROR([SSL/TLS privacy protection not supported!])
		fi;
	fi;
sm_enable_tls=$sm_have_tls;		AC_SUBST(sm_enable_tls)
AM_CONDITIONAL(SM_ENABLE_TLS, test x$sm_enable_tls = xyes)

#-------------------------------------------------------------------
# Any requisite variable cleanup
#-------------------------------------------------------------------
sm_databases=$(echo "${sm_databases}" | sed -e 's/^, //');
sm_features=$(echo "${sm_features}" | sed -e 's/^, //');
sm_recommends=$(echo "${sm_recommends}" | sed -e 's/^, //');

#-------------------------------------------------------------------
# Add any FFRs to sendmail_ENVDEF
#-------------------------------------------------------------------
sm_sendmail_envdef="$sm_sendmail_envdef $sm_ffr";


#-------------------------------------------------------------------
# Fini - define configuration files, and commands upon them
#-------------------------------------------------------------------
AC_CONFIG_FILES([Makefile])
AC_CONFIG_FILES([build/autoconf.mk])
AC_CONFIG_FILES([build/autoconf.pl])
AC_CONFIG_FILES([build/autoconf.sh])
AC_CONFIG_FILES([build/update_chaos],[
		echo 'Updating Build setup';
		chmod ug+x ./build/update_chaos;
		(cd ../ && ./debian/build/update_chaos);])
AC_CONFIG_FILES([build/site.config.m4])
AC_CONFIG_FILES([control.new:control.in],[
		if cmp control control.new; then
			echo "*** debian/control was up-to-date ***";
			rm -f control.new;
		else
			echo "*** debian/control was updated, aborting, please restart your build ***";
			mv control.new control;
			exit 1;
		fi;
		])
AC_CONFIG_FILES([libmilter${sm_libmilter_version}.install:libmilter.install.in])
AC_CONFIG_FILES([libmilter${sm_libmilter_version}.symbols:libmilter.symbols.in])
AC_CONFIG_FILES([milter.pc])
AC_CONFIG_FILES([sendmail-base.dirs])
AC_CONFIG_FILES([sendmail-base.postinst])
AC_CONFIG_FILES([sendmail-base.postrm])
AC_CONFIG_FILES([sendmail-base.preinst])
AC_CONFIG_FILES([sendmail-base.prerm])
AC_CONFIG_FILES([sendmail-cf.postrm])
AC_CONFIG_FILES([sendmail-bin.sendmail.cron.daily])
AC_CONFIG_FILES([sendmail-bin.dirs])
AC_CONFIG_FILES([sendmail-bin.sendmail.init.d:sendmail-bin.sendmail.init.d.in:local/sendmail.in])
AC_CONFIG_FILES([sendmail-bin.postinst])
AC_CONFIG_FILES([sendmail-bin.postrm])
AC_CONFIG_FILES([sendmail-bin.preinst])
AC_CONFIG_FILES([sendmail-bin.prerm])
AC_CONFIG_FILES([sendmail-bin.suid])
AC_CONFIG_FILES([bug-control])
AC_CONFIG_FILES([bug-script])
AC_CONFIG_FILES([cf/Makefile])
AC_CONFIG_FILES([cf/debian/autoconf.m4])
AC_CONFIG_FILES([cf/debian/sendmail.mc])
AC_CONFIG_FILES([cf/debian/submit.mc])
AC_CONFIG_FILES([cf/domain/debian-msp.m4])
AC_CONFIG_FILES([cf/domain/debian-mta.m4])
AC_CONFIG_FILES([cf/hack/debian_auth.m4])
AC_CONFIG_FILES([cf/hack/virthost_by_ip.m4])
AC_CONFIG_FILES([cf/ostype/debian.m4])
AC_CONFIG_FILES([examples/Makefile])
AC_CONFIG_FILES([examples/dhcp/dhclient-exit-hooks.d/sendmail],
	[chmod a+x ./examples/dhcp/dhclient-exit-hooks.d/sendmail])
AC_CONFIG_FILES([examples/network/if-down.d/sendmail],
	[chmod a+x ./examples/network/if-down.d/sendmail])
AC_CONFIG_FILES([examples/network/if-post-down.d/sendmail],
	[chmod a+x ./examples/network/if-post-down.d/sendmail])
AC_CONFIG_FILES([examples/network/if-up.d/sendmail],
	[chmod a+x ./examples/network/if-up.d/sendmail])
AC_CONFIG_FILES([examples/ppp/ip-down.d/sendmail],
	[chmod a+x ./examples/ppp/ip-down.d/sendmail])
AC_CONFIG_FILES([examples/ppp/ip-up.d/sendmail],
	[chmod a+x ./examples/ppp/ip-up.d/sendmail])
AC_CONFIG_FILES([examples/resolvconf/update-libc.d/sendmail],
	[chmod a+x ./examples/resolvconf/update-libc.d/sendmail])
AC_CONFIG_FILES([examples/sasl/sasl.m4])
AC_CONFIG_FILES([examples/tls/starttls.m4])
AC_CONFIG_FILES([local/Makefile])
AC_CONFIG_FILES([local/Parse_conf.pm], [chmod a+x ./local/Parse_conf.pm])
AC_CONFIG_FILES([local/Parse_mc.pm], [chmod a+x ./local/Parse_mc.pm])
AC_CONFIG_FILES([local/dynamic], [chmod a+x ./local/dynamic])
AC_CONFIG_FILES([local/parse_mc], [chmod a+x ./local/parse_mc])
AC_CONFIG_FILES([local/sendmailconfig], [chmod a+x ./local/sendmailconfig])
AC_CONFIG_FILES([local/sendmail], [chmod a+x ./local/sendmail])
AC_CONFIG_FILES([local/update_auth], [chmod a+x ./local/update_auth])
AC_CONFIG_FILES([local/update_authm4], [chmod a+x ./local/update_authm4])
AC_CONFIG_FILES([local/update_conf], [chmod a+x ./local/update_conf])
AC_CONFIG_FILES([local/update_db], [chmod a+x ./local/update_db])
AC_CONFIG_FILES([local/update_ldap], [chmod a+x ./local/update_ldap])
AC_CONFIG_FILES([local/update_mc], [chmod a+x ./local/update_mc])
AC_CONFIG_FILES([local/update_mk], [chmod a+x ./local/update_mk])
AC_CONFIG_FILES([local/update_smrsh], [chmod a+x ./local/update_smrsh])
AC_CONFIG_FILES([local/update_sys], [chmod a+x ./local/update_sys])
AC_CONFIG_FILES([local/update_tls], [chmod a+x ./local/update_tls])
AC_CONFIG_FILES([local/update_tlsm4], [chmod a+x ./local/update_tlsm4])
AC_CONFIG_FILES([sensible_mda/Makefile])
AC_CONFIG_FILES([sensible_mda/sensible-mda.c])
AC_OUTPUT
