[xml] Generating a correct xml2-config for use with --libs



Hi,

Patches which removes the unnecessary declaration of dependencies on libraries which libxml2 depends upon itself, when generating the xml2-config script.

Justification

Applications should only depend on those libraries which they need to link to.

Problem

xml2-config lists all the libraries which libxml2 itself depends on, when xml2-config is invoked:

e.g.

$ xml2-config --libs
-L/usr/local/libxml/sparc/lib -R/usr/local/libxml/sparc/lib -lxml2 -lz -lpthread -lm -lsocket -lnsl

This is wrong, the following is correct:

$ xml2-config --libs
-L/usr/local/libxml/sparc/lib -R/usr/local/libxml/sparc/lib -lxml2

This creates unnecesary dependencies on libraries which can easily be avoided.

Fix

Define a new autoconf macro (XML_LIB) in configure.in and set this to be -lxml2. Modify XML_LIBS to use this new macro and modify xml2-config.in to also use this new macro in place of the existing XML_LIBS.

Gary

PATCH

bash-2.03# diff -c configure.in.orig configure.in
*** configure.in.orig    Thu Jun 13 11:46:28 2002
--- configure.in    Thu Jun 13 11:44:48 2002
***************
*** 514,520 ****
         LDFLAGS="${_ldflags}"])]))
 fi
 M_LIBS="-lm"
! XML_LIBS="-lxml2 $Z_LIBS $THREAD_LIBS $ICONV_LIBS $M_LIBS $LIBS"
 AC_SUBST(WITH_ICONV)

AC_ARG_WITH(schemas, [ --with-schemas Add experimental Schemas support (off)])
--- 514,521 ----
         LDFLAGS="${_ldflags}"])]))
 fi
 M_LIBS="-lm"
! XML_LIB="-lxml2"
! XML_LIBS="$XML_LIB $Z_LIBS $THREAD_LIBS $ICONV_LIBS $M_LIBS $LIBS"
 AC_SUBST(WITH_ICONV)

AC_ARG_WITH(schemas, [ --with-schemas Add experimental Schemas support (off)])
***************
*** 554,559 ****
--- 555,561 ----
 AC_SUBST(XML_CFLAGS)

 AC_SUBST(XML_LIBDIR)
+ AC_SUBST(XML_LIB)
 AC_SUBST(XML_LIBS)
 AC_SUBST(ICONV_LIBS)
 AC_SUBST(XML_INCLUDEDIR)

bash-2.03# diff -c xml2-config.in.orig xml2-config.in
*** xml2-config.in.orig    Thu Jun 13 11:39:24 2002
--- xml2-config.in    Thu Jun 13 11:47:20 2002
***************
*** 60,66 ****
            ;;

     --libs)
!            echo @XML_LIBDIR@ @XML_LIBS@
            ;;

     *)
--- 60,66 ----
            ;;

     --libs)
!            echo @XML_LIBDIR@ @XML_LIB@
            ;;

     *)





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