4 dnl From codeset.m4 (in libcharset):
9 AC_DEFUN(jm_LANGINFO_CODESET,
11 AC_CHECK_HEADERS(langinfo.h)
12 AC_CHECK_FUNCS(nl_langinfo)
14 AC_CACHE_CHECK([for nl_langinfo and CODESET], jm_cv_langinfo_codeset,
15 [AC_TRY_LINK([#include <langinfo.h>],
16 [char* cs = nl_langinfo(CODESET);],
17 jm_cv_langinfo_codeset=yes,
18 jm_cv_langinfo_codeset=no)
20 if test $jm_cv_langinfo_codeset = yes; then
21 AC_DEFINE(HAVE_LANGINFO_CODESET, 1,
22 [Define if you have <langinfo.h> and nl_langinfo(CODESET).])
26 dnl From glibc21.m4 (in libcharset):
29 # Test for the GNU C Library, version 2.1 or newer.
34 AC_CACHE_CHECK(whether we are using the GNU C Library 2.1 or newer,
35 ac_cv_gnu_library_2_1,
36 [AC_EGREP_CPP([Lucky GNU user],
39 #ifdef __GNU_LIBRARY__
40 #if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) || (__GLIBC__ > 2)
45 ac_cv_gnu_library_2_1=yes,
46 ac_cv_gnu_library_2_1=no)
50 GLIBC21="$ac_cv_gnu_library_2_1"
55 dnl gedcom_GLIBC_ICONV()
56 dnl Checks whether iconv is coming from glibc, defines USE_GLIBC_ICONV if so
57 dnl The variable $is_glibc_iconv contains yes or no
58 AC_DEFUN(gedcom_GLIBC22_ICONV, [
59 AC_CACHE_CHECK(for the GNU C Library 2.2 iconv implementation, is_glibc22_iconv, [
64 #if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2) || (__GLIBC__ > 2)
68 ], is_glibc22_iconv=yes, is_glibc22_iconv=no)
70 if test "$is_glibc22_iconv" = yes; then
71 AC_DEFINE(USE_GLIBC_ICONV,1,
72 [Define if the GNU implementation of iconv in glibc is used])
76 dnl gedcom_ICONV_HAS_CONV()
77 dnl Checks whether iconv has support to convert $1 to $2
78 dnl The variable $iconv_has_conv contains yes or no afterwards
79 dnl (overwritten on subsequent calls)
80 AC_DEFUN(gedcom_ICONV_HAS_CONV, [
82 LIBS="$LIBS $LIBICONV"
86 iconv_t cd = iconv_open("$2","$1");
87 return (cd == (iconv_t)-1);
97 dnl gedcom_SANE_ICONV()
98 dnl Checks whether the iconv implementation has the basic functionality
100 dnl The variable $is_iconv_sane contains yes or no
101 AC_DEFUN(gedcom_SANE_ICONV, [
102 AC_CACHE_CHECK(whether iconv has the needed functionality, is_iconv_sane, [
104 gedcom_ICONV_HAS_CONV(ASCII, UTF-8)
105 if test "$iconv_has_conv" = "no"; then
108 gedcom_ICONV_HAS_CONV(UCS-2LE, UTF-8)
109 if test "$iconv_has_conv" = "no"; then
112 gedcom_ICONV_HAS_CONV(UCS-2BE, UTF-8)
113 if test "$iconv_has_conv" = "no"; then
121 dnl gedcom_LIBICONV_HAS_ANSEL()
122 dnl Checks whether libiconv has ANSEL support
123 dnl The variable $is_ansel_supported contains yes or no
124 AC_DEFUN(gedcom_LIBICONV_HAS_ANSEL, [
125 AC_CACHE_CHECK(for ANSEL support in libiconv, is_ansel_supported, [
126 is_ansel_supported=no
127 gedcom_ICONV_HAS_CONV(ANSEL, UTF-8)
128 if test "$iconv_has_conv" = yes; then
129 is_ansel_supported=yes
134 dnl gedcom_SYS_NEWLINE()
135 dnl Checks how newline is written on the system
136 dnl SYS_NEWLINE is set to one of the following:
137 dnl END_CR, END_LF, END_CR_LF, END_LF_CR
138 AC_DEFUN(gedcom_SYS_NEWLINE, [
139 AC_CACHE_CHECK(how to represent newline, ac_cv_system_newline, [
142 #include <sys/types.h>
143 #include <sys/stat.h>
150 for (i=0; i<10; i++) { buffer[i] = '\0'; }
151 fd = open("newlinetest", O_RDONLY);
152 if (fd == -1) return 1;
153 read(fd, buffer, 10);
155 f = fopen("newlinetest", "w");
158 while (buffer[i] != '\0') { fprintf(f, "%02x", buffer[i++]); }
163 [system_newline_output=`cat newlinetest`
164 case "$system_newline_output" in
165 0a0d) ac_cv_system_newline="\"\x0A\x0D\"" ;;
166 0d0a) ac_cv_system_newline="\"\x0D\x0A\"" ;;
167 0a) ac_cv_system_newline="\"\x0A\"" ;;
168 0d) ac_cv_system_newline="\"\x0D\"" ;;
169 *) ac_cv_system_newline="\"\x0A\"" ;;
171 ac_cv_system_newline="\"\x0A\"",
172 ac_cv_system_newline="\"\x0A\"")
175 AC_DEFINE_UNQUOTED(SYS_NEWLINE,$ac_cv_system_newline,
176 [The representation of newline in text files in the system])