SUMMARY="C library and tools for working with many archive formats."
DESCRIPTION="
The libarchive library features:
* Support for a variety of archive and compression formats.
* Robust automatic format detection, including archive/compression \
combinations such as tar.gz.
* Zero-copy internal architecture for high performance.
* Streaming architecture eliminates all limits on size of archive, limits on \
entry sizes depend on particular formats.
* Carefully factored code to minimize bloat when programs are statically linked.
* Growing test suite ? to verify correctness of new ports.
* Works on most POSIX-like systems
* Supports Windows, including Cygwin, MinGW, and Visual Studio.
The bsdtar and bscpio command-line utilities are feature- and \
performance-competitive with other tar and cpio implementations:
* Reads a variety of formats, including tar, pax, cpio, zip, xar, lha, ar, \
cab, mtree, rar, and ISO images.
* Writes tar, pax, cpio, zip, xar, ar, ISO, mtree, and shar archives
* Automatically handles archives compressed with gzip, bzip2, lzip, xz, lzma, \
or compress.
* Unique format conversion feature.
"
LICENSE="BSD (2-clause)"
COPYRIGHT="2003-2013 Tim Kientzle"
HOMEPAGE="http://www.libarchive.org/"
SRC_URI="http://www.libarchive.org/downloads/libarchive-3.1.2.tar.gz"
CHECKSUM_SHA256="eb87eacd8fe49e8d90c8fdc189813023ccc319c5e752b01fb6ad0cc7b2c53d5e"
REVISION="1"
ARCHITECTURES="x86"
if [ $effectiveTargetArchitecture != x86_gcc2 ]; then
    # x86_gcc2 is fine as primary target architecture as long as we're building
    # for a different secondary architecture.
    ARCHITECTURES="$ARCHITECTURES x86_gcc2"
else
    ARCHITECTURES="$ARCHITECTURES !x86_gcc2"
fi
SECONDARY_ARCHITECTURES="x86"

# On x86_gcc2 we don't want to install the commands in bin/<arch>/, but in bin/.
commandSuffix=$secondaryArchSuffix
commandBinDir=$binDir
if [ "$targetArchitecture" = x86_gcc2 ]; then
    commandSuffix=
    commandBinDir=$prefix/bin
fi

PROVIDES="
	libarchive$secondaryArchSuffix = $portVersion compat >= 3.0
	cmd:bsdtar$commandSuffix = $portVersion compat >= 3.0
	cmd:bsdcpio$commandSuffix = $portVersion compat >= 3.0
	lib:libarchive$secondaryArchSuffix = $portVersion compat >= 3.0
	"

REQUIRES="
	haiku$secondaryArchSuffix >= $haikuVersion
	lib:liblzma$secondaryArchSuffix
	lib:libxml2$secondaryArchSuffix
	lib:libssl$secondaryArchSuffix
	lib:libcrypto$secondaryArchSuffix
	lib:libz$secondaryArchSuffix
	lib:libbz2$secondaryArchSuffix
	"

BUILD_REQUIRES="
	devel:liblzma$secondaryArchSuffix
	devel:libxml2$secondaryArchSuffix
	devel:libssl$secondaryArchSuffix
	devel:libcrypto$secondaryArchSuffix
	devel:libz$secondaryArchSuffix
	devel:libbz2$secondaryArchSuffix
	"

BUILD_PREREQUIRES="
	haiku${secondaryArchSuffix}_devel >= $haikuVersion
	cmd:libtoolize
	cmd:aclocal
	cmd:autoconf
	cmd:automake
	cmd:make
	cmd:gcc$secondaryArchSuffix
	cmd:xml2_config
	"

PROVIDES_devel="
	libarchive${secondaryArchSuffix}_devel = $portVersion compat >= 3.0
	devel:libarchive$secondaryArchSuffix = $portVersion compat >= 3.0
	"

REQUIRES_devel="
	libarchive$secondaryArchSuffix == $portVersion
	"

PATCHES="libarchive-3.1.2.patchset"


BUILD()
{
	libtoolize -fci
	aclocal -I build/autoconf
	automake --add-missing
	autoconf
	runConfigure --omit-dirs binDir ./configure --bindir=$commandBinDir
	make $jobArgs
}

INSTALL()
{
	make install
	prepareInstalledDevelLibs libarchive
	fixPkgconfig
	packageEntries devel $developDir $manDir/man3
}

TEST()
{ 
	make check 
}
