[pacman-dev] [PATCH] RFC: Allow building against internal libarchive

Allan McRae allan at archlinux.org
Wed Sep 29 02:31:37 EDT 2010

The idea behind this patch is to allow putting a libarchive source
folder in the pacman source directory and then build against that
libarchive version.  This is handy for testing pacman out on systems
when libarchive is not available (and you do not want to or unable to
install it for some reason).  It would also allow easy testing of
patches to libarchive and how they affected pacman without touching
your system libarchive.

Currently, the following works:
1) extract the libarchive source in the root of the pacman source and
rename or symlink the folder to be called libarchive.
2) build libarchive using:
	./configure --prefix=$PWD/install
	make install
3) build pacman in the usual way

The pacman build will then link against/use headers from the libarchive
version in ./libarchive/install/{lib,include}. Note that the "make install"
step is necessary to put the needed files in a clean place or all sorts of
weird build issues happen...  Hence the weird --prefix to the ./configure.

It should be possible to automate the building of libarchive as necessary,
even to the extent of not running ./configure if the Makefile is there and
possible doing necessary stuff for using SVN checkouts of libarchive.
But I have absolutely no idea how...  Help!
 configure.ac |   13 +++++++++++--
 1 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/configure.ac b/configure.ac
index e709fc4..8f34776 100644
--- a/configure.ac
+++ b/configure.ac
@@ -133,8 +133,17 @@ AM_GNU_GETTEXT([external])
 # Check for libarchive
-AC_CHECK_LIB([archive], [archive_read_data], ,
-	AC_MSG_ERROR([libarchive is needed to compile pacman!]))
+if test -d ${srcdir}/libarchive; then
+	# Do not test libarchive as it is in the source tree and the library
+	# has not been built yet
+	libarchivedir=`(cd $srcdir && pwd)`/libarchive/install
+	CFLAGS="-I${libarchivedir}/include $CFLAGS"
+	LIBS="-L${libarchivedir}/lib -larchive $LIBS"
+	AC_CHECK_LIB([archive], [archive_read_data], ,
+		AC_MSG_ERROR([libarchive is needed to compile pacman!]))
 # Check for OpenSSL
 AC_MSG_CHECKING(whether to link with libssl)

More information about the pacman-dev mailing list