added iconv format checker.
authorNot Zed <NotZed@Ximian.com>
Fri, 3 Dec 2004 03:34:16 +0000 (03:34 +0000)
committerMichael Zucci <zucchi@src.gnome.org>
Fri, 3 Dec 2004 03:34:16 +0000 (03:34 +0000)
2004-11-15  Not Zed  <NotZed@Ximian.com>

        * iconv-detect.c: added iconv format checker.

        * configure.in: add stftime checks and iconv charset format checks.

ChangeLog
Makefile.am
configure.in
iconv-detect.c [new file with mode: 0644]

index d513c98..d63b634 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
        (e_source_selector_get_primary_source_group): accessor for 
        primary source group.
 
+2004-11-16  Not Zed  <NotZed@Ximian.com>
+
+       * Makefile.am (DIST_SUBDIRS, SUBDIRS): Added camel.
+
+       * configure.in: Added more camel required config checks.  Build
+       the camel makefiles.  Not sure if this should be in its own
+       configure.in.
+
+2004-11-15  Not Zed  <NotZed@Ximian.com>
+
+       * libedataserver/e-util.c: include config.h.
+
+       * libedataserver/e-sexp.c: updated from evolution/e-util.
+
+       * libedataserver/e-memory.c: updated from evolution/e-util.
+
+       * iconv-detect.c: added iconv format checker.
+
+       * configure.in: add stftime checks and iconv charset format checks.
+
+       * libedataserver/e-util.c (e_strftime): copied from gal/e-util.h.
+
+       * libedataserver/e-time-utils.c (parse_with_strptime): reove
+       e-utf8 depenedncy.
+
+       * libedataserver/e-iconv.[ch]: Moved from gal/util.
+
+       * libedataserver/e-trie.[ch]: Moved from evolution/e-util.
+       * libedataserver/e-msgport.[ch]: Moved from evolution/e-util.
+       * libedataserver/e-time-utils.[ch]: Moved from evolution/e-util.
+
 2004-11-05  Rodrigo Moya <rodrigo@novell.com>
 
        * configure.in: use evolution-data-server-$BASE_VERSION as the
index c8b1763..b2030f6 100644 (file)
@@ -1,8 +1,8 @@
 AUTOMAKE_OPTIONS = 1.6
 DISTCHECK_CONFIGURE_FLAGS = --enable-gtk-doc
 
-SUBDIRS = libdb libedataserver servers addressbook calendar libedataserverui src docs po
-DIST_SUBDIRS= libedataserver servers addressbook calendar libedataserverui src docs po
+SUBDIRS = libdb libedataserver camel servers addressbook calendar libedataserverui src docs po
+DIST_SUBDIRS= libedataserver camel servers addressbook calendar libedataserverui src docs po
 
 changelogs =                   \
        ChangeLog
index 809bcd1..d8771c6 100644 (file)
@@ -47,6 +47,10 @@ LIBEGROUPWISE_CURRENT=0
 LIBEGROUPWISE_REVISION=1
 LIBEGROUPWISE_AGE=0
 
+LIBCAMEL_CURRENT=0
+LIBCAMEL_REVISION=0
+LIBCAMEL_AGE=0
+
 AC_SUBST(LIBEDATASERVER_CURRENT)
 AC_SUBST(LIBEDATASERVER_REVISION)
 AC_SUBST(LIBEDATASERVER_AGE)
@@ -68,7 +72,9 @@ AC_SUBST(LIBEDATABOOK_AGE)
 AC_SUBST(LIBEGROUPWISE_CURRENT)
 AC_SUBST(LIBEGROUPWISE_REVISION)
 AC_SUBST(LIBEGROUPWISE_AGE)
-
+AC_SUBST(LIBCAMEL_CURRENT)
+AC_SUBST(LIBCAMEL_REVISION)
+AC_SUBST(LIBCAMEL_AGE)
 
 dnl Put the ACLOCAL flags in the Makefile
 ACLOCAL="$ACLOCAL $ACLOCAL_FLAGS"
@@ -116,6 +122,854 @@ AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE, "$GETTEXT_PACKAGE", [Package name for gettex
 localedir='$(prefix)/$(DATADIRNAME)/locale'
 AC_SUBST(localedir)
 
+dnl ******************************
+dnl iconv checking
+dnl ******************************
+have_iconv=no
+AC_ARG_WITH(libiconv, [  --with-libiconv         Prefix where libiconv is installed])
+case $withval in
+/*)
+    ICONV_CFLAGS="-I$withval/include"
+    ICONV_LIBS="-L$withval/lib"
+    ;;
+esac
+
+save_CFLAGS="$CFLAGS"
+save_LIBS="$LIBS"
+CFLAGS="$CFLAGS $ICONV_CFLAGS"
+LIBS="$LIBS $ICONV_LIBS -liconv"
+AC_CACHE_CHECK(for iconv in -liconv, ac_cv_libiconv, AC_TRY_LINK([
+#include <iconv.h>
+], [
+       iconv_t cd;
+       cd = iconv_open ("UTF-8", "ISO-8859-1");
+], ac_cv_libiconv=yes, ac_cv_libiconv=no))
+if test $ac_cv_libiconv = yes; then
+       ICONV_LIBS="$ICONV_LIBS -liconv"
+       have_iconv=yes
+else
+       CFLAGS="$save_CFLAGS"
+       LIBS="$save_LIBS"
+       AC_CHECK_FUNC(iconv, have_iconv=yes, have_iconv=no)
+fi
+
+if test $have_iconv = yes; then
+       if test $ac_cv_libiconv = no; then
+               AC_CHECK_FUNCS(gnu_get_libc_version)
+       fi
+       AC_CACHE_CHECK([if iconv() handles UTF-8], ac_cv_libiconv_utf8, AC_TRY_RUN([
+#include <iconv.h>
+#include <stdlib.h>
+#include <string.h>
+#ifdef HAVE_GNU_GET_LIBC_VERSION
+#include <gnu/libc-version.h>
+#endif
+
+int main (int argc, char **argv)
+{
+       const char *jp = "\x1B\x24\x42\x46\x7C\x4B\x5C\x38\x6C";
+       const char *utf8 = "\xE6\x97\xA5\xE6\x9C\xAC\xE8\xAA\x9E";
+       char *transbuf = malloc (10), *trans = transbuf;
+       iconv_t cd;
+       size_t jp_len = strlen (jp), utf8_len = 10;
+       size_t utf8_real_len = strlen (utf8);
+
+#ifdef HAVE_GNU_GET_LIBC_VERSION
+       /* glibc 2.1.2's iconv is broken in hard to test ways. */
+       if (!strcmp (gnu_get_libc_version (), "2.1.2"))
+               exit (1);
+#endif
+
+       cd = iconv_open ("UTF-8", "ISO-2022-JP");
+       if (cd == (iconv_t) -1)
+               exit (1);
+       if (iconv (cd, &jp, &jp_len, &trans, &utf8_len) == -1 || jp_len != 0)
+               exit (1);
+       if (memcmp (utf8, transbuf, utf8_real_len) != 0)
+               exit (1);
+
+       exit (0);
+}], ac_cv_libiconv_utf8=yes, [ac_cv_libiconv_utf8=no; have_iconv=no], [ac_cv_libiconv_utf8=no; have_iconv=no]))
+fi
+
+if test "$have_iconv" = no; then
+       AC_MSG_ERROR([You need to install a working iconv implementation, such as ftp://ftp.gnu.org/pub/gnu/libiconv])
+fi
+AC_SUBST(ICONV_CFLAGS)
+AC_SUBST(ICONV_LIBS)
+
+CFLAGS="$CFLAGS -I$srcdir"
+
+AC_MSG_CHECKING(preferred charset formats for system iconv)
+AC_TRY_RUN([
+#define CONFIGURE_IN
+#include "iconv-detect.c"
+],[
+       AC_MSG_RESULT(found)
+],[
+       AC_MSG_RESULT(not found)
+       AC_WARN([
+       *** The iconv-detect program was unable to determine the
+       *** preferred charset formats recognized by your system
+       *** iconv library. It is suggested that you install a
+       *** working iconv library such as the one found at
+       *** ftp://ftp.gnu.org/pub/gnu/libiconv
+       ])
+])
+
+CFLAGS="$save_CFLAGS"
+LIBS="$save_LIBS"
+
+dnl Check to see if strftime supports the use of %l and %k
+
+AC_MSG_CHECKING(for %l and %k support in strftime)
+AC_TRY_RUN([
+#include <string.h>
+#include <time.h>
+
+int main(int argc, char **argv)
+{
+       char buf[10];
+       time_t rawtime;
+       struct tm *timeinfo;
+
+       time(&rawtime);
+       timeinfo=localtime(&rawtime);
+       strftime(buf, 10, "%l %k", timeinfo);
+
+       if (strstr(buf, "l") || strstr(buf, "k"))
+               exit(1);
+       else
+               exit(0);
+}],[
+AC_DEFINE(HAVE_LKSTRFTIME, 1, [strftime supports use of l and k])
+ac_cv_lkstrftime=yes
+],ac_cv_lkstrftime=no,ac_cv_lkstrftime=no])
+AC_MSG_RESULT($ac_cv_lkstrftime)
+
+dnl ********************************************************************************
+dnl security extension support (SSL and S/MIME)
+dnl
+dnl The following voodoo does detection of mozilla libraries (nspr and nss) 
+dnl needed by Camel (SSL and S/MIME).
+dnl
+dnl The Evolution security extensions are only built if these libraries are found
+dnl ********************************************************************************
+msg_ssl="no"
+msg_smime="no"
+
+dnl these 2 enable's are inverses of each other
+AC_ARG_ENABLE(nss, [  --enable-nss=[yes,no,static]        Attempt to use Mozilla libnss for SSL support.],
+       enable_nss="$enableval", enable_nss="yes")
+
+AC_ARG_ENABLE(smime, [ --enable-smime=[yes,no]            Attempt to use Mozilla libnss for SMIME support (this requires --enable-nss)],
+       enable_smime="$enableval", enable_smime="yes")
+
+dnl ***********************************************************************************************************
+dnl OpenSSL is no longer available. DO NOT USE IT!!! The OpenSSL camel code is known to have security problems, 
+dnl it doesn't work, it doesn't build, it is never tested, and to top it all off, it is not GPL compatable.
+dnl ***********************************************************************************************************
+dnl
+dnl AC_ARG_ENABLE(openssl, [  --enable-openssl=[no,yes]        Attempt to use OpenSSL for SSL support.],
+dnl    enable_openssl="$enableval", enable_openssl="no")
+dnl 
+dnl if test "x${enable_openssl}" = "xyes"; then
+dnl User wants to override nss with OpenSSL
+dnl    enable_nss="no"
+dnl    AC_MSG_WARN([OpenSSL enabled, disabling NSS.])
+dnl fi
+
+AC_ARG_WITH(nspr-includes, [  --with-nspr-includes=PREFIX      Location of Mozilla nspr4 includes.],
+       with_nspr_includes="$withval")
+
+AC_ARG_WITH(nspr-libs, [  --with-nspr-libs=PREFIX              Location of Mozilla nspr4 libs.],
+       with_nspr_libs="$withval")
+
+AC_ARG_WITH(nss-includes, [  --with-nss-includes=PREFIX        Location of Mozilla nss3 includes.],
+       with_nss_includes="$withval")
+
+AC_ARG_WITH(nss-libs, [  --with-nss-libs=PREFIX                Location of Mozilla nss3 libs.],
+       with_nss_libs="$withval")
+
+if test "x${enable_nss}" = "xyes" || test "x${enable_nss}" = "xstatic"; then
+       if test -n "${with_nspr_includes}" || test -n "${with_nspr_libs}" || test -n "${with_nss_includes}" || test -n "${with_nss_libs}" || test "x${enable_nss}" = "xstatic"; then
+dnl If the user specifies --with-foo or --enable-nss=static, then we have to do this manually
+               check_manually="yes"
+       else
+               check_manually="no"
+       fi
+       
+       if test "x${check_manually}" = "xno" && `$PKG_CONFIG --exists mozilla-nss`; then
+               PKG_CHECK_MODULES(NSS, mozilla-nss, have_nss="yes")
+               if test "x${have_nss}" = "xyes"; then
+                       msg_ssl="yes (Mozilla NSS)"
+                       if test "x$enable_smime" = "xyes"; then
+                               AC_DEFINE(ENABLE_SMIME,1,[Define if SMIME should be enabled])
+                               msg_smime="yes (Mozilla NSS)"
+                       fi                                  
+                       mozilla_nspr="mozilla-nspr"
+                       mozilla_nss="mozilla-nss"
+                       AC_DEFINE(HAVE_NSS,1,[Define if you have NSS])
+                       AC_DEFINE(HAVE_SSL,1,[Define if you have a supported SSL library])
+                       MANUAL_NSPR_CFLAGS=""
+                       MANUAL_NSPR_LIBS=""
+                       MANUAL_NSS_CFLAGS=""
+                       MANUAL_NSS_LIBS=""
+               else
+                       check_manually="yes"
+               fi
+       fi
+       
+       if test "x${check_manually}" = "xyes"; then
+               mozilla_nss=""
+               have_nspr_includes="no"
+               if test "x${with_nspr_includes}" != "xno"; then
+                       CPPFLAGS_save="$CPPFLAGS"
+                       
+                       AC_MSG_CHECKING(for Mozilla nspr4 includes in $with_nspr_includes)
+                       AC_MSG_RESULT("")
+                       
+                       CPPFLAGS="$CPPFLAGS -I$with_nspr_includes"
+                       AC_CHECK_HEADERS(nspr.h prio.h, [ moz_nspr_includes="yes" ])
+                       CPPFLAGS="$CPPFLAGS_save"
+                       
+                       if test "x{$moz_nspr_includes}" != "xno" -a "x{$moz_nspr_includes}" != "x" ; then
+                               have_nspr_includes="yes"
+                               MANUAL_NSPR_CFLAGS="-I$with_nspr_includes"
+                       fi
+               else
+                       AC_MSG_CHECKING(for Mozilla nspr4 includes)
+                       AC_MSG_RESULT(no)
+               fi
+               
+               have_nspr_libs="no"
+               if test "x${with_nspr_libs}" != "xno" -a "x${have_nspr_includes}" != "xno"; then
+                       CFLAGS_save="$CFLAGS"
+                       LDFLAGS_save="$LDFLAGS"
+                       
+                       if test "$enable_nss" = "static"; then
+                               if test -z "${with_nspr_libs}"; then
+                                       AC_MSG_ERROR([Static linkage requested, but path to nspr libraries not set.]
+[Please specify the path to libnspr4.a]
+[Example: --with-nspr-libs=/usr/lib])
+                                       else
+                                       nsprlibs="-ldl $with_nspr_libs/libplc4.a $with_nspr_libs/libplds4.a $with_nspr_libs/libnspr4.a $PTHREAD_LIB"
+                               fi
+                       else
+                               nsprlibs="-ldl -lplc4 -lplds4 -lnspr4 $PTHREAD_LIB"
+                       fi
+                       
+                       AC_CACHE_CHECK([for Mozilla nspr libraries], moz_nspr_libs,
+                       [
+                               LIBS_save="$LIBS"
+                               CFLAGS="$CFLAGS $MANUAL_NSPR_CFLAGS"
+                               
+                               if test "x${with_nspr_libs}" != "x"; then
+                                       LIBS="$nsprlibs"
+                                       LDFLAGS="$LDFLAGS -L$with_nspr_libs"
+                               else
+                                       LIBS="$nsprlibs"
+                                       LDFLAGS="$LDFLAGS"
+                               fi
+                               
+                               AC_TRY_LINK_FUNC(PR_Init, moz_nspr_libs="yes", moz_nspr_libs="no")
+                               CFLAGS="$CFLAGS_save"
+                               LDFLAGS="$LDFLAGS_save"
+                               LIBS="$LIBS_save"
+                       ])
+                       if test "x$moz_nspr_libs" != "xno"; then
+                               have_nspr_libs="yes"
+                               MANUAL_NSPR_LIBS="-L$with_nspr_libs $nsprlibs"
+                       else
+                               MANUAL_NSPR_CLFAGS=""
+                       fi
+               else
+                       AC_MSG_CHECKING(for Mozilla nspr4 libraries)
+                       AC_MSG_RESULT(no)
+               fi
+               
+               if test "x${with_nss_includes}" != "xno" -a "x${have_nspr_libs}" != "xno"; then
+                       CPPFLAGS_save="$CPPFLAGS"
+                       
+                       AC_MSG_CHECKING(for Mozilla nss3 includes in $with_nss_includes)
+                       AC_MSG_RESULT("")
+                       
+                       if test "x${with_nspr_includes}" != "x"; then
+                               CPPFLAGS="$CPPFLAGS -I$with_nspr_includes -I$with_nss_includes"
+                       else
+                               CPPFLAGS="$CPPFLAGS -I$with_nss_includes"
+                       fi
+                       
+                       AC_CHECK_HEADERS(nss.h ssl.h smime.h,
+                               [ have_nss_includes="yes" ], 
+                               [ have_nss_includes="no" ])
+                       
+                       CPPFLAGS="$CPPFLAGS_save"
+                       
+                       if test "x${have_nss_includes}" = "xyes"; then  
+                               have_nss_includes="yes"
+                               MANUAL_NSS_CFLAGS="-I$with_nss_includes"
+                       else
+                               MANUAL_NSPR_CFLAGS=""
+                               MANUAL_NSPR_LIBS=""
+                       fi
+               else
+                       AC_MSG_CHECKING(for Mozilla nss3 includes)
+                       AC_MSG_RESULT(no)
+               fi
+               
+               if test "x${with_nss_libs}" != "xno" -a "x${have_nss_includes}" != "xno"; then
+                       LDFLAGS_save="$LDFLAGS"
+                       
+                       if test "$enable_nss" = "static"; then
+                               if test -z "${with_nss_libs}"; then
+                                       AC_MSG_ERROR([Static linkage requested, but path to nss libraries not set.]
+[Please specify the path to libnss3.a]
+[Example: --with-nspr-libs=/usr/lib/mozilla])
+                               else
+                                       nsslibs="-ldb1 $with_nss_libs/libnssckfw.a $with_nss_libs/libasn1.a $with_nss_libs/libcrmf.a $with_nss_libs/libswfci.a $with_nss_libs/libjar.a $with_nss_libs/libpkcs12.a $with_nss_libs/libpkcs7.a $with_nss_libs/libpki1.a $with_nss_libs/libsmime.a $with_nss_libs/libssl.a $with_nss_libs/libnss.a $with_nss_libs/libpk11wrap.a $with_nss_libs/libsoftokn.a $with_nss_libs/libfreebl.a $with_nss_libs/libnsspki.a $with_nss_libs/libnssdev.a $with_nss_libs/libcryptohi.a $with_nss_libs/libcerthi.a $with_nss_libs/libcertdb.a $with_nss_libs/libsecutil.a $with_nss_libs/libnssb.a"
+                                       case "$host" in
+                                               *solaris*)
+                                               nsslibs="$nsslibs $with_nss_libs/libfreebl.a"
+                                       ;;
+                                       esac
+                               fi
+                       else
+                               nsslibs="-lssl3 -lsmime3 -lnss3 -lsoftokn3"
+                       fi      
+                       
+                       AC_CACHE_CHECK([for Mozilla nss libraries], moz_nss_libs,
+                       [
+                               LIBS_save="$LIBS"
+                               LDFLAGS="$LDFLAGS -L$with_nspr_libs $nsprlibs -L$with_nss_libs $nsslibs"
+                               LIBS="$nsslibs $nsprlibs"
+                               AC_TRY_LINK_FUNC(NSS_Init, moz_nss_libs="yes", moz_nss_libs="no")
+                               if test "$moz_nss_libs" = no; then
+                                       nsslibs="-lssl3 -lsmime3 -lnss3 -lsoftokn3"
+                                       LDFLAGS="$LDFLAGS -L$with_nspr_libs $nsprlibs -L$with_nss_libs $nsslibs"
+                                       AC_TRY_LINK_FUNC(NSS_Init, moz_nss_libs="yes", moz_nss_libs="no")       
+                               fi
+                               LDFLAGS="$LDFLAGS_save"
+                               LIBS="$LIBS_save"
+                       ])
+                       if test "$moz_nss_libs" != no; then
+                               AC_DEFINE(HAVE_NSS)
+                               AC_DEFINE(HAVE_SSL)
+                               if test "$enable_nss" = "static"; then
+                                       msg_ssl="yes (Mozilla NSS:static)"
+                               else
+                                       msg_ssl="yes (Mozilla NSS)"
+                               fi # static_nss
+                               if test "$enable_smime" = "yes"; then
+                                       AC_DEFINE(ENABLE_SMIME,1,[Define if SMIME should be enabled])
+                                       msg_smime="yes (Mozilla NSS)"
+                               fi
+                               MANUAL_NSS_LIBS="-L$with_nss_libs $nsslibs"
+                       else
+                               MANUAL_NSS_CFLAGS=""
+                               MANUAL_NSPR_CFLAGS=""
+                               MANUAL_NSPR_LIBS=""
+                       fi
+               else
+                       AC_MSG_CHECKING(for Mozilla nss libraries)
+                       AC_MSG_RESULT(no)
+               fi
+               
+               MANUAL_NSS_CFLAGS="$MANUAL_NSPR_CFLAGS $MANUAL_NSS_CFLAGS"
+               MANUAL_NSS_LIBS="$MANUAL_NSPR_LIBS $MANUAL_NSS_LIBS"
+       fi
+fi
+
+AM_CONDITIONAL(ENABLE_SMIME, test "x$msg_smime" != "xno")
+
+AC_SUBST(MANUAL_NSPR_CFLAGS)
+AC_SUBST(MANUAL_NSPR_LIBS)
+AC_SUBST(MANUAL_NSS_CFLAGS)
+AC_SUBST(MANUAL_NSS_LIBS)
+
+dnl check for socklen_t (in Unix98)
+AC_MSG_CHECKING(for socklen_t)
+AC_TRY_COMPILE([#include <sys/types.h>
+#include <sys/socket.h>
+socklen_t x;
+],[],[AC_MSG_RESULT(yes)],[
+AC_TRY_COMPILE([#include <sys/types.h>
+#include <sys/socket.h>
+int accept (int, struct sockaddr *, size_t *);
+],[],[
+AC_MSG_RESULT(size_t)
+AC_DEFINE(socklen_t,size_t,[Define to appropriate type if socklen_t is not defined])], [
+AC_MSG_RESULT(int)
+AC_DEFINE(socklen_t,int)])])
+
+dnl
+dnl system mail stuff
+dnl
+AC_PATH_PROG(SENDMAIL, sendmail, /usr/sbin/sendmail, /usr/sbin:/usr/lib)
+AC_DEFINE_UNQUOTED(SENDMAIL_PATH, "$SENDMAIL", [Path to a sendmail binary, or equivalent])
+
+AC_MSG_CHECKING(system mail directory)
+if test -d /var/mail -a '!' -h /var/mail ; then
+       system_mail_dir=/var/mail
+else
+       system_mail_dir=/var/spool/mail
+fi
+AC_DEFINE_UNQUOTED(SYSTEM_MAIL_DIR, "$system_mail_dir", [Directory local mail is delivered to])
+
+case `ls -ld $system_mail_dir 2>&1 | awk '{print $1;}'` in
+d??????rw?)
+       CAMEL_LOCK_HELPER_USER=""
+       CAMEL_LOCK_HELPER_GROUP=""
+       system_mail_perm="world writable"
+       ;;
+
+d???rw????)
+       CAMEL_LOCK_HELPER_USER=""
+       CAMEL_LOCK_HELPER_GROUP=`ls -ld $system_mail_dir 2>&1 | awk '{print $4;}'`
+       system_mail_perm="writable by group $CAMEL_LOCK_HELPER_GROUP"
+       ;;
+
+drw???????)
+       CAMEL_LOCK_HELPER_USER=`ls -ld $system_mail_dir 2>&1 | awk '{print $3;}'`
+       CAMEL_LOCK_HELPER_GROUP=""
+       system_mail_perm="writable by user $CAMEL_LOCK_HELPER_USER"
+       ;;
+
+*)
+       CAMEL_LOCK_HELPER_USER=""
+       CAMEL_LOCK_HELPER_GROUP=""
+       system_mail_perm="???"
+       ;;
+esac
+
+AC_MSG_RESULT([$system_mail_dir, $system_mail_perm])
+AC_SUBST(CAMEL_LOCK_HELPER_USER)
+AC_SUBST(CAMEL_LOCK_HELPER_GROUP)
+
+
+dnl ***************
+dnl Timezone checks
+dnl ***************
+AC_CACHE_CHECK(for tm_gmtoff in struct tm, ac_cv_struct_tm_gmtoff,
+       AC_TRY_COMPILE([
+               #include <time.h>
+               ], [
+               struct tm tm;
+               tm.tm_gmtoff = 1;
+               ], ac_cv_struct_tm_gmtoff=yes, ac_cv_struct_tm_gmtoff=no))
+if test $ac_cv_struct_tm_gmtoff = yes; then
+       AC_DEFINE(HAVE_TM_GMTOFF, 1, [Define if struct tm has a tm_gmtoff member])
+else
+       AC_CACHE_CHECK(for timezone variable, ac_cv_var_timezone,
+               AC_TRY_COMPILE([
+                       #include <time.h>
+               ], [
+                       timezone = 1;
+               ], ac_cv_var_timezone=yes, ac_cv_var_timezone=no))
+       if test $ac_cv_var_timezone = yes; then
+               AC_DEFINE(HAVE_TIMEZONE, 1, [Define if libc defines a timezone variable])
+               AC_CACHE_CHECK(for altzone variable, ac_cv_var_altzone,
+                       AC_TRY_COMPILE([
+                               #include <time.h>
+                       ], [
+                               altzone = 1;
+                       ], ac_cv_var_altzone=yes, ac_cv_var_altzone=no))
+               if test $ac_cv_var_altzone = yes; then
+                       AC_DEFINE(HAVE_ALTZONE, 1, [Define if libc defines an altzone variable])
+               fi
+       else
+               AC_ERROR(unable to find a way to determine timezone)
+       fi
+fi
+
+
+AC_CHECK_FUNCS(mkstemp mkdtemp isblank)
+
+dnl **************************************************
+dnl ctime_r prototype
+dnl **************************************************
+
+AC_CACHE_CHECK([if ctime_r wants three arguments], ac_cv_ctime_r_three_args,
+[
+       AC_TRY_COMPILE([
+               #include <time.h>
+       ],[
+               char *buf;
+               time_t date;
+               ctime_r (&date, buf, 100);
+       ],[
+               ac_cv_ctime_r_three_args=yes
+       ],[
+               ac_cv_ctime_r_three_args=no
+       ])
+])
+       
+if test x"$ac_cv_ctime_r_three_args" = xyes ; then
+       AC_DEFINE(CTIME_R_THREE_ARGS, 1, [Solaris-style ctime_r])
+fi
+
+dnl **************************************************
+dnl gethostbyname_r prototype
+dnl **************************************************
+
+AC_CHECK_FUNCS(gethostbyname_r,[
+AC_CACHE_CHECK([if gethostbyname_r wants five arguments], ac_cv_gethostbyname_r_five_args,
+[
+       AC_TRY_COMPILE([
+               #include "confdefs.h"
+               #include <sys/types.h>
+               #include <sys/socket.h>
+               #include <netinet/in.h>
+               #include <netdb.h>
+
+               #define BUFSIZE (sizeof(struct hostent)+10)
+       ],[
+               struct hostent hent;
+               char buffer[BUFSIZE];
+               int bufsize=BUFSIZE;
+               int h_errno;
+
+               (void)gethostbyname_r ("www.ximian.com", &hent, buffer, bufsize, &h_errno);
+       ],[
+               ac_cv_gethostbyname_r_five_args=yes
+       ],[
+               ac_cv_gethostbyname_r_five_args=no
+       ])
+])])
+       
+if test "x$ac_cv_gethostbyname_r_five_args" = "xyes" ; then
+       AC_DEFINE(GETHOSTBYNAME_R_FIVE_ARGS, 1, [Solaris-style gethostbyname_r])
+fi
+
+dnl **************************************************
+dnl gethostbyaddr_r prototype
+dnl **************************************************
+
+AC_CHECK_FUNCS(gethostbyaddr_r,[
+AC_CACHE_CHECK([if gethostbyaddr_r wants seven arguments], ac_cv_gethostbyaddr_r_seven_args,
+[
+       AC_TRY_COMPILE([
+               #include "confdefs.h"
+               #include <sys/types.h>
+               #include <sys/socket.h>
+               #include <netinet/in.h>
+               #include <netdb.h>
+
+               #define BUFSIZE (sizeof(struct hostent)+10)
+       ],[
+               struct hostent hent;
+               char buffer[BUFSIZE];
+               int bufsize=BUFSIZE;
+               int h_errno;
+
+               (void)gethostbyaddr_r ("www.ximian.com", 14, AF_INET, &hent, buffer, bufsize, &h_errno);
+       ],[
+               ac_cv_gethostbyaddr_r_seven_args=yes
+       ],[
+               ac_cv_gethostbyaddr_r_seven_args=no
+       ])
+])])
+       
+if test "x$ac_cv_gethostbyaddr_r_seven_args" = "xyes" ; then
+       AC_DEFINE(GETHOSTBYADDR_R_SEVEN_ARGS, 1, [Solaris-style gethostbyaddr_r])
+fi
+
+dnl **************************************************
+dnl stat(v)fs location/type
+dnl **************************************************
+
+AC_CHECK_HEADERS(sys/statvfs.h)
+AC_CHECK_FUNCS(statvfs)
+AC_CHECK_HEADERS(sys/param.h)
+AC_CHECK_HEADERS(sys/mount.h)
+AC_CHECK_FUNCS(statfs)
+
+dnl **************************************************
+dnl * IPv6 support and getaddrinfo calls
+dnl **************************************************
+AC_CACHE_CHECK([if system supports getaddrinfo and getnameinfo], have_addrinfo,
+[
+       AC_TRY_COMPILE([
+               #include "confdefs.h"
+               #include <sys/types.h>
+               #include <sys/socket.h>
+               #include <netinet/in.h>
+               #include <netdb.h>
+
+       ],[
+               struct addrinfo hints, *res;
+               struct sockaddr_in6 sin6;
+               int af = AF_INET6;
+               char host[NI_MAXHOST];
+               char serv[NI_MAXSERV];
+
+               getaddrinfo ("www.ximian.com", NULL, &hints, &res);
+               freeaddrinfo (res);
+               getnameinfo((struct sockaddr *)&sin6, sizeof(sin6), host, sizeof(host), serv, sizeof(serv), 0);
+       ],[
+               have_addrinfo=yes
+       ],[
+               have_addrinfo=no
+       ])
+])
+
+if test x"$have_addrinfo" = "xno" ; then
+   AC_DEFINE(NEED_ADDRINFO,1,[Enable getaddrinfo emulation])
+   if test x"$enable_ipv6" = "xyes" ; then
+      AC_ERROR(system doesn't support necessary interfaces for ipv6 support)
+   fi
+   msg_ipv6=no
+else
+   AC_ARG_ENABLE(ipv6, [  --enable-ipv6=[no/yes]      Enable support for resolving IPv6 addresses.],,enable_ipv6=yes)
+   if test x"$enable_ipv6" = "xyes"; then
+        msg_ipv6=yes
+       AC_DEFINE(ENABLE_IPv6,1,[Enable IPv6 support])
+       AC_TRY_COMPILE([
+               #include "confdefs.h"
+               #include <sys/types.h>
+               #include <sys/socket.h>
+               #include <netinet/in.h>
+               #include <netdb.h>
+
+       ],[
+               struct addrinfo hints;
+               
+               hints.ai_flags = AI_ADDRCONFIG;
+       ],[
+               AC_DEFINE(HAVE_AI_ADDRCONFIG,1,[Define if the system defines the AI_ADDRCONFIG flag for getaddrinfo])
+       ])
+   else
+       msg_ipv6=no
+   fi
+fi
+
+AM_CONDITIONAL(ENABLE_IPv6, test "x$enable_ipv6" = "xyes")
+
+dnl **************************************************
+dnl NNTP support.
+dnl **************************************************
+AC_ARG_ENABLE(nntp, 
+[  --enable-nntp=[no/yes]      Build Usenet news (NNTP) backend],,enable_nntp=yes)
+if test "x$enable_nntp" = "xyes"; then
+       AC_DEFINE(ENABLE_NNTP,1,[Build NNTP backend])
+       msg_nntp=yes
+else
+       msg_nntp=no
+fi
+AM_CONDITIONAL(ENABLE_NNTP, test x$enable_nntp = xyes)
+
+dnl **************************************************
+dnl New IMAP code support.
+dnl **************************************************
+AC_ARG_ENABLE(imapp, 
+[  --enable-imapp=[no/yes]      Attempt to compile alternative, incomplete, very unsupported IMAPv4r1 code],,enable_imapp=no)
+if test "x$enable_imapp" = "xyes"; then
+       AC_DEFINE(ENABLE_IMAPP,1,[Really don't try this at home])
+       msg_imapp=yes
+else
+       msg_imapp=no
+fi
+AM_CONDITIONAL(ENABLE_IMAPP, test x$enable_imapp = xyes)
+
+dnl **************************************************
+dnl New IMAP code support.
+dnl **************************************************
+AC_ARG_ENABLE(imap4, 
+[  --enable-imap4=[no/yes]      Attempt to compile yet another, incomplete, very unsupported IMAPv4r1 implementation],,enable_imap4="yes")
+if test "x$enable_imap4" = "xyes"; then
+       AC_DEFINE(ENABLE_IMAP4,1,[Really don't try this at home])
+       msg_imap4=yes
+else
+       msg_imap4=no
+fi
+AM_CONDITIONAL(ENABLE_IMAP4, test x$enable_imap4 = xyes)
+
+dnl **************************************************
+dnl * Posix thread support
+dnl **************************************************
+
+dnl GLIB_CONFIG=${GLIB_CONFIG-glib-config}
+dnl GNOME_PTHREAD_CHECK
+
+dnl if test "x$PTHREAD_LIB" = "x" ; then
+dnl    AC_MSG_ERROR([POSIX threads are currently required for Evolution])
+dnl fi
+
+dnl
+dnl Notice that this is a hack, and we wont be able to use this forever, but
+dnl at least for some time
+dnl
+
+EVO_PTHREAD_CHECK
+
+THREADS_LIBS="$PTHREAD_LIB"
+THREADS_CFLAGS="$PTHREAD_CFLAGS"
+
+AC_SUBST(THREADS_LIBS)
+AC_SUBST(THREADS_CFLAGS)
+AC_DEFINE(ENABLE_THREADS,1,[Required])
+
+dnl **************************************************
+dnl * File locking
+dnl **************************************************
+
+AC_ARG_ENABLE(dot-locking, 
+[  --enable-dot-locking=[yes/no] Enable support for locking mail files with dot locking],,enable_dot_locking=yes)
+if test "x$enable_dot_locking" = "xyes"; then
+  AC_DEFINE(USE_DOT,1,[Define to use dot locking for mbox files])
+  msg_dot=yes
+else
+  msg_dot=no   
+fi
+
+AC_ARG_ENABLE(file-locking, 
+[  --enable-file-locking=[fcntl/flock/no] Enable support for locking mail files with file locking],,enable_file_locking=fcntl)
+if test "x$enable_file_locking" = "xfcntl"; then
+  AC_DEFINE(USE_FCNTL,1,[Define to use fcntl locking for mbox files])
+  msg_file=fcntl
+else
+  if test "x$enable_file_locking" = "xflock"; then
+    AC_DEFINE(USE_FLOCK,1,[Define to use flock locking for mbox files])
+    msg_file=flock
+  else
+    msg_file=no        
+  fi
+fi
+
+dnl **************************************************
+dnl * sendmail operation
+dnl **************************************************
+
+AC_MSG_CHECKING(for SunOS broken spool format)
+if test "x$host_os" = "xsunos" ; then
+   with_broken_spool="yes"
+fi
+
+AC_ARG_WITH(broken-spool, 
+[  --with-broken-spool=[yes/no] Using SunOS/Solaris sendmail which has a broken spool format],,with_broken_spool=${with_broken_spool:=no})
+
+if test "x$with_broken_spool" = "xyes"; then
+  AC_DEFINE(HAVE_BROKEN_SPOOL,1,[Define if mail delivered to the system mail directory is in broken Content-Length format])
+fi
+
+AC_MSG_RESULT($with_broken_spool)
+
+dnl ********
+dnl Kerberos
+dnl ********
+AC_ARG_WITH(krb5, [  --with-krb5=DIR      Location of Kerberos 5 install dir], with_krb5="$withval", with_krb5="no")
+AC_ARG_WITH(krb5-libs, [  --with-krb5-libs=DIR Location of Kerberos 5 libraries], with_krb5_libs="$withval", with_krb5_libs="$with_krb5/lib")
+AC_ARG_WITH(krb5-includes, [  --with-krb5-includes=DIR Location of Kerberos 5 headers], with_krb5_includes="$withval", with_krb5_includes="")
+AC_ARG_WITH(krb4, [  --with-krb4=DIR      Location of Kerberos 4 install dir], with_krb4="$withval", with_krb4="no")
+AC_ARG_WITH(krb4-libs, [  --with-krb4-libs=DIR Location of Kerberos 4 libraries], with_krb4_libs="$withval", with_krb4_libs="$with_krb4/lib")
+AC_ARG_WITH(krb4-includes, [  --with-krb4-includes=DIR Location of Kerberos 4 headers], with_krb4_includes="$withval", with_krb4_includes="")
+
+msg_krb5="no"
+if test "x${with_krb5}" != "xno"; then
+       LDFLAGS_save="$LDFLAGS"
+       
+       mitlibs="-lkrb5 -lk5crypto -lcom_err -lgssapi_krb5"
+       heimlibs="-lkrb5 -lcrypto -lasn1 -lcom_err -lroken -lgssapi"
+       AC_CACHE_CHECK([for Kerberos 5], ac_cv_lib_kerberos5,
+       [
+               LDFLAGS="$LDFLAGS -L$with_krb5_libs $mitlibs"
+               AC_TRY_LINK_FUNC(krb5_init_context, ac_cv_lib_kerberos5="$mitlibs",
+               [
+                       LDFLAGS="$LDFLAGS_save -L$with_krb5_libs $heimlibs"
+                       AC_TRY_LINK_FUNC(krb5_init_context, ac_cv_lib_kerberos5="$heimlibs", ac_cv_lib_kerberos5="no")
+               ])
+               LDFLAGS="$LDFLAGS_save"
+       ])
+       if test "$ac_cv_lib_kerberos5" != "no"; then
+               AC_DEFINE(HAVE_KRB5,1,[Define if you have Krb5])
+               if test "$ac_cv_lib_kerberos5" = "$mitlibs"; then
+                       AC_DEFINE(HAVE_MIT_KRB5,1,[Define if you have MIT Krb5])
+                       if test -z "$with_krb5_includes"; then
+                               KRB5_CFLAGS="-I$with_krb5/include"
+                       else
+                               KRB5_CFLAGS="-I$with_krb5_includes"
+                       fi
+                       msg_krb5="yes (MIT)"
+               else
+                       AC_DEFINE(HAVE_HEIMDAL_KRB5,1,[Define if you have Heimdal])
+                       if test -z "$with_krb5_includes"; then
+                               KRB5_CFLAGS="-I$with_krb5/include/heimdal"
+                       else
+                               KRB5_CFLAGS="-I$with_krb5_includes"
+                       fi
+                       msg_krb5="yes (Heimdal)"
+               fi
+               KRB5_LDFLAGS="-L$with_krb5_libs $ac_cv_lib_kerberos5"
+       fi
+else
+       AC_MSG_CHECKING(for Kerberos 5)
+       AC_MSG_RESULT($with_krb5)
+fi
+
+AC_CHECK_HEADER([et/com_err.h],[AC_DEFINE([HAVE_ET_COM_ERR_H], 1, [Have et/comm_err.h])])
+AC_CHECK_HEADER([com_err.h],[AC_DEFINE([HAVE_COM_ERR_H], 1, [Have comm_err.h])])
+
+msg_krb4="no"
+if test "x${with_krb4}" != "xno"; then
+       LDFLAGS_save="$LDFLAGS"
+       AC_CACHE_CHECK(for Kerberos 4, ac_cv_lib_kerberos4,
+       [
+               ac_cv_lib_kerberos4="no"
+
+               mitcompatlibs="-lkrb4 -ldes425 -lkrb5 -lk5crypto -lcom_err"
+               # Look for MIT krb5 compat krb4
+               LDFLAGS="$LDFLAGS -L$with_krb4_libs $mitcompatlibs"
+               AC_TRY_LINK_FUNC(krb_mk_req, ac_cv_lib_kerberos4="$mitcompatlibs")
+               
+               if test "$ac_cv_lib_kerberos4" = "no"; then
+                       # Look for KTH krb4
+                       LDFLAGS="$LDFLAGS_save -L$with_krb4_libs -lkrb -lcrypto -lcom_err -lroken"
+                       AC_TRY_LINK_FUNC(krb_mk_req, ac_cv_lib_kerberos4="-lkrb -lcrypto -lcom_err -lroken")
+               fi
+               if test "$ac_cv_lib_kerberos4" = "no"; then
+                       # Look for old MIT krb4
+                       LDFLAGS="$LDFLAGS_save -L$with_krb4_libs -lkrb"
+                       AC_TRY_LINK_FUNC(krb_mk_req, ac_cv_lib_kerberos4="-lkrb",
+                       [
+                               LDFLAGS="$LDFLAGS -ldes"
+                               AC_TRY_LINK_FUNC(krb_mk_req, ac_cv_lib_kerberos4="-lkrb -ldes")
+                       ])
+               fi
+       ])
+       LDFLAGS="$LDFLAGS_save"
+       if test "$ac_cv_lib_kerberos4" != "no"; then
+               AC_DEFINE(HAVE_KRB4,1,[Define if you have Krb4])
+               msg_krb4="yes"
+
+               if test -z "$with_krb4_includes"; then
+                       if test -f "$with_krb4/include/krb.h" -o -f "$with_krb4/include/port-sockets.h"; then
+                               KRB4_CFLAGS="-I$with_krb4/include"
+                       fi
+                       if test -d "$with_krb4/include/kerberosIV"; then
+                               KRB4_CFLAGS="$KRB4_CFLAGS -I$with_krb4/include/kerberosIV"
+                       fi
+               else
+                       KRB4_CFLAGS="-I$with_krb4_includes"
+               fi
+               KRB4_LDFLAGS="-L$with_krb4_libs $ac_cv_lib_kerberos4"
+               
+               CFLAGS_save="$CFLAGS"
+               CFLAGS="$CFLAGS $KRB4_CFLAGS"
+               AC_TRY_COMPILE([#include "krb.h"
+               int krb_sendauth;
+               ],[return 0],[AC_DEFINE(NEED_KRB_SENDAUTH_PROTO,1,[Need krb_sendauth proto])],)
+               CFLAGS="$CFLAGS_save"
+       fi
+else
+       AC_MSG_CHECKING(for Kerberos 4)
+       AC_MSG_RESULT(${with_krb4})
+fi
+
+AC_SUBST(KRB5_CFLAGS)
+AC_SUBST(KRB5_LDFLAGS)
+AC_SUBST(KRB4_CFLAGS)
+AC_SUBST(KRB4_LDFLAGS)
+
 dnl Initialize libtool
 AM_DISABLE_STATIC
 AM_PROG_LIBTOOL
@@ -214,7 +1068,7 @@ dnl --- libedataserver and libedataserverui flags
 
 E_DATA_SERVER_DEPS="libxml-2.0 libbonobo-2.0 >= $LIBBONOBO_REQUIRED libgnome-2.0"
 
-EVO_SET_COMPILE_FLAGS(E_DATA_SERVER, $E_DATA_SERVER_DEPS, $THREADS_CFLAGS, $THREADS_LIBS)
+EVO_SET_COMPILE_FLAGS(E_DATA_SERVER, $E_DATA_SERVER_DEPS, $THREADS_CFLAGS $MANUAL_NSPR_CFLAGS, $THREADS_LIBS $MANUAL_NSPR_LIBS)
 AC_SUBST(E_DATA_SERVER_CFLAGS)
 AC_SUBST(E_DATA_SERVER_LIBS)
 
@@ -247,6 +1101,15 @@ EVO_SET_COMPILE_FLAGS(SOUP, libsoup-2.2 >= $LIBSOUP_REQUIRED)
 AC_SUBST(SOUP_CFLAGS)
 AC_SUBST(SOUP_LIBS)
 
+dnl --- Camel flags
+EVO_SET_COMPILE_FLAGS(CAMEL, glib-2.0 gthread-2.0 $mozilla_nss,
+                     $THREADS_CFLAGS $KRB4_CFLAGS $KRB5_CFLAGS $MANUAL_NSS_CFLAGS,
+                     $THREADS_LIBS $KRB4_LDFLAGS $KRB5_LDFLAGS $MANUAL_NSS_LIBS)
+AC_SUBST(CAMEL_CFLAGS)
+AC_SUBST(CAMEL_LIBS)
+AC_SUBST(CAMEL_GROUPWISE_CFLAGS)
+AC_SUBST(CAMEL_GROUPWISE_LIBS)
+
 dnl *******************
 dnl Special directories
 dnl *******************
@@ -273,6 +1136,10 @@ AC_SUBST(serverdir)
 extensiondir='${privlibdir}'/extensions
 AC_SUBST(extensiondir)
 
+dnl separate camel from e-d-s?  or should it be under the same spot?  same for now.
+camel_providerdir="${privlibdir}/camel-providers"
+AC_SUBST(camel_providerdir)
+
 dnl ************************
 dnl IDL/Component Versioning
 dnl ************************
@@ -337,6 +1204,27 @@ calendar/backends/http/Makefile
 calendar/backends/contacts/Makefile
 calendar/tests/Makefile
 calendar/tests/ecal/Makefile
+camel/Makefile
+camel/providers/Makefile
+camel/providers/groupwise/Makefile
+camel/providers/imap/Makefile
+camel/providers/imapp/Makefile
+camel/providers/imap4/Makefile
+camel/providers/local/Makefile
+camel/providers/nntp/Makefile
+camel/providers/pop3/Makefile
+camel/providers/sendmail/Makefile
+camel/providers/smtp/Makefile
+camel/tests/Makefile
+camel/tests/folder/Makefile
+camel/tests/lib/Makefile
+camel/tests/message/Makefile
+camel/tests/mime-filter/Makefile
+camel/tests/misc/Makefile
+camel/tests/smime/Makefile
+camel/tests/stream/Makefile
+camel/camel.pc
+camel/camel-provider.pc
 libdb/Makefile
 libedataserver/Makefile
 libedataserver/libedataserver.pc
diff --git a/iconv-detect.c b/iconv-detect.c
new file mode 100644 (file)
index 0000000..9cd2fd3
--- /dev/null
@@ -0,0 +1,185 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ *  Authors: Jeffrey Stedfast <fejj@ximian.com>
+ *
+ *  Copyright 2002 Ximian, Inc. (www.ximian.com)
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA.
+ *
+ */
+
+#include <stdio.h>
+#include <iconv.h>
+
+enum {
+       ISO_UNSUPPORTED          = 0,
+       
+       /* iso-8859-1 */
+       ISO_DASH_D_DASH_D_LOWER  = (1 << 0),
+       ISO_DASH_D_DASH_D        = (1 << 1),
+       ISO_D_DASH_D             = (1 << 2),
+       ISO_D_D                  = (1 << 3),
+       ISO_UNDER_D_DASH_D       = (1 << 4),
+       NO_ISO_D_DASH_D          = (1 << 5),
+       
+       /* iso-10646-1 */
+       /*ISO_DASH_D_DASH_D_LOWER  = (1 << 0),*/
+       /*ISO_DASH_D_DASH_D        = (1 << 1),*/
+       /*ISO_D_DASH_D             = (1 << 2),*/
+       ISO_DASH_D_LOWER           = (1 << 3),
+       ISO_DASH_D                 = (1 << 4),
+       ISO_D                      = (1 << 5),
+       UCS4                       = (1 << 6),
+       
+       /* iso-2022-jp */
+       ISO_DASH_D_DASH_S_LOWER  = (1 << 0),
+       ISO_DASH_D_DASH_S        = (1 << 1),
+       ISO_D_DASH_S             = (1 << 2),
+};
+
+
+typedef struct {
+       char *charset;
+       char *format;
+       int id;
+} CharInfo;
+
+
+static CharInfo iso8859_tests[] = {
+       { "iso-8859-1",  "iso-%d-%d", ISO_DASH_D_DASH_D_LOWER },
+       { "ISO-8859-1",  "ISO-%d-%d", ISO_DASH_D_DASH_D },
+       { "ISO8859-1",   "ISO%d-%d",  ISO_D_DASH_D },
+       { "ISO88591",    "ISO%d%d",   ISO_D_D },
+       { "ISO_8859-1",  "ISO_%d-%d", ISO_UNDER_D_DASH_D },
+       { "8859-1",      "%d-%d",     NO_ISO_D_DASH_D },
+};
+
+static int num_iso8859_tests = sizeof (iso8859_tests) / sizeof (CharInfo);
+
+static CharInfo iso2022_tests[] = {
+       { "iso-2022-jp", "iso-%d-%s", ISO_DASH_D_DASH_S_LOWER },
+       { "ISO-2022-JP", "ISO-%d-%s", ISO_DASH_D_DASH_S },
+       { "ISO2022-JP",  "ISO%d-%s",  ISO_D_DASH_S },
+};
+
+static int num_iso2022_tests = sizeof (iso2022_tests) / sizeof (CharInfo);
+
+static CharInfo iso10646_tests[] = {
+       { "iso-10646-1", "iso-%d-%d",  ISO_DASH_D_DASH_D_LOWER },
+       { "ISO-10646-1", "ISO-%d-%d",  ISO_DASH_D_DASH_D },
+       { "ISO10646-1",  "ISO%d-%d",   ISO_D_DASH_D },
+       { "iso-10646",   "iso-%d",     ISO_DASH_D_LOWER },
+       { "ISO-10646",   "ISO-%d",     ISO_DASH_D },
+       { "ISO10646",    "ISO%d",      ISO_D },
+       { "UCS-4BE",     "UCS-4BE",    UCS4 },
+};
+
+static int num_iso10646_tests = sizeof (iso10646_tests) / sizeof (CharInfo);
+
+
+int main (int argc, char **argv)
+{
+       unsigned int bits, iso8859, iso2022, iso10646;
+       CharInfo *info;
+       iconv_t cd;
+       FILE *fp;
+       int i;
+       
+       fp = fopen ("iconv-detect.h", "w");
+       if (fp == NULL)
+               exit (255);
+       
+       fprintf (fp, "/* This is an auto-generated header, DO NOT EDIT! */\n\n");
+       
+       iso8859 = ISO_UNSUPPORTED;
+       info = iso8859_tests;
+       /*printf ("#define DEFAULT_ISO_FORMAT(iso,codepage)\t");*/
+       for (i = 0; i < num_iso8859_tests; i++) {
+               cd = iconv_open (info[i].charset, "UTF-8");
+               if (cd != (iconv_t) -1) {
+                       iconv_close (cd);
+                       /*printf ("(\"%s\", (iso), (codepage))\n", info[i].format);*/
+                       fprintf (stderr, "System prefers %s\n", info[i].charset);
+                       iso8859 = info[i].id;
+                       break;
+               }
+       }
+       
+       if (iso8859 == ISO_UNSUPPORTED) {
+               fprintf (stderr, "System doesn't support any ISO-8859-1 formats\n");
+               fprintf (fp, "#define ICONV_ISO_D_FORMAT \"%s\"\n", info[0].format);
+#ifdef CONFIGURE_IN
+               exit (1);
+#endif
+       } else {
+               fprintf (fp, "#define ICONV_ISO_D_FORMAT \"%s\"\n", info[i].format);
+       }
+       
+       iso2022 = ISO_UNSUPPORTED;
+       info = iso2022_tests;
+       /*printf ("#define ISO_2022_FORMAT(iso,codepage)\t");*/
+       for (i = 0; i < num_iso2022_tests; i++) {
+               cd = iconv_open (info[i].charset, "UTF-8");
+               if (cd != (iconv_t) -1) {
+                       iconv_close (cd);
+                       /*printf ("(\"%s\", (iso), (codepage))\n", info[i].format);*/
+                       fprintf (stderr, "System prefers %s\n", info[i].charset);
+                       iso2022 = info[i].id;
+                       break;
+               }
+       }
+       
+       if (iso2022 == ISO_UNSUPPORTED) {
+               fprintf (stderr, "System doesn't support any ISO-2022 formats\n");
+               fprintf (fp, "#define ICONV_ISO_S_FORMAT \"%s\"\n", info[0].format);
+#ifdef CONFIGURE_IN
+               exit (3);
+#endif
+       } else {
+               fprintf (fp, "#define ICONV_ISO_S_FORMAT \"%s\"\n", info[i].format);
+       }
+       
+       iso10646 = ISO_UNSUPPORTED;
+       info = iso10646_tests;
+       /*printf ("#define ISO_10646_FORMAT(iso,codepage)\t");*/
+       for (i = 0; i < num_iso10646_tests; i++) {
+               cd = iconv_open (info[i].charset, "UTF-8");
+               if (cd != (iconv_t) -1) {
+                       iconv_close (cd);
+                       /*if (info[i].id < ISO_DASH_D_LOWER)
+                               printf ("(\"%s\", (iso), (codepage))\n", info[i].format);
+                       else
+                       printf ("(\"%s\", (iso))\n", info[i].format);*/
+                       fprintf (stderr, "System prefers %s\n", info[i].charset);
+                       iso10646 = info[i].id;
+                       break;
+               }
+       }
+       
+       /* we don't need a printf format for iso-10646 because there is only 1 */
+       if (iso10646 == ISO_UNSUPPORTED) {
+               fprintf (stderr, "System doesn't support any ISO-10646-1 formats\n");
+               fprintf (fp, "#define ICONV_10646 \"%s\"\n", info[0].charset);
+#ifdef CONFIGURE_IN
+               exit (2);
+#endif
+       } else {
+               fprintf (fp, "#define ICONV_10646 \"%s\"\n", info[i].charset);
+       }
+       
+       fclose (fp);
+       
+       exit (0);
+}