dnl $Id$
dnl
dnl Copyright 1998 - 1999 Double Precision, Inc.  See COPYING for
dnl distribution information.
AC_INIT(rfc2045.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
AC_CHECK_HEADERS(unistd.h sys/wait.h strings.h)

AC_CACHE_CHECK([for missing gethostname prototype],rfc2045_cv_SYS_GETHOSTNAME,

AC_TRY_COMPILE([
#if HAVE_UNISTD_H
#include	<unistd.h>
#endif

extern int gethostname(int,int);
],[
],rfc2045_cv_SYS_GETHOSTNAME=yes,rfc2045_cv_SYS_GETHOSTNAME=no
)

)

if test $rfc2045_cv_SYS_GETHOSTNAME = "no"
then
	AC_DEFINE_UNQUOTED(HAS_GETHOSTNAME, 1,
			   [Define if gethostname() is provided])
fi

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

dnl Checks for library functions.
AC_CHECK_FUNC(strncasecmp,,CFLAGS="$CFLAGS -Dstrncasecmp=strnicmp")
AC_CHECK_FUNC(strcasecmp,,CFLAGS="$CFLAGS -Dstrcasecmp=stricmp")

AC_ARG_WITH(package, [], package="$withval",
	[
		package="$PACKAGE"
		ac_configure_args="$ac_configure_args --with-package=$PACKAGE"
	])

AC_ARG_WITH(version, [], version="$withval",
	[
		version="$VERSION"
		ac_configure_args="$ac_configure_args --with-version=$VERSION"
	])

AC_DEFINE_UNQUOTED(RFC2045PKG,"$package",[Specify package])
AC_DEFINE_UNQUOTED(RFC2045VER,"$version",[Specify version])

AC_ARG_ENABLE(mimecharset,
	[  --enable-mimecharset=charset   Default MIME charset to set on new messages],
	RFC2045CHARSET="$enableval", RFC2045CHARSET="us-ascii")

CFLAGS="$CFLAGS -I${srcdir}/.."
AC_SUBST(rfc822includedir)

AC_SUBST(RFC2045CHARSET)
AC_OUTPUT(Makefile rfc2045charset.h)
