Index: samba/source/aclocal.m4 =================================================================== --- samba/source/aclocal.m4.orig +++ samba/source/aclocal.m4 @@ -403,22 +403,6 @@ main(){ AC_MSG_RESULT($ICONV_CHARSET) ]) -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 -]) - dnl AC_ENABLE_SHARED - implement the --enable-shared flag dnl Usage: AC_ENABLE_SHARED[(DEFAULT)] dnl Where DEFAULT is either `yes' or `no'. If omitted, it defaults to Index: samba/source/configure.in =================================================================== --- samba/source/configure.in.orig +++ samba/source/configure.in @@ -2353,8 +2353,7 @@ fi # end utmp details -ICONV_LOCATION=standard -LOOK_DIRS="/usr /usr/local /sw /opt" +ICONV_LOOK_DIRS="/usr /usr/local /sw /opt" AC_ARG_WITH(libiconv, [ --with-libiconv=BASEDIR Use libiconv in BASEDIR/lib and BASEDIR/include (default=auto) ], [ @@ -2363,20 +2362,27 @@ AC_ARG_WITH(libiconv, else if test "$withval" != "yes" ; then ICONV_PATH_SPEC=yes - LOOK_DIRS="$withval" + ICONV_LOOK_DIRS="$withval" fi fi ]) -for i in $LOOK_DIRS ; do - save_LIBS=$LIBS - save_LDFLAGS=$LDFLAGS - save_CPPFLAGS=$CPPFLAGS +for i in $ICONV_LOOK_DIRS ; do + + save_LIBS="$LIBS" + save_LDFLAGS="$LDFLAGS" + save_CPPFLAGS="$CPPFLAGS" + + iconv_current_LIBS="" + iconv_current_LDFLAGS="" + iconv_current_CPPFLAGS="" + ICONV_FOUND="no" unset libext - CPPFLAGS="$CPPFLAGS -I$i/include" + dnl This is here to handle -withval stuff for --with-libiconv dnl Perhaps we should always add a -L + CPPFLAGS="$save_CPPFLAGS -I$i/include" dnl Check lib and lib32 library variants to cater for IRIX ABI-specific dnl installation paths. This gets a little tricky since we might have iconv @@ -2388,37 +2394,37 @@ dnl For IA64 HPUX systems, the libs are for l in "lib32" "lib" "lib/hpux32"; do if test -d "$i/$l" ; then LDFLAGS="$save_LDFLAGS -L$i/$l" - LIBS= - export LDFLAGS LIBS CPPFLAGS + LIBS= + export LDFLAGS LIBS CPPFLAGS dnl Try to find iconv(3) jm_ICONV($i/$l) if test x"$ICONV_FOUND" = "xyes" ; then - libext="$l" - break; - fi + libext="$l" + break + fi fi done if test x"$ICONV_FOUND" = "xyes" ; then - LDFLAGS=$save_LDFLAGS - LIB_ADD_DIR(LDFLAGS, "$i/$libext") - CFLAGS_ADD_DIR(CPPFLAGS, "$i/include") - LIBS="$save_LIBS" - ICONV_LOCATION=$i - export LDFLAGS LIBS CPPFLAGS -dnl Now, check for a working iconv ... we want to do it here because -dnl there might be a working iconv further down the list of LOOK_DIRS + iconv_current_LDFLAGS="-L$i/$libext" + iconv_current_CPPFLAGS="-I$i/include" - ############ - # check for iconv in libc - ic_save_LIBS="$LIBS" - if test x"$ICONV_PATH_SPEC" = "xyes" ; then - LIBS="$LIBS -L$ICONV_LOCATION/$libext" - fi if test x"$jm_cv_lib_iconv" != x; then - LIBS="$LIBS -l$jm_cv_lib_iconv" + iconv_current_LIBS="$LIBS -l$jm_cv_lib_iconv" + else + # We found iconv in libc. + iconv_current_LIBS="" fi -dnl AC_CACHE_CHECK([for working iconv],samba_cv_HAVE_NATIVE_ICONV,[ + + fi + + if test x"$ICONV_FOUND" = "xyes" ; then + + LDFLAGS="$save_LDFLAGS $iconv_current_LDFLAGS" + CPPFLAGS="$save_CPPFLAGS $iconv_current_CPPFLAGS" + LIBS="$save_LIBS $iconv_current_LIBS" + export LDFLAGS LIBS CPPFLAGS + default_dos_charset=no default_display_charset=no default_unix_charset=no @@ -2426,28 +2432,30 @@ dnl AC_CACHE_CHECK([for working i # check for default dos charset name for j in CP850 IBM850 ; do rjs_CHARSET($j) - if test x"$ICONV_CHARSET" = x"$j"; then - default_dos_charset="\"$j\"" + default_dos_charset="$ICONV_CHARSET" + if test x"$default_dos_charset" = x"$j"; then break fi done + # check for default display charset name for j in ASCII 646 ; do rjs_CHARSET($j) - if test x"$ICONV_CHARSET" = x"$j"; then - default_display_charset="\"$j\"" + default_display_charset="$ICONV_CHARSET" + if test x"$default_display_charset" = x"$j"; then break fi done + # check for default unix charset name for j in UTF-8 UTF8 ; do rjs_CHARSET($j) - if test x"$ICONV_CHARSET" = x"$j"; then - default_unix_charset="\"$j\"" + default_unix_charset="$ICONV_CHARSET" + if test x"$default_unix_charset" = x"$j"; then break fi done - + if test "$default_dos_charset" != "no" -a \ "$default_dos_charset" != "cross" -a \ "$default_display_charset" != "no" -a \ @@ -2456,37 +2464,62 @@ dnl AC_CACHE_CHECK([for working i "$default_unix_charset" != "cross" then samba_cv_HAVE_NATIVE_ICONV=yes - else if test "$default_dos_charset" = "cross" -o \ + else + if test "$default_dos_charset" = "cross" -o \ "$default_display_charset" = "cross" -o \ "$default_unix_charset" = "cross" - then - samba_cv_HAVE_NATIVE_ICONV=cross - else - samba_cv_HAVE_NATIVE_ICONV=no - fi + then + samba_cv_HAVE_NATIVE_ICONV=cross + else + samba_cv_HAVE_NATIVE_ICONV=no + fi fi -dnl ]) - LIBS="$ic_save_LIBS" - if test x"$samba_cv_HAVE_NATIVE_ICONV" = x"yes"; then - CPPFLAGS=$save_CPPFLAGS - LDFLAGS=$save_LDFLAGS - LIBS=$save_LIBS - if test x"$jm_cv_lib_iconv" != x; then - LIBS="$LIBS -l$jm_cv_lib_iconv" - fi - dnl Add the flags we need to CPPFLAGS and LDFLAGS - CFLAGS_ADD_DIR(CPPFLAGS, "$i/include") - LIB_ADD_DIR(LDFLAGS, "$i/$libext") - export CPPFLAGS - AC_DEFINE(HAVE_NATIVE_ICONV,1,[Whether to use native iconv]) - AC_DEFINE_UNQUOTED(DEFAULT_DOS_CHARSET,$default_dos_charset,[Default dos charset name]) - AC_DEFINE_UNQUOTED(DEFAULT_DISPLAY_CHARSET,$default_display_charset,[Default display charset name]) - AC_DEFINE_UNQUOTED(DEFAULT_UNIX_CHARSET,$default_unix_charset,[Default unix charset name]) + # At this point, we have a libiconv candidate. We know that + # we have the right headers and libraries, but we don't know + # whether it does the conversions we want. We can't test this + # because we are cross-compiling. This is not necessarily a big + # deal, since we can't guarantee that the results we get now will + # match the results we get at runtime anyway. + if test x"$samba_cv_HAVE_NATIVE_ICONV" = x"cross" ; then + default_dos_charset="CP850" + default_display_charset="ASCII" + default_unix_charset="UTF-8" + samba_cv_HAVE_NATIVE_ICONV=yes + AC_MSG_WARN(assuming the libiconv in $iconv_current_LDFLAGS can convert) + AC_MSG_WARN([$default_dos_charset, $default_display_charset and $default_unix_charset to UCS-16LE]) + fi + + if test x"$samba_cv_HAVE_NATIVE_ICONV" = x"yes" ; then + + CPPFLAGS=$save_CPPFLAGS + LDFLAGS=$save_LDFLAGS + LIBS=$save_LIBS + + if test x"$iconv_current_LIBS" != x; then + LIBS="$LIBS $iconv_current_LIBS" + fi + + # Add the flags we need to CPPFLAGS and LDFLAGS + CPPFLAGS="$CPPFLAGS $iconv_current_CPPFLAGS" + LDFLAGS="$LDFLAGS $iconv_current_LDFLAGS" + + # Turn the #defines into string literals + default_dos_charset="\"$default_dos_charset\"" + default_display_charset="\"$default_display_charset\"" + default_unix_charset="\"$default_unix_charset\"" + + AC_DEFINE(HAVE_NATIVE_ICONV,1,[Whether to use native iconv]) + AC_DEFINE_UNQUOTED(DEFAULT_DOS_CHARSET,$default_dos_charset,[Default dos charset name]) + AC_DEFINE_UNQUOTED(DEFAULT_DISPLAY_CHARSET,$default_display_charset,[Default display charset name]) + AC_DEFINE_UNQUOTED(DEFAULT_UNIX_CHARSET,$default_unix_charset,[Default unix charset name]) + break fi + dnl We didn't find a working iconv, so keep going fi + dnl We only need to clean these up here for the next pass through the loop CPPFLAGS=$save_CPPFLAGS LDFLAGS=$save_LDFLAGS