2006-10-21 09:15:15 +00:00
dnl SMB_CHECK_ICONV(hdr, msg, action-if-found,action-if-not-found)
2006-05-13 17:13:46 +00:00
AC_DEFUN(SMB_CHECK_ICONV,[
2006-10-21 09:15:15 +00:00
AC_MSG_CHECKING($2)
2006-05-13 17:13:46 +00:00
AC_TRY_RUN([#include <stdlib.h>
2006-05-24 17:57:54 +00:00
#include <$1>
2006-05-13 17:13:46 +00:00
int main()
{
iconv_t cd = iconv_open("ASCII","UCS-2LE");
if (cd == 0 || cd == (iconv_t)-1) return -1;
return 0;
}
2007-01-12 03:05:31 +00:00
],
[AC_MSG_RESULT(yes); $3],
[AC_MSG_RESULT(no); $4],
[AC_MSG_RESULT(cross); $4])
2006-05-13 17:13:46 +00:00
])
dnl SMB_CHECK_ICONV_DIR(dir,action-if-found,action-if-not-found)
AC_DEFUN(SMB_CHECK_ICONV_DIR,
[
2006-06-11 23:12:51 +00:00
save_CPPFLAGS="$CPPFLAGS"
save_LDFLAGS="$LDFLAGS"
save_LIBS="$LIBS"
2006-05-13 17:13:46 +00:00
CPPFLAGS="-I$1/include"
LDFLAGS="-L$1/lib"
LIBS=-liconv
2006-10-21 09:15:15 +00:00
SMB_CHECK_ICONV(iconv.h,Whether iconv.h is present,[ AC_DEFINE(HAVE_ICONV_H,1,[Whether iconv.h is present]) $2 ], [
2006-05-24 17:57:54 +00:00
LIBS=-lgiconv
2006-10-21 09:15:15 +00:00
SMB_CHECK_ICONV(giconv.h,Whether giconv.h is present, [AC_DEFINE(HAVE_GICONV_H,1,[Whether giconv.h is present]) $2],[$3])
2006-05-13 17:13:46 +00:00
])
2006-06-11 23:12:51 +00:00
CPPFLAGS="$save_CPPFLAGS"
LDFLAGS="$save_LDFLAGS"
LIBS="$save_LIBS"
2006-05-13 17:13:46 +00:00
])
ICONV_FOUND=no
2004-02-02 13:43:03 +00:00
LOOK_DIRS="/usr /usr/local /sw"
AC_ARG_WITH(libiconv,
[ --with-libiconv=BASEDIR Use libiconv in BASEDIR/lib and BASEDIR/include (default=auto) ],
[
if test "$withval" = "no" ; then
AC_MSG_ERROR(I won't take no for an answer)
else
if test "$withval" != "yes" ; then
2006-05-13 17:13:46 +00:00
SMB_CHECK_ICONV_DIR($withval, [
ICONV_FOUND=yes;
ICONV_CPPFLAGS="$CPPFLAGS"
ICONV_LIBS="$LIBS"
ICONV_LDFLAGS="$LDFLAGS"
], [AC_MSG_ERROR([No iconv library found in $withval])])
2004-02-02 13:43:03 +00:00
fi
fi
])
2006-05-13 17:13:46 +00:00
if test x$ICONV_FOUND = xno; then
2006-10-21 09:15:15 +00:00
SMB_CHECK_ICONV(iconv.h,
[Whether iconv.h is present],
[AC_DEFINE(HAVE_ICONV_H,1,[Whether iconv.h is present]) ICONV_FOUND=yes])
2006-05-13 17:13:46 +00:00
fi
2005-08-04 23:56:18 +00:00
2006-05-13 17:13:46 +00:00
for i in $LOOK_DIRS ; do
if test x$ICONV_FOUND = xyes; then
break
fi
2006-05-24 17:47:40 +00:00
SMB_CHECK_ICONV_DIR($i, [
2006-05-24 18:23:57 +00:00
ICONV_FOUND=yes
2006-05-13 17:13:46 +00:00
ICONV_CPPFLAGS="$CPPFLAGS"
ICONV_LIBS="$LIBS"
ICONV_LDFLAGS="$LDFLAGS"
], [])
2004-02-02 13:43:03 +00:00
done
2006-05-13 17:13:46 +00:00
if test x"$ICONV_FOUND" = x"no"; then
2004-02-02 13:43:03 +00:00
AC_MSG_WARN([Sufficient support for iconv function was not found.
2006-05-13 17:13:46 +00:00
Install libiconv from http://www.gnu.org/software/libiconv/ for better charset compatibility!])
SMB_ENABLE(ICONV,NO)
else
AC_DEFINE(HAVE_NATIVE_ICONV,1,[Whether external iconv is available])
SMB_ENABLE(ICONV,YES)
2004-02-02 13:43:03 +00:00
fi
2005-08-04 23:56:18 +00:00
SMB_EXT_LIB(ICONV,[${ICONV_LIBS}],[${ICONV_CFLAGS}],[${ICONV_CPPFLAGS}],[${ICONV_LDFLAGS}])