5 dnl gedcom_GLIBC_ICONV()
6 dnl Checks whether iconv is coming from glibc, defines USE_GLIBC_ICONV if so
7 dnl The variable $is_glibc_iconv contains yes or no
8 AC_DEFUN(gedcom_GLIBC22_ICONV, [
9 AC_CACHE_CHECK(for the GNU C Library 2.2 iconv implementation, is_glibc22_iconv, [
14 #if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2) || (__GLIBC__ > 2)
18 ], is_glibc22_iconv=yes, is_glibc22_iconv=no)
20 if test "$is_glibc22_iconv" = yes; then
21 AC_DEFINE(USE_GLIBC_ICONV,1,
22 [Define if the GNU implementation of iconv in glibc is used])
26 dnl gedcom_ICONV_HAS_CONV()
27 dnl Checks whether iconv has support to convert $1 to $2
28 dnl The variable $iconv_has_conv contains yes or no afterwards
29 dnl (overwritten on subsequent calls)
30 AC_DEFUN(gedcom_ICONV_HAS_CONV, [
32 LIBS="$LIBS $LIBICONV"
36 iconv_t cd = iconv_open("$2","$1");
37 return (cd == (iconv_t)-1);
47 dnl gedcom_SANE_ICONV()
48 dnl Checks whether the iconv implementation has the basic functionality
50 dnl The variable $is_iconv_sane contains yes or no
51 AC_DEFUN(gedcom_SANE_ICONV, [
52 AC_CACHE_CHECK(whether iconv has the needed functionality, is_iconv_sane, [
54 gedcom_ICONV_HAS_CONV(ASCII, UTF-8)
55 if test "$iconv_has_conv" = "no"; then
58 gedcom_ICONV_HAS_CONV(UCS-2LE, UTF-8)
59 if test "$iconv_has_conv" = "no"; then
62 gedcom_ICONV_HAS_CONV(UCS-2BE, UTF-8)
63 if test "$iconv_has_conv" = "no"; then
71 dnl gedcom_LIBICONV_HAS_ANSEL()
72 dnl Checks whether libiconv has ANSEL support
73 dnl The variable $is_ansel_supported contains yes or no
74 AC_DEFUN(gedcom_LIBICONV_HAS_ANSEL, [
75 AC_CACHE_CHECK(for ANSEL support in libiconv, is_ansel_supported, [
77 gedcom_ICONV_HAS_CONV(ANSEL, UTF-8)
78 if test "$iconv_has_conv" = yes; then
79 is_ansel_supported=yes
84 dnl gedcom_SYS_NEWLINE()
85 dnl Checks how newline is written on the system
86 dnl SYS_NEWLINE is set to one of the following:
87 dnl END_CR, END_LF, END_CR_LF, END_LF_CR
88 AC_DEFUN(gedcom_SYS_NEWLINE, [
89 AC_CACHE_CHECK(how to represent newline, ac_cv_system_newline, [
92 #include <sys/types.h>
100 for (i=0; i<10; i++) { buffer[i] = '\0'; }
101 fd = open("newlinetest", O_RDONLY);
102 if (fd == -1) return 1;
103 read(fd, buffer, 10);
105 f = fopen("newlinetest", "w");
108 while (buffer[i] != '\0') { fprintf(f, "%02x", buffer[i++]); }
113 [system_newline_output=`cat newlinetest`
114 case "$system_newline_output" in
115 0a0d) ac_cv_system_newline="\"\x0A\x0D\"" ;;
116 0d0a) ac_cv_system_newline="\"\x0D\x0A\"" ;;
117 0a) ac_cv_system_newline="\"\x0A\"" ;;
118 0d) ac_cv_system_newline="\"\x0D\"" ;;
119 *) ac_cv_system_newline="\"\x0A\"" ;;
121 ac_cv_system_newline="\"\x0A\"",
122 ac_cv_system_newline="\"\x0A\"")
125 AC_DEFINE_UNQUOTED(SYS_NEWLINE,$ac_cv_system_newline,
126 [The representation of newline in text files in the system])