1 dnl SMB_CHECK_ICONV(action-if-found,action-if-not-found)
2 AC_DEFUN(SMB_CHECK_ICONV,[
3 AC_CHECK_HEADERS(iconv.h giconv.h)
5 AC_TRY_RUN([#include <stdlib.h>
15 iconv_t cd = iconv_open("ASCII","UCS-2LE");
16 if (cd == 0 || cd == (iconv_t)-1) return -1;
22 dnl SMB_CHECK_ICONV_DIR(dir,action-if-found,action-if-not-found)
23 AC_DEFUN(SMB_CHECK_ICONV_DIR,
25 if test -f "$1/include/iconv.h" -o -f "$1/include/giconv.h"; then
26 CPPFLAGS="-I$1/include"
33 SMB_CHECK_ICONV([$2],[$3])
36 CPPFLAGS=$save_CPPFLAGS
45 LOOK_DIRS="/usr /usr/local /sw"
47 [ --with-libiconv=BASEDIR Use libiconv in BASEDIR/lib and BASEDIR/include (default=auto) ],
49 if test "$withval" = "no" ; then
50 AC_MSG_ERROR(I won't take no for an answer)
52 if test "$withval" != "yes" ; then
53 SMB_CHECK_ICONV_DIR($withval, [
55 ICONV_CPPFLAGS="$CPPFLAGS"
57 ICONV_LDFLAGS="$LDFLAGS"
58 ], [AC_MSG_ERROR([No iconv library found in $withval])])
63 if test x$ICONV_FOUND = xno; then
64 SMB_CHECK_ICONV([ICONV_FOUND=yes])
67 for i in $LOOK_DIRS ; do
68 if test x$ICONV_FOUND = xyes; then
72 SMB_CHECK_ICONV_DIR($i, [
74 ICONV_CPPFLAGS="$CPPFLAGS"
76 ICONV_LDFLAGS="$LDFLAGS"
80 if test x"$ICONV_FOUND" = x"no"; then
81 AC_MSG_WARN([Sufficient support for iconv function was not found.
82 Install libiconv from http://www.gnu.org/software/libiconv/ for better charset compatibility!])
85 AC_DEFINE(HAVE_NATIVE_ICONV,1,[Whether external iconv is available])
89 SMB_EXT_LIB(ICONV,[${ICONV_LIBS}],[${ICONV_CFLAGS}],[${ICONV_CPPFLAGS}],[${ICONV_LDFLAGS}])