iconv.m4 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. # iconv.m4 serial AM4 (gettext-0.11.3)
  2. dnl Copyright (C) 2000-2002 Free Software Foundation, Inc.
  3. dnl This file is free software, distributed under the terms of the GNU
  4. dnl General Public License. As a special exception to the GNU General
  5. dnl Public License, this file may be distributed as part of a program
  6. dnl that contains a configuration script generated by Autoconf, under
  7. dnl the same distribution terms as the rest of that program.
  8. dnl From Bruno Haible.
  9. AC_DEFUN([AM_ICONV_LINKFLAGS_BODY],
  10. [
  11. dnl Prerequisites of AC_LIB_LINKFLAGS_BODY.
  12. AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
  13. AC_REQUIRE([AC_LIB_RPATH])
  14. dnl Search for libiconv and define LIBICONV, LTLIBICONV and INCICONV
  15. dnl accordingly.
  16. AC_LIB_LINKFLAGS_BODY([iconv])
  17. ])
  18. AC_DEFUN([AM_ICONV_LINK],
  19. [
  20. dnl Some systems have iconv in libc, some have it in libiconv (OSF/1 and
  21. dnl those with the standalone portable GNU libiconv installed).
  22. dnl Search for libiconv and define LIBICONV, LTLIBICONV and INCICONV
  23. dnl accordingly.
  24. AC_REQUIRE([AM_ICONV_LINKFLAGS_BODY])
  25. dnl Add $INCICONV to CPPFLAGS before performing the following checks,
  26. dnl because if the user has installed libiconv and not disabled its use
  27. dnl via --without-libiconv-prefix, he wants to use it. The first
  28. dnl AC_TRY_LINK will then fail, the second AC_TRY_LINK will succeed.
  29. am_save_CPPFLAGS="$CPPFLAGS"
  30. AC_LIB_APPENDTOVAR([CPPFLAGS], [$INCICONV])
  31. AC_CACHE_CHECK(for iconv, am_cv_func_iconv, [
  32. am_cv_func_iconv="no, consider installing GNU libiconv"
  33. am_cv_lib_iconv=no
  34. AC_TRY_LINK([#include <stdlib.h>
  35. #include <iconv.h>],
  36. [iconv_t cd = iconv_open("","");
  37. iconv(cd,NULL,NULL,NULL,NULL);
  38. iconv_close(cd);],
  39. am_cv_func_iconv=yes)
  40. if test "$am_cv_func_iconv" != yes; then
  41. am_save_LIBS="$LIBS"
  42. LIBS="$LIBS $LIBICONV"
  43. AC_TRY_LINK([#include <stdlib.h>
  44. #include <iconv.h>],
  45. [iconv_t cd = iconv_open("","");
  46. iconv(cd,NULL,NULL,NULL,NULL);
  47. iconv_close(cd);],
  48. am_cv_lib_iconv=yes
  49. am_cv_func_iconv=yes)
  50. LIBS="$am_save_LIBS"
  51. fi
  52. ])
  53. if test "$am_cv_func_iconv" = yes; then
  54. AC_DEFINE(HAVE_ICONV, 1, [Define if you have the iconv() function.])
  55. fi
  56. if test "$am_cv_lib_iconv" = yes; then
  57. AC_MSG_CHECKING([how to link with libiconv])
  58. AC_MSG_RESULT([$LIBICONV])
  59. else
  60. dnl If $LIBICONV didn't lead to a usable library, we don't need $INCICONV
  61. dnl either.
  62. CPPFLAGS="$am_save_CPPFLAGS"
  63. LIBICONV=
  64. LTLIBICONV=
  65. fi
  66. AC_SUBST(LIBICONV)
  67. AC_SUBST(LTLIBICONV)
  68. ])
  69. AC_DEFUN([AM_ICONV],
  70. [
  71. AM_ICONV_LINK
  72. if test "$am_cv_func_iconv" = yes; then
  73. AC_MSG_CHECKING([for iconv declaration])
  74. AC_CACHE_VAL(am_cv_proto_iconv, [
  75. AC_TRY_COMPILE([
  76. #include <stdlib.h>
  77. #include <iconv.h>
  78. extern
  79. #ifdef __cplusplus
  80. "C"
  81. #endif
  82. #if defined(__STDC__) || defined(__cplusplus)
  83. size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
  84. #else
  85. size_t iconv();
  86. #endif
  87. ], [], am_cv_proto_iconv_arg1="", am_cv_proto_iconv_arg1="const")
  88. am_cv_proto_iconv="extern size_t iconv (iconv_t cd, $am_cv_proto_iconv_arg1 char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);"])
  89. am_cv_proto_iconv=`echo "[$]am_cv_proto_iconv" | tr -s ' ' | sed -e 's/( /(/'`
  90. AC_MSG_RESULT([$]{ac_t:-
  91. }[$]am_cv_proto_iconv)
  92. AC_DEFINE_UNQUOTED(ICONV_CONST, $am_cv_proto_iconv_arg1,
  93. [Define as const if the declaration of iconv() needs const.])
  94. fi
  95. ])