iconv.m4 3.3 KB

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