[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Building optional shared libraries
From: |
Bill Moseley |
Subject: |
Re: Building optional shared libraries |
Date: |
Mon, 08 Oct 2001 17:07:35 -0700 |
At 07:55 PM 10/08/01 -0400, Steven G. Johnson wrote:
>I think that most of us agree that the "standard" approach is to tell the
>user to use LDFLAGS and CPPFLAGS to tell configure to look in nonstandard
>locations for libraries/headers, e.g.:
>
> ./configure LDFLAGS=-L/foo/lib CPPFLAGS=-I/foo/include
I'm now using:
./configure --with-libxml2=[prefix]
And then I call a utility provided by libxml2 library called xml2-config
that can be queried for cflags and libx. I've attached this below, as I'm
way new to autoconf, and a review would be helpful (and educational).
>This is mentioned in the './configure --help' message. Steve Robbins
>created a nice macro to make this a bit easier:
>
http://www.gnu.org/software/ac-archive/Installed_Packages/smr_with_build_pat
h.html
>(i.e. *don't* do --with-libfoo=<dir>)
Oh, so that's what I'm doing. What's wrong with --with-libfoo?
Actually, it seems necessary in my situation, because the library is *not*
linked in by default. --with-libxml2 enables it.
>For shared libraries, I would argue that the user should either:
>
>1) Install it properly so that it can be shared by all programs...i.e.
>tell the linker where to look (via LD_RUN_PATH or /etc/ld.so.conf).
Yes, seems like a number of our users (this is for Swish-e) don't have root
access, so I'm currently saying use a prefix of, for example, $HOME/local
when building and installing the 3rd party library, then for building swish-e
./configure --with-libxml2=$HOME/local
export LD_RUN_PATH=$HOME/local/lib
make
>2) Configure it with --disable-shared --enable-static and avoid shared
>libraries entirely.
>
>If the user is just compiling the library for use in your program, and
>doesn't want to share it globally, I would recommend (2).
Ok, that's probably safer as they might forget and rm the locally installed
library.
Thank you very much for responding.
Now, this is probably more work than is needed. Since this is probably a
very common problem, I wouldn't be surprised if the was a macro to do this
that I just don't know about.
The library is not linked in by default.
dnl Optional building with libxml2
dnl Probably should be 2.4.5 + patches
LIBXML_REQUIRED_VERSION=2.4.3
AC_ARG_WITH(libxml2,[\
--with-libxml2[=DIR] use libxml2 in DIR],,withval=no)
if test "$withval" = "no"; then
AC_MSG_RESULT([Not building with libxml2 - use --with-libxml2 to enable])
else
if test "$withval" != "yes"; then
XML2_CONFIG_PATH="$withval/bin"
else
XML2_CONFIG_PATH=$PATH
fi
XML2_CONFIG="no"
AC_PATH_PROG(XML2_CONFIG, xml2-config,"no", $XML2_CONFIG_PATH)
if test "$XML2_CONFIG" = "no"; then
AC_MSG_ERROR(Could not find xml2-config in '$XML2_CONFIG_PATH': check
ftp://xmlsoft.org/.)
fi
dnl Much of this was copied from libxslt's configure.in
dnl
dnl find libxml
dnl
AC_SUBST(LIBXML_REQUIRED_VERSION)
AC_MSG_CHECKING(for libxml libraries >= $LIBXML_REQUIRED_VERSION)
AC_DEFUN(VERSION_TO_NUMBER,
[`$1 | sed -e 's/libxml //' | awk 'BEGIN { FS = "."; } { printf "%d",
([$]1 * 1000 + [$]2) * 1000 + [$]3;}'`])
dnl
dnl test version and init our variables
dnl
vers=VERSION_TO_NUMBER($XML2_CONFIG --version)
if test "$vers" -ge VERSION_TO_NUMBER(echo $LIBXML_REQUIRED_VERSION);then
LIBXML2_LIB="`$XML2_CONFIG --libs`"
LIBXML2_CFLAGS="`$XML2_CONFIG --cflags`"
AC_MSG_RESULT(found version `$XML2_CONFIG --version`)
else
AC_MSG_ERROR(You need at least libxml2 $LIBXML_REQUIRED_VERSION for
this version of swish)
fi
AC_DEFINE(HAVE_LIBXML2)
AC_MSG_RESULT([** Enabling libxml2 support -- good choice! **])
LIBXML2_OBJS="parser.o"
AC_SUBST(LIBXML2_OBJS)
AC_SUBST(LIBXML2_LIB)
AC_SUBST(LIBXML2_CFLAGS)
fi
Bill Moseley
mailto:address@hidden