D&C GLug - Home Page

[ Date Index ] [ Thread Index ] [ <= Previous by date / thread ] [ Next by date / thread => ]

Re: [LUG] Autoconf help

 

On Wed, 2008-03-26 at 13:16 +0000, Robin Cornelius wrote:

> I'm doing a test for libxml2 such so this can be enabled with a 
> --with-shared-libxml2 option....
> 
> AC_ARG_WITH([shared-libxml],[  --with-shared-libxml=[location]  Use 
> system shared libxml2 as xmlparser],[
> if test "x$withval" = "xyes"; then
>     withval=
> fi
> LIBXML2_LOCATION=$withval;
> 
> AC_CHECK_HEADERS([libxml/parser.h], [], [AC_MSG_ERROR([Sorry 
> libxml/parser.h not found, is libxmlrpc and libxmlrpc-dev installed?])],[])

That seems a little restrictive - it would be easier to use pkg-config
IMHO (it deals with extra directories in the path). Also, this check is
run no matter what - should it be inside the conditional ?

> AC_DEFINE([HAVE_LIBXML])
> HAVE_LIBXML=1;
> ],
> [])
> 
> 
> The code is a bit rough but the question is:-
> 
> if a with option specifies a location how to i use this. I am catching 
> the $withval but on Debian libxml/parser.h is infact under 
> /usr/include/libxml2/libxml/parser.h
> 
> I can force libxml2 to be found by specifying 
> CFLAGS=-I/usr/include/libxml2 on the command line when i call configure 
> i get a warning about the preprocessor not being able to find parser.h 
> but the compiler is ok so it continues and builds ok. Is this the 
> correct way to build in this situation?

No. :-)

        LIBXML2_REQUIRED=2.5.10
        PKG_CHECK_MODULES(LIBXML2, libxml-2.0 >= $LIBXML2_REQUIRED)
        LIBXML_VERSION=`xml2-config --version`
        AC_SUBST(LIBXML2_CFLAGS)
        AC_SUBST(LIBXML2_LIBS)


> what should i do with $withval in general (or in this case 
> $LIBXML_LOCATION) should something like this happen :-

See the QOF source where conditionals are used around libxml2 to
determine if the build should use the (hefty) libxml2 or the (tiny)
libsqlite0:


AC_ARG_ENABLE(embedded,
        [  --enable-embedded       Enable the SQLite backend for embedded systems
                          and DISABLE libgdasql and the QSF XML backend. (no)],
        [case "${enableval}" in
                no) embedded="no" ;;
                yes) embedded="yes" ;;
                *) AC_MSG_ERROR(bad value ${enableval} for --enable-embedded) ;;
                esac])

if test "$embedded" = "yes"; then
        PKG_CHECK_MODULES(SQLITE, sqlite >= 2.8.0)
        AC_SUBST(SQLITE_LIBS)
        AC_SUBST(SQLITE_CFLAGS)
        backend="sqlite"
else
        LIBXML2_REQUIRED=2.5.10
        PKG_CHECK_MODULES(LIBXML2, libxml-2.0 >= $LIBXML2_REQUIRED)
        LIBXML_VERSION=`xml2-config --version`
        AC_SUBST(LIBXML2_CFLAGS)
        AC_SUBST(LIBXML2_LIBS)
        backend="libxml2 == $LIBXML_VERSION"
fi

AM_CONDITIONAL(EMBEDDED, [test "$embedded" = "yes"])

sqlite="yes"
AC_ARG_ENABLE(sqlite,
  [  --disable-sqlite        Disable the SQLite backend module.],
  [case "${enableval}" in
                no) sqlite="no" ;;
                yes) sqlite="yes" ;;
                *) AC_MSG_ERROR(bad value ${enableval} for --disable-sqlite) ;;
                esac])

if test "$embedded" != "yes"; then
        if test "$sqlite" = "yes"; then
                SQLITE_REQUIRED=2.8.0
                PKG_CHECK_MODULES(SQLITE, sqlite >= $SQLITE_REQUIRED)
                AC_SUBST(SQLITE_LIBS)
                AC_SUBST(SQLITE_CFLAGS)
                backend2="sqlite"
        fi
fi

AM_CONDITIONAL(USE_SQLITE, [test "$sqlite" = "yes"])


> Which is ok if you move things to /usr/local/ or 
> /home/robin/tests/include and /home/robin/tests/lib but it still breaks 
> in this particular Debian case where the headers are in an additional 
> subfolder. 

pkg-config is the tool for the job here - it copes with all these
vagaries because the pc file encodes the relevant directory on a
system-specific basis.

-- 


Neil Williams
=============
http://www.data-freedom.org/
http://www.nosoftwarepatents.com/
http://www.linux.codehelp.co.uk/


Attachment: signature.asc
Description: This is a digitally signed message part

-- 
The Mailing List for the Devon & Cornwall LUG
http://mailman.dclug.org.uk/listinfo/list
FAQ: http://www.dcglug.org.uk/linux_adm/list-faq.html