From: Peter Verthez Date: Sun, 27 Oct 2002 15:55:09 +0000 (+0000) Subject: Generalize search for iconv conversions, check whether iconv has the needed X-Git-Url: https://git.dlugolecki.net.pl/?a=commitdiff_plain;h=cc8b71592f11d870625d87458fe1afd597d48f78;p=gedcom-parse.git Generalize search for iconv conversions, check whether iconv has the needed features. --- diff --git a/acinclude.m4 b/acinclude.m4 index 9edd0bc..ac07948 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -73,23 +73,60 @@ yes fi ]) -dnl gedcom_LIBICONV_HAS_ANSEL() -dnl Checks whether libiconv has ANSEL support -dnl The variable $is_ansel_supported contains yes or no -AC_DEFUN(gedcom_LIBICONV_HAS_ANSEL, [ - AC_CACHE_CHECK(for ANSEL support in libiconv, is_ansel_supported, [ - my_save_LIBS="$LIBS" - LIBS="$LIBS $LIBICONV" - AC_TRY_RUN([ +dnl gedcom_ICONV_HAS_CONV() +dnl Checks whether iconv has support to convert $1 to $2 +dnl The variable $iconv_has_conv contains yes or no afterwards +dnl (overwritten on subsequent calls) +AC_DEFUN(gedcom_ICONV_HAS_CONV, [ + my_save_LIBS="$LIBS" + LIBS="$LIBS $LIBICONV" + AC_TRY_RUN([ #include int main() { - iconv_t cd = iconv_open("UTF-8","ANSEL"); + iconv_t cd = iconv_open("$2","$1"); return (cd == (iconv_t)-1); } ], - is_ansel_supported=yes, - is_ansel_supported=no, - is_ansel_supported=no) + iconv_has_conv=yes, + iconv_has_conv=no, + iconv_has_conv=no) LIBS="$my_save_LIBS" ]) ]) + +dnl gedcom_SANE_ICONV() +dnl Checks whether the iconv implementation has the basic functionality +dnl that we need +dnl The variable $is_iconv_sane contains yes or no +AC_DEFUN(gedcom_SANE_ICONV, [ + AC_CACHE_CHECK(whether iconv has the needed functionality, is_iconv_sane, [ + is_iconv_sane=yes + gedcom_ICONV_HAS_CONV(ASCII, UTF-8) + if test "$iconv_has_conv" = "no"; then + is_iconv_sane=no + else + gedcom_ICONV_HAS_CONV(UCS-2LE, UTF-8) + if test "$iconv_has_conv" = "no"; then + is_iconv_sane=no + else + gedcom_ICONV_HAS_CONV(UCS-2BE, UTF-8) + if test "$iconv_has_conv" = "no"; then + is_iconv_sane=no + fi + fi + fi + ]) +]) + +dnl gedcom_LIBICONV_HAS_ANSEL() +dnl Checks whether libiconv has ANSEL support +dnl The variable $is_ansel_supported contains yes or no +AC_DEFUN(gedcom_LIBICONV_HAS_ANSEL, [ + AC_CACHE_CHECK(for ANSEL support in libiconv, is_ansel_supported, [ + is_ansel_supported=no + gedcom_ICONV_HAS_CONV(ANSEL, UTF-8) + if test "$iconv_has_conv" = yes; then + is_ansel_supported=yes + fi + ]) +])