Bug 26830 - Add search for libiconv non-default directory

Add --with-libiconv, --with-libiconv-includes and --with-libiconv-lib
to specify the directory where libiconv might be installed.
This commit is contained in:
Akira TAGOH 2012-04-10 18:34:11 +09:00
parent ddefa5021f
commit 2589207cfd
2 changed files with 62 additions and 22 deletions

View File

@ -138,33 +138,72 @@ AC_CHECK_FUNCS([geteuid getuid link memmove memset mkstemp strchr strrchr strtol
# #
# Checks for iconv # Checks for iconv
# #
AC_ARG_WITH(libiconv,
[AC_HELP_STRING([--with-libiconv=DIR],
[Use libiconv in DIR])],
[libiconv_prefix=$withval],
[libiconv_prefix=auto])
AC_ARG_WITH(libiconv-includes,
[AC_HELP_STRING([--with-libiconv-includes=DIR],
[Use libiconv includes in DIR])],
[libiconv_includes=$withval],
[libiconv_includes=auto])
AC_ARG_WITH(libiconv-lib,
[AC_HELP_STRING([--with-libiconv-lib=DIR],
[Use libiconv library in DIR])],
[libiconv_lib=$withval],
[libiconv_lib=auto])
# if none of libiconv,libiconv-includes,libiconv-libs are specified
if test "$libiconv_prefix" != "auto" -o "$libiconv_includes" != "auto" -o "$libiconv_lib" != "auto"; then
if test "$libiconv_includes" != "auto" -a -r ${libiconv_includes}/iconv.h; then
libiconv_cflags="-I${libiconv_includes}"
elif test "$libiconv_prefix" != "auto" -a -r ${libiconv_prefix}/include/iconv.h; then
libiconv_cflags="-I${libiconv_prefix}/include"
else
libiconv_cflags=""
fi
if test "$libiconv_lib" != "auto"; then
libiconv_lib="-L${libiconv_lib} -liconv"
elif test "$libiconv_prefix" != "auto"; then
libiconv_lib="-L${libiconv_prefix}/lib -liconv"
elif test "x$libiconv_cflags" != "x"; then
libiconv_lib="-liconv"
else
libiconv_lib=""
fi
fi
use_iconv=0
AC_MSG_CHECKING([for a usable iconv]) AC_MSG_CHECKING([for a usable iconv])
ICONV_LIBS="" if test "x$libiconv_cflags" != "x" -o "x$libiconv_lib" != "x"; then
AC_TRY_LINK([#include <iconv.h>], iconvsaved_CFLAGS="$CFLAGS"
[iconv_open ("from", "to");], iconvsaved_LIBS="$LIBS"
[use_iconv=1], CFLAGS="$CFLAGS $libiconv_cflags"
[use_iconv=0]) LIBS="$LIBS $libiconv_lib"
if test x$use_iconv = x1; then
AC_MSG_RESULT([libc])
else
# try using libiconv
fontconfig_save_libs="$LIBS"
LIBS="$LIBS -liconv"
AC_TRY_LINK([#include <iconv.h>], AC_TRY_LINK([#include <iconv.h>],
[iconv_open ("from", "to");], [iconv_open ("from", "to");],
[use_iconv=1], [iconv_type="libiconv"
use_iconv=1],
[use_iconv=0]) [use_iconv=0])
if test x$use_iconv = x1; then CFLAGS="$iconvsaved_CFLAGS"
ICONV_LIBS="-liconv" LIBS="$iconvsaved_LIBS"
AC_MSG_RESULT([libiconv]) ICONV_CFLAGS="$libiconv_cflags"
else ICONV_LIBS="$libiconv_lib"
AC_MSG_RESULT([no]) fi
if test "x$use_iconv" = "x0"; then
AC_TRY_LINK([#include <iconv.h>],
[iconv_open ("from", "to");],
[iconv_type="libc"
use_iconv=1],
[iconv_type="not found"
use_iconv=0])
fi fi
LIBS="$fontconfig_save_libs" AC_MSG_RESULT([$iconv_type])
fi AC_SUBST(ICONV_CFLAGS)
AC_SUBST(ICONV_LIBS) AC_SUBST(ICONV_LIBS)
AC_DEFINE_UNQUOTED(USE_ICONV,$use_iconv,[Use iconv.]) AC_DEFINE_UNQUOTED(USE_ICONV,$use_iconv,[Use iconv.])

View File

@ -71,6 +71,7 @@ INCLUDES = \
-I$(top_srcdir) \ -I$(top_srcdir) \
-I$(top_srcdir)/src \ -I$(top_srcdir)/src \
$(FREETYPE_CFLAGS) \ $(FREETYPE_CFLAGS) \
$(ICONV_CFLAGS) \
$(LIBXML2_CFLAGS) \ $(LIBXML2_CFLAGS) \
$(EXPAT_CFLAGS) \ $(EXPAT_CFLAGS) \
$(WARN_CFLAGS) \ $(WARN_CFLAGS) \