dnl Process this file with autoconf to produce a configure script.
dnl $Id$
dnl
dnl Copyright 1998 - 1999 Double Precision, Inc.  See COPYING for
dnl distribution information.

AC_INIT(rfc822.c)
AC_PREREQ([2.50])
AC_CONFIG_HEADER(config.h)
AC_SUBST(AR)
AC_SUBST(RANLIB)

dnl Checks for programs.
AC_PROG_CC
AC_CANONICAL_HOST
AC_CHECK_TOOLS(AR, ar, ar)
AC_CHECK_TOOLS(RANLIB, ranlib, ranlib)

AC_USE_SYSTEM_EXTENSIONS

if test "$GCC" = yes ; then
        CXXFLAGS="$CXXFLAGS -Wall"
        CFLAGS="$CFLAGS -Wall"
fi

dnl Checks for libraries.

dnl Checks for header files.
AC_HEADER_STDC

dnl Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_TYPE_SIZE_T
AC_STRUCT_TM

dnl Checks for library functions.

AC_CHECK_FUNCS(strcasecmp strncasecmp)

AC_CACHE_CHECK([how to calculate alternate timezone],librfc822_cv_SYS_TIMEZONE,

AC_TRY_COMPILE([
#include	<time.h>
],[
int main()
{
time_t	t=altzone;
int	offset = -timezone;

	return (0);
}
], librfc822_cv_SYS_TIMEZONE=altzone,

	AC_TRY_COMPILE([
#include	<time.h>
],[
int main()
{
int	n=daylight;
int	offset = -timezone;

	return (0);
}
	], librfc822_cv_SYS_TIMEZONE=daylight,

	AC_TRY_COMPILE([
#include	<time.h>

extern struct tm dummy;
],[
int main()
{
long	n=dummy.tm_gmtoff;

	return (0);
}
	] ,librfc822_cv_SYS_TIMEZONE=tm_gmtoff,
		librfc822_cv_SYS_TIMEZONE=unknown
			)
		)
	)
)

case $librfc822_cv_SYS_TIMEZONE in
tm_gmtoff)
	AC_DEFINE_UNQUOTED(USE_TIME_GMTOFF,1,
			   [Whether time offset is specified via the tm_gmtoff member])
	;;
altzone)
	AC_DEFINE_UNQUOTED(USE_TIME_ALTZONE,1,
			   [Whether daylight savings time offset is set via the altzone variable])
	;;
daylight)
	AC_DEFINE_UNQUOTED(USE_TIME_DAYLIGHT,1,
			   [Whether daylight savings time offset is set via the tm_isdst member])
	;;
*)
	AC_MSG_WARN(Cannot figure out how to calculate the alternate timezone, will use GMT)
	;;
esac

if test -d ../unicode
then
	AC_DEFINE_UNQUOTED(HAVE_LIBUNICODE,1,[Whether we have libunicode.a])
fi

AC_OUTPUT(Makefile)
