on some systems (openbsd, solaris, freebsd) the iconv was not really well

recognized and/or added to the LIBS .. i tested this version on a lot of
different platforms and it SHOULD work propperly, even if it looks a bit
strange.
This commit is contained in:
mathias 2005-05-12 20:00:18 +00:00
parent 87212dd249
commit c55dce44fa

View file

@ -72,44 +72,77 @@ size_t x = strftime(s, 5, "%a", localtime(&t));
dnl --------------- dnl ---------------
dnl CHECK FOR ICONV dnl CHECK FOR ICONV
dnl --------------- dnl ---------------
dnl Find iconv. It may be in libiconv and may be iconv() or libiconv() dnl Find iconv. It may be in libiconv and may be iconv() or libiconv()
if test "x$ac_cv_header_iconv_h" = "xyes"; then if test "x$ac_cv_header_iconv_h" = "xyes"; then
AC_CHECK_FUNC(iconv, ac_found_iconv=yes, ac_found_iconv=no) ac_found_iconv=no
if test "x$ac_found_iconv" = "xno"; then AC_COMPILE_IFELSE(
AC_CHECK_LIB(iconv, iconv, ac_found_iconv=yes) [AC_LANG_PROGRAM(
if test "x$ac_found_iconv" = "xno"; then [[#include <stdlib.h>
AC_CHECK_LIB(iconv, libiconv, ac_found_iconv=yes) #include <iconv.h>]],
fi [[
if test "x$ac_found_iconv" != "xno"; then iconv_open(NULL, NULL);
LIBS="-liconv $LIBS" return 0;
fi ]]
fi )],
fi [
if test "x$ac_found_iconv" = xyes; then ac_found_iconv=yes
AC_DEFINE(HAVE_ICONV, 1, [Define if you have the iconv() function.]) ],
fi [ ])
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM(
[[#include <stdlib.h>
#include <iconv.h>]],
[[
libiconv_open(NULL, NULL);
return 0;
]]
)],
[
ac_found_iconv=yes
],
[ ])
if test "x$ac_found_iconv" = xyes; then
AC_DEFINE(HAVE_ICONV, 1, [Define if you have the iconv() function.])
AC_CHECK_LIB([iconv],
[iconv_open],
[
LIBS="$LIBS -liconv"
],
[])
AC_CHECK_LIB([iconv],
[libiconv_open],
[
LIBS="$LIBS -liconv"
],
[])
dnl Check if iconv uses const in prototype declaration dnl Check if iconv uses const in prototype declaration
if test "x$ac_found_iconv" = "xyes"; then AC_CACHE_CHECK(for iconv declaration,
AC_CACHE_CHECK(for iconv declaration, ac_cv_iconv_const, ac_cv_iconv_const,
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdlib.h> [AC_COMPILE_IFELSE(
#include <iconv.h>]], [AC_LANG_PROGRAM(
[[ [[#include <stdlib.h>
char **msg, **new_msg; #include <iconv.h>]],
size_t result, inleft, outleft; [[
result = iconv((iconv_t)(-1), msg, &inleft, new_msg, &outleft); char **msg, **new_msg;
return 0; size_t result, inleft, outleft;
]])], result = iconv((iconv_t)(-1), msg, &inleft, new_msg, &outleft);
[ac_cv_iconv_const=no], return 0;
[ac_cv_iconv_const=yes])]) ]]
if test "x$ac_cv_iconv_const" = xyes; then )],
AC_DEFINE(HAVE_CONST_ICONV, 1, [Define if you have the iconv() function.]) [ac_cv_iconv_const=no],
fi [ac_cv_iconv_const=yes])
])
if test "x$ac_cv_iconv_const" = xyes; then
AC_DEFINE(HAVE_CONST_ICONV, 1, [Define if you have the iconv() function.])
fi
fi
fi fi
AC_CHECK_LIB(nsl, t_open, LIBS="$LIBS -lnsl") AC_CHECK_LIB(nsl, t_open, LIBS="$LIBS -lnsl")
AC_CHECK_LIB(socket, socket, LIBS="$LIBS -lsocket") AC_CHECK_LIB(socket, socket, LIBS="$LIBS -lsocket")