Bug 26830 - Add search for libiconv non-default directory
Summary: Add search for libiconv non-default directory
Status: RESOLVED FIXED
Alias: None
Product: fontconfig
Classification: Unclassified
Component: library (show other bugs)
Version: 2_1
Hardware: Other All
: medium normal
Assignee: Akira TAGOH
QA Contact: Behdad Esfahbod
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-03-01 19:55 UTC by suzuki toshiya
Modified: 2012-04-10 02:48 UTC (History)
2 users (show)

See Also:
i915 platform:
i915 features:


Attachments
Add search for libiconv in user-defined directory (3.00 KB, patch)
2010-03-01 19:55 UTC, suzuki toshiya
Details | Splinter Review

Description suzuki toshiya 2010-03-01 19:55:52 UTC
Created attachment 33674 [details] [review]
Add search for libiconv in user-defined directory

Current configure checks the availability of libiconv, but
has no option to specify the location of libiconv. It might
be better to provide such options. I've tried to use iconv.m4
included in gettext (written by Bruno Haible), but it didn't
work well.

diff --git a/configure.in b/configure.in
index 365abff..2b6761f 100644
--- a/configure.in
+++ b/configure.in
@@ -176,15 +176,64 @@ AC_CHECK_FUNCS([geteuid getuid link memmove memset mkstemp strchr strrchr strtol
 #
 # Checks for iconv
 #
-AC_MSG_CHECKING([for a usable iconv])
-ICONV_LIBS=""
-AC_TRY_LINK([#include <iconv.h>],
-           [iconv_open ("from", "to");],
-           [use_iconv=1],
-           [use_iconv=0])
-if test x$use_iconv = x1; then
+AC_ARG_WITH(libiconv,          [  --with-libiconv=DIR              Use libiconv in DIR],
+            libiconv_prefix=$withval, libiconv_prefix=auto)
+AC_ARG_WITH(libiconv-includes, [  --with-libiconv-includes=DIR     Use libiconv includes in DIR],
+            libiconv_includes=$withval, libiconv_includes=auto)
+AC_ARG_WITH(libiconv-lib,      [  --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
+  AC_MSG_CHECKING([libiconv in specified directory])
+
+  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
+    AC_MSG_RESULT([not found])
+  fi
+
+  if test "${libiconv_lib}" != auto # -a -r ${libiconv_libs}/libiconv*
+  then
+    libiconv_lib="-L${libiconv_lib} -liconv"
+  elif test "${libiconv_prefix}" != auto # -a -r ${libiconv_prefix}/lib/libiconv*
+  then
+    libiconv_lib="-L${libiconv_prefix}/lib -liconv"
+  else
+    AC_MSG_RESULT([not found])
+  fi
+
+  CFLAGS_save="${CFLAGS}" 
+  LIBS_save="${LIBS}"
+  CFLAGS="${CFLAGS} ${libiconv_cflags}"
+  LIBS="${LIBS} ${libiconv_lib}"
+  
+  AC_TRY_LINK([#include <iconv.h>],
+             [iconv_open ("from", "to");],
+             [AC_MSG_RESULT([ok])
+               use_iconv=1],
+             [AC_MSG_RESULT([not found])
+               use_iconv=0])
+  ICONV_CFLAGS="${libiconv_cflags}"
+  ICONV_LIBS="${libiconv_lib}"
+fi
+
+if test "x${ICONV_CFLAGS}" = "x" -a "x${ICONV_LIBS}" = "x"
+then
+  AC_MSG_CHECKING([for a usable iconv])
+  ICONV_LIBS=""
+  AC_TRY_LINK([#include <iconv.h>],
+             [iconv_open ("from", "to");],
+             [use_iconv=1],
+             [use_iconv=0])
+  if test x$use_iconv = x1; then
        AC_MSG_RESULT([libc])
-else
+  else
        # try using libiconv
        fontconfig_save_libs="$LIBS"
        LIBS="$LIBS -liconv"
@@ -202,7 +251,10 @@ else
        fi
 
        LIBS="$fontconfig_save_libs"
+  fi
 fi
+
+AC_SUBST(ICONV_CFLAGS)
 AC_SUBST(ICONV_LIBS)
 AC_DEFINE_UNQUOTED(USE_ICONV,$use_iconv,[Use iconv.])
 
diff --git a/src/Makefile.am b/src/Makefile.am
index 9110cde..3645ae9 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -70,6 +70,7 @@ endif
 INCLUDES =                                             \
        -I$(top_srcdir)                                 \
        -I$(top_srcdir)/src                             \
+       $(ICONV_CFLAGS)                                 \
        $(FREETYPE_CFLAGS)                              \
        $(LIBXML2_CFLAGS)                               \
        $(EXPAT_CFLAGS)                                 \
Comment 1 Akira TAGOH 2012-04-10 02:48:49 UTC
reworked and fixed in 2589207c.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.