Build problem with libiconv
Alexander Bokovoy
a.bokovoy at sam-solutions.net
Mon Feb 17 12:19:46 GMT 2003
On Mon, Feb 17, 2003 at 07:04:55AM -0500, Ken Cross wrote:
> Samba-folk:
>
> When building SAMBA_3_0 on NetBSD (and I think any OS except Linux,
> Solaris, or OSF) with iconv support, configure can't figure out that
> iconv is really present. It's because in <iconv.h>, it defines:
>
> #ifndef LIBICONV_PLUG
> #define iconv_open libiconv_open
> #endif
>
> where LIBICONV_PLUG is defined on OS's with plug libraries (Linux,
> Solaris, or OSF). What I've done locally to fix it is:
>
> Index: configure.in
> ===================================================================
> RCS file: /cvsroot/samba/source/configure.in,v
> retrieving revision 1.300.2.43
> diff -p -u -r1.300.2.43 configure.in
> --- configure.in 14 Feb 2003 00:47:27 -0000 1.300.2.43
> +++ configure.in 17 Feb 2003 11:56:37 -0000
> @@ -1490,7 +1490,7 @@ AC_ARG_WITH(libiconv,
> AC_MSG_RESULT(yes)
> CFLAGS="$CFLAGS -I$withval/include"
> LDFLAGS="$LDFLAGS -L$withval/lib"
> - AC_CHECK_LIB(iconv, iconv_open)
> + AC_CHECK_LIB(iconv, libiconv_open)
> AC_DEFINE_UNQUOTED(WITH_LIBICONV, "${withval}",[Path to iconv])
> ;;
> esac ],
>
>
> However, I think this'll break OS's with plug libraries (Linux, Solaris,
> or OSF). What configure should really do is try one (iconv_open) then
> the other (libiconv_open). (I'm not sure what's involved in that or I'd
> have done it.)
The better approach is to use a code which allows to find all types of ICONV(3).
We use following in Midgard's core for years:
dnl From Bruno Haible.
AC_DEFUN(jm_ICONV,
[
dnl Some systems have iconv in libc, some have it in libiconv (OSF/1 and
dnl those with the standalone portable libiconv installed).
AC_MSG_CHECKING(for iconv in $1)
jm_cv_func_iconv="no"
jm_cv_lib_iconv=no
jm_cv_giconv=no
AC_TRY_LINK([#include <stdlib.h>
#include <giconv.h>],
[iconv_t cd = iconv_open("","");
iconv(cd,NULL,NULL,NULL,NULL);
iconv_close(cd);],
jm_cv_func_iconv=yes
jm_cv_giconv=yes)
if test "$jm_cv_func_iconv" != yes; then
AC_TRY_LINK([#include <stdlib.h>
#include <iconv.h>],
[iconv_t cd = iconv_open("","");
iconv(cd,NULL,NULL,NULL,NULL);
iconv_close(cd);],
jm_cv_func_iconv=yes)
if test "$jm_cv_lib_iconv" != yes; then
jm_save_LIBS="$LIBS"
LIBS="$LIBS -lgiconv"
AC_TRY_LINK([#include <stdlib.h>
#include <giconv.h>],
[iconv_t cd = iconv_open("","");
iconv(cd,NULL,NULL,NULL,NULL);
iconv_close(cd);],
jm_cv_lib_iconv=yes
jm_cv_func_iconv=yes
jm_cv_giconv=yes)
LIBS="$jm_save_LIBS"
if test "$jm_cv_func_iconv" != yes; then
jm_save_LIBS="$LIBS"
LIBS="$LIBS -liconv"
AC_TRY_LINK([#include <stdlib.h>
#include <iconv.h>],
[iconv_t cd = iconv_open("","");
iconv(cd,NULL,NULL,NULL,NULL);
iconv_close(cd);],
jm_cv_lib_iconv=yes
jm_cv_func_iconv=yes)
LIBS="$jm_save_LIBS"
fi
fi
fi
if test "$jm_cv_func_iconv" = yes; then
if test "$jm_cv_giconv" = yes; then
AC_DEFINE(HAVE_GICONV, 1, [Define if you have the iconv() function.])
ICONV_INCLUDE=giconv.h
AC_MSG_RESULT(yes)
ICONV_FOUND=yes
else
AC_DEFINE(HAVE_ICONV, 1, [Define if you have the iconv() function.])
ICONV_INCLUDE=iconv.h
AC_MSG_RESULT(yes)
ICONV_FOUND=yes
fi
else
AC_MSG_RESULT(no)
fi
if test "$jm_cv_lib_iconv" = yes; then
if test "$jm_cv_giconv" = yes; then
LIBS="$LIBS -lgiconv"
else
LIBS="$LIBS -liconv"
fi
fi
])
--
/ Alexander Bokovoy
---
ignorance, n.:
When you don't know anything, and someone else finds out.
More information about the samba-technical
mailing list