1 dnl SMB_CHECK_ICONV(hdr, msg, action-if-found,action-if-not-found)
2 AC_DEFUN(SMB_CHECK_ICONV,[
4 AC_TRY_RUN([#include <stdlib.h>
9 iconv_t cd = iconv_open("ASCII","UCS-2LE");
10 if (cd == 0 || cd == (iconv_t)-1) return -1;
14 [AC_MSG_RESULT(yes); $3],
15 [AC_MSG_RESULT(no); $4],
16 [AC_MSG_RESULT(cross); $4])
19 dnl SMB_CHECK_ICONV_DIR(dir,action-if-found,action-if-not-found)
20 AC_DEFUN(SMB_CHECK_ICONV_DIR,
22 save_CPPFLAGS="$CPPFLAGS"
23 save_LDFLAGS="$LDFLAGS"
25 CPPFLAGS="-I$1/include"
29 SMB_CHECK_ICONV(iconv.h,Whether iconv.h is present,[ AC_DEFINE(HAVE_ICONV_H,1,[Whether iconv.h is present]) $2 ], [
31 SMB_CHECK_ICONV(giconv.h,Whether giconv.h is present, [AC_DEFINE(HAVE_GICONV_H,1,[Whether giconv.h is present]) $2],[$3])
34 CPPFLAGS="$save_CPPFLAGS"
35 LDFLAGS="$save_LDFLAGS"
40 LOOK_DIRS="/usr /usr/local /sw"
42 [ --with-libiconv=BASEDIR Use libiconv in BASEDIR/lib and BASEDIR/include (default=auto) ],
44 if test "$withval" = "no" ; then
45 AC_MSG_ERROR(I won't take no for an answer)
47 if test "$withval" != "yes" ; then
48 SMB_CHECK_ICONV_DIR($withval, [
50 ICONV_CPPFLAGS="$CPPFLAGS"
52 ICONV_LDFLAGS="$LDFLAGS"
53 ], [AC_MSG_ERROR([No iconv library found in $withval])])
58 if test x$ICONV_FOUND = xno; then
59 SMB_CHECK_ICONV(iconv.h,
60 [Whether iconv.h is present],
61 [AC_DEFINE(HAVE_ICONV_H,1,[Whether iconv.h is present]) ICONV_FOUND=yes])
64 for i in $LOOK_DIRS ; do
65 if test x$ICONV_FOUND = xyes; then
69 SMB_CHECK_ICONV_DIR($i, [
71 ICONV_CPPFLAGS="$CPPFLAGS"
73 ICONV_LDFLAGS="$LDFLAGS"
77 if test x"$ICONV_FOUND" = x"no"; then
78 AC_MSG_WARN([Sufficient support for iconv function was not found.
79 Install libiconv from http://www.gnu.org/software/libiconv/ for better charset compatibility!])
82 AC_DEFINE(HAVE_NATIVE_ICONV,1,[Whether external iconv is available])
86 SMB_EXT_LIB(ICONV,[${ICONV_LIBS}],[${ICONV_CFLAGS}],[${ICONV_CPPFLAGS}],[${ICONV_LDFLAGS}])