| | | | |
| Offset 0, 0 lines modified | Offset 1, 293 lines modified |
| | 1 | #·iconv.m4·serial·26 |
| | 2 | dnl·Copyright·(C)·2000-2002,·2007-2014,·2016-2023·Free·Software·Foundation, |
| | 3 | dnl·Inc. |
| | 4 | dnl·This·file·is·free·software;·the·Free·Software·Foundation |
| | 5 | dnl·gives·unlimited·permission·to·copy·and/or·distribute·it, |
| | 6 | dnl·with·or·without·modifications,·as·long·as·this·notice·is·preserved. |
| | |
| | 7 | dnl·From·Bruno·Haible. |
| | |
| | 8 | AC_PREREQ([2.64]) |
| | |
| | 9 | dnl·Note:·AM_ICONV·is·documented·in·the·GNU·gettext·manual |
| | 10 | dnl·<https://www.gnu.org/software/gettext/manual/html_node/AM_005fICONV.html>. |
| | 11 | dnl·Don't·make·changes·that·are·incompatible·with·that·documentation! |
| | |
| | 12 | AC_DEFUN([AM_ICONV_LINKFLAGS_BODY], |
| | 13 | [ |
| | 14 | ··dnl·Prerequisites·of·AC_LIB_LINKFLAGS_BODY. |
| | 15 | ··AC_REQUIRE([AC_LIB_PREPARE_PREFIX]) |
| | 16 | ··AC_REQUIRE([AC_LIB_RPATH]) |
| | |
| | 17 | ··dnl·Search·for·libiconv·and·define·LIBICONV,·LTLIBICONV·and·INCICONV |
| | 18 | ··dnl·accordingly. |
| | 19 | ··AC_LIB_LINKFLAGS_BODY([iconv]) |
| | 20 | ]) |
| | |
| | 21 | AC_DEFUN([AM_ICONV_LINK], |
| | 22 | [ |
| | 23 | ··dnl·Some·systems·have·iconv·in·libc,·some·have·it·in·libiconv·(OSF/1·and |
| | 24 | ··dnl·those·with·the·standalone·portable·GNU·libiconv·installed). |
| | 25 | ··AC_REQUIRE([AC_CANONICAL_HOST])·dnl·for·cross-compiles |
| | |
| | 26 | ··dnl·Search·for·libiconv·and·define·LIBICONV,·LTLIBICONV·and·INCICONV |
| | 27 | ··dnl·accordingly. |
| | 28 | ··AC_REQUIRE([AM_ICONV_LINKFLAGS_BODY]) |
| | |
| | 29 | ··dnl·Add·$INCICONV·to·CPPFLAGS·before·performing·the·following·checks, |
| | 30 | ··dnl·because·if·the·user·has·installed·libiconv·and·not·disabled·its·use |
| | 31 | ··dnl·via·--without-libiconv-prefix,·he·wants·to·use·it.·The·first |
| | 32 | ··dnl·AC_LINK_IFELSE·will·then·fail,·the·second·AC_LINK_IFELSE·will·succeed. |
| | 33 | ··am_save_CPPFLAGS="$CPPFLAGS" |
| | 34 | ··AC_LIB_APPENDTOVAR([CPPFLAGS],·[$INCICONV]) |
| | |
| | 35 | ··AC_CACHE_CHECK([for·iconv],·[am_cv_func_iconv],·[ |
| | 36 | ····am_cv_func_iconv="no,·consider·installing·GNU·libiconv" |
| | 37 | ····am_cv_lib_iconv=no |
| | 38 | ····AC_LINK_IFELSE( |
| | 39 | ······[AC_LANG_PROGRAM( |
| | 40 | ·········[[ |
| | 41 | #include·<stdlib.h> |
| | 42 | #include·<iconv.h> |
| | 43 | ·········]], |
| | 44 | ·········[[iconv_t·cd·=·iconv_open("",""); |
| | 45 | ···········iconv(cd,NULL,NULL,NULL,NULL); |
| | 46 | ···········iconv_close(cd);]])], |
| | 47 | ······[am_cv_func_iconv=yes]) |
| | 48 | ····if·test·"$am_cv_func_iconv"·!=·yes;·then |
| | 49 | ······am_save_LIBS="$LIBS" |
| | 50 | ······LIBS="$LIBS·$LIBICONV" |
| | 51 | ······AC_LINK_IFELSE( |
| | 52 | ········[AC_LANG_PROGRAM( |
| | 53 | ···········[[ |
| | 54 | #include·<stdlib.h> |
| | 55 | #include·<iconv.h> |
| | 56 | ···········]], |
| | 57 | ···········[[iconv_t·cd·=·iconv_open("",""); |
| | 58 | ·············iconv(cd,NULL,NULL,NULL,NULL); |
| | 59 | ·············iconv_close(cd);]])], |
| | 60 | ········[am_cv_lib_iconv=yes] |
| | 61 | ········[am_cv_func_iconv=yes]) |
| | 62 | ······LIBS="$am_save_LIBS" |
| | 63 | ····fi |
| | 64 | ··]) |
| | 65 | ··if·test·"$am_cv_func_iconv"·=·yes;·then |
| | 66 | ····AC_CACHE_CHECK([for·working·iconv],·[am_cv_func_iconv_works],·[ |
| | 67 | ······dnl·This·tests·against·bugs·in·AIX·5.1,·AIX·6.1..7.1,·HP-UX·11.11, |
| | 68 | ······dnl·Solaris·10. |
| | 69 | ······am_save_LIBS="$LIBS" |
| | 70 | ······if·test·$am_cv_lib_iconv·=·yes;·then |
| | 71 | ········LIBS="$LIBS·$LIBICONV" |
| | 72 | ······fi |
| | 73 | ······am_cv_func_iconv_works=no |
| | 74 | ······for·ac_iconv_const·in·''·'const';·do |
| | 75 | ········AC_RUN_IFELSE( |
| | 76 | ··········[AC_LANG_PROGRAM( |
| | 77 | ·············[[ |
| | 78 | #include·<iconv.h> |
| | 79 | #include·<string.h> |
| | |
| | 80 | #ifndef·ICONV_CONST |
| | 81 | #·define·ICONV_CONST·$ac_iconv_const |
| | 82 | #endif |
| | 83 | ·············]], |
| | 84 | ·············[[int·result·=·0; |
| | 85 | ··/*·Test·against·AIX·5.1...7.2·bug:·Failures·are·not·distinguishable·from |
| | 86 | ·····successful·returns.··This·is·even·documented·in |
| | 87 | ·····<https://www.ibm.com/support/knowledgecenter/ssw_aix_72/i_bostechref/iconv.html>·*/ |
| | 88 | ··{ |
| | 89 | ····iconv_t·cd_utf8_to_88591·=·iconv_open·("ISO8859-1",·"UTF-8"); |
| | 90 | ····if·(cd_utf8_to_88591·!=·(iconv_t)(-1)) |
| | 91 | ······{ |
| | 92 | ········static·ICONV_CONST·char·input[]·=·"\342\202\254";·/*·EURO·SIGN·*/ |
| | 93 | ········char·buf[10]; |
| | 94 | ········ICONV_CONST·char·*inptr·=·input; |
| | 95 | ········size_t·inbytesleft·=·strlen·(input); |
| | 96 | ········char·*outptr·=·buf; |
| | 97 | ········size_t·outbytesleft·=·sizeof·(buf); |
| | 98 | ········size_t·res·=·iconv·(cd_utf8_to_88591, |
| | 99 | ····························&inptr,·&inbytesleft, |
| | 100 | ····························&outptr,·&outbytesleft); |
| | 101 | ········if·(res·==·0) |
| | 102 | ··········result·|=·1; |
| | 103 | ········iconv_close·(cd_utf8_to_88591); |
| | 104 | ······} |
| | 105 | ··} |
| | 106 | ··/*·Test·against·Solaris·10·bug:·Failures·are·not·distinguishable·from |
| | 107 | ·····successful·returns.··*/ |
| | 108 | ··{ |
| | 109 | ····iconv_t·cd_ascii_to_88591·=·iconv_open·("ISO8859-1",·"646"); |
| | 110 | ····if·(cd_ascii_to_88591·!=·(iconv_t)(-1)) |
| | 111 | ······{ |
| | 112 | ········static·ICONV_CONST·char·input[]·=·"\263"; |
| | 113 | ········char·buf[10]; |
| | 114 | ········ICONV_CONST·char·*inptr·=·input; |
| | 115 | ········size_t·inbytesleft·=·strlen·(input); |
| | 116 | ········char·*outptr·=·buf; |
| | 117 | ········size_t·outbytesleft·=·sizeof·(buf); |
| | 118 | ········size_t·res·=·iconv·(cd_ascii_to_88591, |
| | 119 | ····························&inptr,·&inbytesleft, |
| | 120 | ····························&outptr,·&outbytesleft); |
| | 121 | ········if·(res·==·0) |
| | 122 | ··········result·|=·2; |
| | 123 | ········iconv_close·(cd_ascii_to_88591); |
| | 124 | ······} |
| | 125 | ··} |
| | 126 | ··/*·Test·against·AIX·6.1..7.1·bug:·Buffer·overrun.··*/ |
| | 127 | ··{ |
| | 128 | ····iconv_t·cd_88591_to_utf8·=·iconv_open·("UTF-8",·"ISO-8859-1"); |
| | 129 | ····if·(cd_88591_to_utf8·!=·(iconv_t)(-1)) |
| | 130 | ······{ |
| | 131 | ········static·ICONV_CONST·char·input[]·=·"\304"; |
| | 132 | ········static·char·buf[2]·=·{·(char)0xDE,·(char)0xAD·}; |
| | 133 | ········ICONV_CONST·char·*inptr·=·input; |
| | 134 | ········size_t·inbytesleft·=·1; |
| | 135 | ········char·*outptr·=·buf; |
| | 136 | ········size_t·outbytesleft·=·1; |
| | 137 | ········size_t·res·=·iconv·(cd_88591_to_utf8, |
| | 138 | ····························&inptr,·&inbytesleft, |
| | 139 | ····························&outptr,·&outbytesleft); |
| | 140 | ········if·(res·!=·(size_t)(-1)·||·outptr·-·buf·>·1·||·buf[1]·!=·(char)0xAD) |
| | 141 | ··········result·|=·4; |
| | 142 | ········iconv_close·(cd_88591_to_utf8); |
| | 143 | ······} |
| | 144 | ··} |
| | 145 | #if·0·/*·This·bug·could·be·worked·around·by·the·caller.··*/ |
| | 146 | ··/*·Test·against·HP-UX·11.11·bug:·Positive·return·value·instead·of·0.··*/ |
| | 147 | ··{ |
| | 148 | ····iconv_t·cd_88591_to_utf8·=·iconv_open·("utf8",·"iso88591"); |
| | 149 | ····if·(cd_88591_to_utf8·!=·(iconv_t)(-1)) |
| | 150 | ······{ |
| | 151 | ········static·ICONV_CONST·char·input[]·=·"\304rger·mit·b\366sen·B\374bchen·ohne·Augenma\337"; |
| | 152 | ········char·buf[50]; |
| | 153 | ········ICONV_CONST·char·*inptr·=·input; |
| | 154 | ········size_t·inbytesleft·=·strlen·(input); |
| | 155 | ········char·*outptr·=·buf; |
| | 156 | ········size_t·outbytesleft·=·sizeof·(buf); |
| | 157 | ········size_t·res·=·iconv·(cd_88591_to_utf8, |
| | 158 | ····························&inptr,·&inbytesleft, |
| | 159 | ····························&outptr,·&outbytesleft); |
| | 160 | ········if·((int)res·>·0) |
| | 161 | ··········result·|=·8; |
| | 162 | ········iconv_close·(cd_88591_to_utf8); |
| | 163 | ······} |
| | 164 | ··} |
| | 165 | #endif |
| | 166 | ··/*·Test·against·HP-UX·11.11·bug:·No·converter·from·EUC-JP·to·UTF-8·is |
| | 167 | ·····provided.··*/ |
| | 168 | ··{ |
| | 169 | ····/*·Try·standardized·names.··*/ |
| | 170 | ····iconv_t·cd1·=·iconv_open·("UTF-8",·"EUC-JP"); |
| | 171 | ····/*·Try·IRIX,·OSF/1·names.··*/ |
| | 172 | ····iconv_t·cd2·=·iconv_open·("UTF-8",·"eucJP"); |
| | 173 | ····/*·Try·AIX·names.··*/ |
| | 174 | ····iconv_t·cd3·=·iconv_open·("UTF-8",·"IBM-eucJP"); |
| | 175 | ····/*·Try·HP-UX·names.··*/ |
| | 176 | ····iconv_t·cd4·=·iconv_open·("utf8",·"eucJP"); |
| | 177 | ····if·(cd1·==·(iconv_t)(-1)·&&·cd2·==·(iconv_t)(-1) |
| | 178 | ········&&·cd3·==·(iconv_t)(-1)·&&·cd4·==·(iconv_t)(-1)) |
| | 179 | ······result·|=·16; |
| | 180 | ····if·(cd1·!=·(iconv_t)(-1)) |
| | 181 | ······iconv_close·(cd1); |
| | 182 | ····if·(cd2·!=·(iconv_t)(-1)) |
| | 183 | ······iconv_close·(cd2); |
| | 184 | ····if·(cd3·!=·(iconv_t)(-1)) |
| | 185 | ······iconv_close·(cd3); |
| | 186 | ····if·(cd4·!=·(iconv_t)(-1)) |
| | 187 | ······iconv_close·(cd4); |
| | 188 | ··} |
| | 189 | ··return·result; |
| | 190 | ]])], |
| | 191 | ··········[am_cv_func_iconv_works=yes],·, |
| | 192 | ··········[case·"$host_os"·in |
| | 193 | ·············aix*·|·hpux*)·am_cv_func_iconv_works="guessing·no"·;; |
| | 194 | ·············*)············am_cv_func_iconv_works="guessing·yes"·;; |
| | 195 | ···········esac]) |
| | 196 | ········test·"$am_cv_func_iconv_works"·=·no·||·break |
| | 197 | ······done |
| | 198 | ······LIBS="$am_save_LIBS" |
| | 199 | ····]) |
| | 200 | ····case·"$am_cv_func_iconv_works"·in |
| | 201 | ······*no)·am_func_iconv=no·am_cv_lib_iconv=no·;; |
| | 202 | ······*)···am_func_iconv=yes·;; |
| | 203 | ····esac |
| | 204 | ··else |
| | 205 | ····am_func_iconv=no·am_cv_lib_iconv=no |
| | 206 | ··fi |
| | 207 | ··if·test·"$am_func_iconv"·=·yes;·then |
| | 208 | ····AC_DEFINE([HAVE_ICONV],·[1], |
| | 209 | ······[Define·if·you·have·the·iconv()·function·and·it·works.]) |
| | 210 | ··fi |
| | 211 | ··if·test·"$am_cv_lib_iconv"·=·yes;·then |
| | 212 | ····AC_MSG_CHECKING([how·to·link·with·libiconv]) |
| | 213 | ····AC_MSG_RESULT([$LIBICONV]) |
| | 214 | ··else |
| | 215 | ····dnl·If·$LIBICONV·didn't·lead·to·a·usable·library,·we·don't·need·$INCICONV |
| | 216 | ····dnl·either. |
| | 217 | ····CPPFLAGS="$am_save_CPPFLAGS" |
| | 218 | ····LIBICONV= |
| | 219 | ····LTLIBICONV= |
| | 220 | ··fi |
| | 221 | ··AC_SUBST([LIBICONV]) |
| | 222 | ··AC_SUBST([LTLIBICONV]) |
| | 223 | ]) |
| | |
| | 224 | dnl·Define·AM_ICONV·using·AC_DEFUN_ONCE,·in·order·to·avoid·warnings·like |
| | 225 | dnl·"warning:·AC_REQUIRE:·`AM_ICONV'·was·expanded·before·it·was·required". |
| | 226 | AC_DEFUN_ONCE([AM_ICONV], |
| | 227 | [ |
| | 228 | ··AM_ICONV_LINK |
| | 229 | ··if·test·"$am_cv_func_iconv"·=·yes;·then |
| | 230 | ····AC_CACHE_CHECK([whether·iconv·is·compatible·with·its·POSIX·signature], |
| | 231 | ······[gl_cv_iconv_nonconst], |
| | 232 | ······[AC_COMPILE_IFELSE( |
| | 233 | ·········[AC_LANG_PROGRAM( |
| | 234 | ············[[ |
| | 235 | #include·<stdlib.h> |
| | 236 | #include·<iconv.h> |
| | 237 | extern |
| | 238 | #ifdef·__cplusplus |
| | 239 | "C" |
| | 240 | #endif |
| | 241 | size_t·iconv·(iconv_t·cd,·char·*·*inbuf,·size_t·*inbytesleft,·char·*·*outbuf,·size_t·*outbytesleft); |
| | 242 | ············]], |
| | 243 | ············[[]])], |
| | 244 | ·········[gl_cv_iconv_nonconst=yes], |
| | 245 | ·········[gl_cv_iconv_nonconst=no]) |
| | 246 | ······]) |
| | 247 | ··else |
| | 248 | ····dnl·When·compiling·GNU·libiconv·on·a·system·that·does·not·have·iconv·yet, |
| | 249 | ····dnl·pick·the·POSIX·compliant·declaration·without·'const'. |
| | 250 | ····gl_cv_iconv_nonconst=yes |
| | 251 | ··fi |
| | 252 | ··if·test·$gl_cv_iconv_nonconst·=·yes;·then |
| | 253 | ····iconv_arg1="" |
| | 254 | ··else |
| | 255 | ····iconv_arg1="const" |
| | 256 | ··fi |
| | 257 | ··AC_DEFINE_UNQUOTED([ICONV_CONST],·[$iconv_arg1], |
| | 258 | ····[Define·as·const·if·the·declaration·of·iconv()·needs·const.]) |
| | 259 | ··dnl·Also·substitute·ICONV_CONST·in·the·gnulib·generated·<iconv.h>. |
| | 260 | ··m4_ifdef([gl_ICONV_H_DEFAULTS], |
| | 261 | ····[AC_REQUIRE([gl_ICONV_H_DEFAULTS]) |
| | 262 | ·····if·test·$gl_cv_iconv_nonconst·!=·yes;·then |
| | 263 | ·······ICONV_CONST="const" |
| | 264 | ·····fi |
| | 265 | ····]) |
| | |
| | 266 | ··dnl·A·summary·result,·for·those·packages·which·want·to·print·a·summary·at·the |
| | 267 | ··dnl·end·of·the·configuration. |
| | 268 | ··if·test·"$am_func_iconv"·=·yes;·then |
| | 269 | ····if·test·-n·"$LIBICONV";·then |
| | 270 | ······am_cv_func_iconv_summary='yes,·in·libiconv' |
| | 271 | ····else |
| | 272 | ······am_cv_func_iconv_summary='yes,·in·libc' |
| | 273 | ····fi |
| | 274 | ··else |
| | 275 | ····if·test·"$am_cv_func_iconv"·=·yes;·then |
| | 276 | ······am_cv_func_iconv_summary='not·working,·consider·installing·GNU·libiconv' |
| | 277 | ····else |
| | 278 | ······am_cv_func_iconv_summary='no,·consider·installing·GNU·libiconv' |
| | 279 | ····fi |
| | 280 | ··fi |
| | 281 | ]) |