Re: [xml] Using libiconv



On Tue, Jul 03, 2001 at 10:40:50AM -0400, Daniel Veillard wrote:
On Tue, Jul 03, 2001 at 09:13:25AM -0500, xml thewrittenword com wrote:
Then how about we add --with-iconv=DIR which allows you to specify the
parent include/lib directory for iconv? All this would really do is
add DIR/include to $CPPFLAGS and DIR/lib to $LDFLAGS.

  Albert, this sounds the Right Way (TM), would you be kind enough
to provide such a patch ?

Ok, how's the following? I tested on Solaris 7/SPARC and it seems to
work fine (with system iconv and libiconv 1.6.1).

Should we change the --with-iconv description in ./configure --help?

Note my previous Makefile.am patch:
  -libxml2_la_LIBADD = @Z_LIBS@ -lm
  +libxml2_la_LIBADD = @Z_LIBS@ $(ICONV_LIBS) -lm
is still needed.

-- 
albert chin (china thewrittenword com)

-- snip snip
--- configure.in.orig   Tue Jul  3 09:49:05 2001
+++ configure.in        Tue Jul  3 10:28:26 2001
@@ -375,21 +363,45 @@
 AC_SUBST(WITH_XINCLUDE)
 AC_SUBST(XINCLUDE_OBJ)
 
-AC_ARG_WITH(iconv, [  --with-iconv            Add the ICONV support (on)])
+WITH_ICONV=0
+AC_ARG_WITH(iconv, [  --with-iconv[=DIR]      Add ICONV support (on)])
 if test "$with_iconv" = "no" ; then
     echo Disabling ICONV support
-    WITH_ICONV=0
 else
-    AC_CHECK_HEADER(iconv.h, 
-       AC_CHECK_FUNC(iconv, ,
-           AC_CHECK_LIB(iconv, iconv, ICONV_LIBS="-liconv")))
-    if test "$have_iconv" != "" ; then
-        echo Iconv support not found
-        WITH_ICONV=0
-    else
-        WITH_ICONV=1
+    if test "$with_iconv" != "yes" ; then
+       CPPFLAGS="${CPPFLAGS} -I$with_iconv/include"
+       ICONV_LIBS="-L$with_iconv/lib"
     fi
-fi  
+
+    AC_CHECK_HEADER(iconv.h,
+       AC_MSG_CHECKING(for iconv)
+       AC_TRY_LINK([#include <stdlib.h>
+#include <iconv.h>],[
+iconv_t cd = iconv_open ("","");
+iconv (cd, NULL, NULL, NULL, NULL);],[
+           AC_MSG_RESULT(yes)
+           WITH_ICONV=1],[
+           AC_MSG_RESULT(no)
+           AC_MSG_CHECKING(for iconv in -liconv)
+
+           _ldflags="${LDFLAGS}"
+           _libs="${LIBS}"
+           LDFLAGS="${LDFLAGS} ${ICONV_LIBS}"
+           LIBS="${LIBS} -liconv"
+
+           AC_TRY_LINK([#include <stdlib.h>
+#include <iconv.h>],[
+iconv_t cd = iconv_open ("","");
+iconv (cd, NULL, NULL, NULL, NULL);],[
+               AC_MSG_RESULT(yes)
+               WITH_ICONV=1
+               ICONV_LIBS="${ICONV_LIBS} -liconv"
+               LIBS="${_libs}"
+               LDFLAGS="${_ldflags}"],[
+               AC_MSG_RESULT(no)
+               LIBS="${_libs}"
+               LDFLAGS="${_ldflags}"])]))
+fi
 XML_LIBS="-lxml2 $Z_LIBS $ICONV_LIBS -lm $LIBS"
 AC_SUBST(WITH_ICONV)
 




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]