diff options
-rw-r--r-- | source3/aclocal.m4 | 92 | ||||
-rw-r--r-- | source3/configure.in | 60 | ||||
-rw-r--r-- | source3/include/includes.h | 5 |
3 files changed, 140 insertions, 17 deletions
diff --git a/source3/aclocal.m4 b/source3/aclocal.m4 index 5b1500106c..345be73aed 100644 --- a/source3/aclocal.m4 +++ b/source3/aclocal.m4 @@ -485,3 +485,95 @@ AC_DEFUN(LIB_REMOVE_USR_LIB,[ done $1=[$]ac_new_flags ]) + +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, [What header to include for iconv() function: giconv.h]) + AC_MSG_RESULT(yes) + ICONV_FOUND=yes + else + AC_DEFINE(HAVE_ICONV, 1, [What header to include for iconv() function: 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 +]) + +dnl CFLAGS_ADD_DIR(CFLAGS, $INCDIR) +dnl This function doesn't add -I/usr/include into CFLAGS +AC_DEFUN(CFLAGS_ADD_DIR,[ +if test "$2" != "/usr/include" ; then + $1="$$1 -I$2" +fi +]) + +dnl LIB_ADD_DIR(LDFLAGS, $LIBDIR) +dnl This function doesn't add -L/usr/lib into LDFLAGS +AC_DEFUN(LIB_ADD_DIR,[ +if test "$2" != "/usr/lib" ; then + $1="$$1 -L$2" +fi +]) diff --git a/source3/configure.in b/source3/configure.in index b90d99bf3d..dfd97bc42f 100644 --- a/source3/configure.in +++ b/source3/configure.in @@ -1482,26 +1482,47 @@ if test x"$samba_cv_HAVE_UX_UT_SYSLEN" = x"yes"; then fi -################################################# -# check for libiconv support -AC_MSG_CHECKING(whether to use libiconv) +ICONV_LOCATION=standard +LOOK_DIRS="/usr /usr/local /sw" AC_ARG_WITH(libiconv, [ --with-libiconv=BASEDIR Use libiconv in BASEDIR/lib and BASEDIR/include (default=auto) ], -[ case "$withval" in - no) - AC_MSG_RESULT(no) - ;; - *) - AC_MSG_RESULT(yes) - CFLAGS="$CFLAGS -I$withval/include" - LDFLAGS="$LDFLAGS -L$withval/lib" - AC_CHECK_LIB(iconv, iconv_open) - AC_DEFINE_UNQUOTED(WITH_LIBICONV, "${withval}",[Path to iconv]) - ;; - esac ], - AC_MSG_RESULT(no) -) +[ + if test "$withval" = "no" ; then + AC_MSG_ERROR(I won't take no for an answer) + else + if test "$withval" != "yes" ; then + LOOK_DIRS="$withval $LOOK_DIRS" + fi + fi +]) +ICONV_FOUND="no" +for i in $LOOK_DIRS ; do + save_LIBS=$LIBS + save_LDFLAGS=$LDFLAGS + save_CPPFLAGS=$CPPFLAGS + CPPFLAGS="-I$i/include" + LDFLAGS="-L$i/lib" + LIBS= + export LDFLAGS LIBS CPPFLAGS +dnl Try to find iconv(3) + jm_ICONV($i) + + CPPFLAGS=$save_CPPFLAGS + if test -n "$ICONV_FOUND" ; then + LDFLAGS=$save_LDFLAGS + LIB_ADD_DIR(LDFLAGS, "$i/lib") + CFLAGS_ADD_DIR(CPPFLAGS, "$i/include") + LIBS="$save_LIBS $LIBS" + ICONV_LOCATION=$i + export LDFLAGS LIBS CPPFLAGS + break + else + LDFLAGS=$save_LDFLAGS + LIBS=$save_LIBS + export LDFLAGS LIBS CPPFLAGS + fi +done ############ # check for iconv in libc @@ -1519,6 +1540,11 @@ if test x"$samba_cv_HAVE_NATIVE_ICONV" = x"yes"; then AC_DEFINE(HAVE_NATIVE_ICONV,1,[Whether to use native iconv]) fi +if test x"$ICONV_FOUND" = x"no" -o x"$samba_cv_HAVE_NATIVE_ICONV" != x"yes" ; then + AC_MSG_WARN([Sufficient support for iconv function was not found. + Install libiconv from http://freshmeat.net/projects/libiconv/ for better charset compatibility!]) +fi + AC_CACHE_CHECK([for Linux kernel oplocks],samba_cv_HAVE_KERNEL_OPLOCKS_LINUX,[ AC_TRY_RUN([ diff --git a/source3/include/includes.h b/source3/include/includes.h index 731d94996c..0d1c72cf1c 100644 --- a/source3/include/includes.h +++ b/source3/include/includes.h @@ -393,8 +393,13 @@ #endif /* HAVE_SYS_SHM_H */ #ifdef HAVE_NATIVE_ICONV +#ifdef HAVE_ICONV #include <iconv.h> #endif +#ifdef HAVE_GICONV +#include <giconv.h> +#endif +#endif #if HAVE_KRB5_H #include <krb5.h> |