mirror of
https://github.com/samba-team/samba.git
synced 2025-01-13 13:18:06 +03:00
r15568: Simplify detection of iconv libraries a fair bit and fix it to
work on FreeBSD. Based very loosely on a patch by Timur Bakevey Fixes #3688
This commit is contained in:
parent
8d794e5911
commit
ea7b28572b
source
92
source/aclocal.m4
vendored
92
source/aclocal.m4
vendored
@ -222,98 +222,6 @@ AC_DEFUN(LIB_REMOVE_USR_LIB,[
|
|||||||
$1=[$]ac_new_flags
|
$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
|
|
||||||
])
|
|
||||||
|
|
||||||
sinclude(build/m4/public.m4)
|
sinclude(build/m4/public.m4)
|
||||||
sinclude(build/m4/core.m4)
|
sinclude(build/m4/core.m4)
|
||||||
sinclude(build/m4/ax_cflags_gcc_option.m4)
|
sinclude(build/m4/ax_cflags_gcc_option.m4)
|
||||||
|
@ -20,14 +20,12 @@
|
|||||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef HAVE_NATIVE_ICONV
|
#ifdef HAVE_ICONV_H
|
||||||
#ifdef HAVE_ICONV
|
|
||||||
#include <iconv.h>
|
#include <iconv.h>
|
||||||
#endif
|
#endif
|
||||||
#ifdef HAVE_GICONV
|
#ifdef HAVE_GICONV_H
|
||||||
#include <giconv.h>
|
#include <giconv.h>
|
||||||
#endif
|
#endif
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef HAVE_CTYPE_H
|
#ifdef HAVE_CTYPE_H
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
@ -1,6 +1,47 @@
|
|||||||
dnl # ICONV/CHARSET subsystem
|
dnl SMB_CHECK_ICONV(action-if-found,action-if-not-found)
|
||||||
|
AC_DEFUN(SMB_CHECK_ICONV,[
|
||||||
|
AC_CHECK_HEADERS(iconv.h giconv.h)
|
||||||
|
|
||||||
ICONV_LOCATION=standard
|
AC_TRY_RUN([#include <stdlib.h>
|
||||||
|
#ifdef HAVE_GICONV_H
|
||||||
|
#include <giconv.h>
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_ICONV_H
|
||||||
|
#include <iconv.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
iconv_t cd = iconv_open("ASCII","UCS-2LE");
|
||||||
|
if (cd == 0 || cd == (iconv_t)-1) return -1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
],[$1],[$2])
|
||||||
|
])
|
||||||
|
|
||||||
|
dnl SMB_CHECK_ICONV_DIR(dir,action-if-found,action-if-not-found)
|
||||||
|
AC_DEFUN(SMB_CHECK_ICONV_DIR,
|
||||||
|
[
|
||||||
|
if test -f "$1/include/iconv.h" -o -f "$1/include/giconv.h"; then
|
||||||
|
CPPFLAGS="-I$1/include"
|
||||||
|
LDFLAGS="-L$1/lib"
|
||||||
|
LIBS=-liconv
|
||||||
|
|
||||||
|
SMB_CHECK_ICONV([$2],
|
||||||
|
[
|
||||||
|
LIBS=-lgiconv
|
||||||
|
SMB_CHECK_ICONV([$2],[$3])
|
||||||
|
])
|
||||||
|
|
||||||
|
CPPFLAGS=$save_CPPFLAGS
|
||||||
|
LDFLAGS=$save_LDFLAGS
|
||||||
|
LIBS=$save_LIBS
|
||||||
|
else
|
||||||
|
$2
|
||||||
|
fi
|
||||||
|
])
|
||||||
|
|
||||||
|
ICONV_FOUND=no
|
||||||
LOOK_DIRS="/usr /usr/local /sw"
|
LOOK_DIRS="/usr /usr/local /sw"
|
||||||
AC_ARG_WITH(libiconv,
|
AC_ARG_WITH(libiconv,
|
||||||
[ --with-libiconv=BASEDIR Use libiconv in BASEDIR/lib and BASEDIR/include (default=auto) ],
|
[ --with-libiconv=BASEDIR Use libiconv in BASEDIR/lib and BASEDIR/include (default=auto) ],
|
||||||
@ -9,57 +50,40 @@ AC_ARG_WITH(libiconv,
|
|||||||
AC_MSG_ERROR(I won't take no for an answer)
|
AC_MSG_ERROR(I won't take no for an answer)
|
||||||
else
|
else
|
||||||
if test "$withval" != "yes" ; then
|
if test "$withval" != "yes" ; then
|
||||||
LOOK_DIRS="$withval $LOOK_DIRS"
|
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])])
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
])
|
])
|
||||||
|
|
||||||
ICONV_FOUND="no"
|
if test x$ICONV_FOUND = xno; then
|
||||||
for i in $LOOK_DIRS ; do
|
SMB_CHECK_ICONV([ICONV_FOUND=yes])
|
||||||
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)
|
|
||||||
|
|
||||||
TMP_ICONV_LIBS="$LIBS"
|
|
||||||
|
|
||||||
CPPFLAGS=$save_CPPFLAGS
|
|
||||||
LDFLAGS=$save_LDFLAGS
|
|
||||||
LIBS=$save_LIBS
|
|
||||||
export LDFLAGS LIBS CPPFLAGS
|
|
||||||
|
|
||||||
if test -n "$ICONV_FOUND" ; then
|
|
||||||
LIB_ADD_DIR(ICONV_LDFLAGS, $i/lib)
|
|
||||||
CFLAGS_ADD_DIR(ICONV_CPPFLAGS, $i/include)
|
|
||||||
ICONV_LIBS="$TMP_ICONV_LIBS"
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
############
|
|
||||||
# check for iconv in libc
|
|
||||||
AC_CACHE_CHECK([for working iconv],samba_cv_HAVE_NATIVE_ICONV,[
|
|
||||||
AC_TRY_RUN([
|
|
||||||
#include <iconv.h>
|
|
||||||
main() {
|
|
||||||
iconv_t cd = iconv_open("ASCII", "UCS-2LE");
|
|
||||||
if (cd == 0 || cd == (iconv_t)-1) return -1;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
],
|
|
||||||
samba_cv_HAVE_NATIVE_ICONV=yes,samba_cv_HAVE_NATIVE_ICONV=no,samba_cv_HAVE_NATIVE_ICONV=cross)])
|
|
||||||
if test x"$samba_cv_HAVE_NATIVE_ICONV" = x"yes"; then
|
|
||||||
AC_DEFINE(HAVE_NATIVE_ICONV,1,[Whether to use native iconv])
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if test x"$ICONV_FOUND" = x"no" -o x"$samba_cv_HAVE_NATIVE_ICONV" != x"yes" ; then
|
for i in $LOOK_DIRS ; do
|
||||||
|
if test x$ICONV_FOUND = xyes; then
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
|
||||||
|
SMB_CHECK_ICONV_DIR($withval, [
|
||||||
|
ICONV_FOUND=yes;
|
||||||
|
ICONV_CPPFLAGS="$CPPFLAGS"
|
||||||
|
ICONV_LIBS="$LIBS"
|
||||||
|
ICONV_LDFLAGS="$LDFLAGS"
|
||||||
|
], [])
|
||||||
|
done
|
||||||
|
|
||||||
|
if test x"$ICONV_FOUND" = x"no"; then
|
||||||
AC_MSG_WARN([Sufficient support for iconv function was not found.
|
AC_MSG_WARN([Sufficient support for iconv function was not found.
|
||||||
Install libiconv from http://freshmeat.net/projects/libiconv/ for better charset compatibility!])
|
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)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
SMB_EXT_LIB(ICONV,[${ICONV_LIBS}],[${ICONV_CFLAGS}],[${ICONV_CPPFLAGS}],[${ICONV_LDFLAGS}])
|
SMB_EXT_LIB(ICONV,[${ICONV_LIBS}],[${ICONV_CFLAGS}],[${ICONV_CPPFLAGS}],[${ICONV_LDFLAGS}])
|
||||||
|
Loading…
Reference in New Issue
Block a user