dnl Process this file with autoconf to produce a configure script.

AC_INIT(unicode, 0.10, [courier-maildrop@lists.sourceforge.net])

>confdefs.h  # Kill PACKAGE_ macros

AC_CONFIG_SRCDIR(unicodecpp.C)

LPATH="$PATH:/usr/local/bin"

AM_CONFIG_HEADER(unicode_config.h)
AM_INIT_AUTOMAKE([foreign no-define])
dnl Checks for programs.

AC_PROG_MAKE_SET
AM_PROG_LIBTOOL
AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_CC
AC_PROG_CXX
AC_PATH_PROGS(PERL, perl5 perl, perl, $LPATH)

if test "$PERL" = "perl"
then
	AC_MSG_ERROR(Perl not found.)
fi

dnl Checks for libraries.

dnl Checks for header files.

AC_CHECK_HEADERS(stddef.h wchar.h locale.h)

dnl Checks for typedefs, structures, and compiler characteristics.

dnl Checks for library functions.

AC_CHECK_FUNCS(setlocale)

AM_CONDITIONAL(UPDATE_UNICODE, test -f ${srcdir}/UnicodeData.txt)

AC_SYS_LARGEFILE

AC_C_BIGENDIAN

AC_MSG_CHECKING([whether libcharset is used])
AC_ARG_WITH(libcharset,
	[  --with-libcharset     Use the libcharset library],
	unicode_with_libcharset=$withval,
	unicode_with_libcharset=no)
AC_MSG_RESULT($unicode_with_libcharset)
if test "$unicode_with_libcharset" = "yes"; then
  AC_CHECK_LIB(charset,locale_charset)
  if test "$ac_cv_lib_charset_locale_charset" = "yes"; then
    AC_CHECK_HEADERS(localcharset.h libcharset.h)
  else
    AC_MSG_ERROR([libcharset was not found.  Install libcharset package.])
  fi
  AC_DEFINE_UNQUOTED(UNICODE_USE_LIBCHARSET, 1,
	[ Set this to 1 to use libcharset library. ])
else
  AM_LANGINFO_CODESET
fi

save_LIBS="$LIBS"

LIBS="$LIBS -liconv"

AC_LINK_IFELSE([AC_LANG_PROGRAM([
#include <iconv.h>
],[

iconv_open("","");
])] ,[ : ], [LIBS="$save_LIBS"])

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

AC_OUTPUT(Makefile)
