SUMMARY="Free implementation of rsync remote-delta algorithm"
DESCRIPTION="librsync is a free software library that implements the \
rsync remote-delta algorithm.  This algorithm allows efficient remote \
updates of a file, without requiring the old and new versions to \
both be presentat the sending end.  The library uses a \"streaming\" \
design similar to that of zlib with the aim of allowing it to be embedded \
into many different applications."

HOMEPAGE="http://librsync.sourcefrog.net"

# Unfortunately the maintainer of librsync did not publish a tag or released
# tarball for the 1.0.0 release (yet?). Use a static tarball with Git hash
# for now (which comparing to directly cloning allows for double-checking
# correctness of the source).
GIT_HASH='02f1cc19182845d37cfb6a893f54af220a294ce7'
# Attach the $GIT_HASH to the file name just in case upstream publishes an
# official release tarball.
SOURCE_FILENAME="librsync-${portVersion}-${GIT_HASH}.tar.gz"
SOURCE_URI="https://github.com/librsync/librsync/archive/${GIT_HASH}.tar.gz"
CHECKSUM_SHA256='25d046a8cbc6e075cc68925b5070c1f0e731e3a018446f6bda20ec9723a5631a'
REVISION="1"
SOURCE_DIR="librsync-${GIT_HASH}"

ARCHITECTURES="x86_gcc2 x86 x86_64"
SECONDARY_ARCHITECTURES="x86_gcc2 x86"
LICENSE="GNU LGPL v2.1"
COPYRIGHT="1995 Patrick Powell <papowell@astart.com>
1996-1999 Andrew Tridgell <tridge@samba.org>
1996 Paul Mackerras
1999-2014 Martin Pool <mbp@sourcefrog.net>
2002-2003 Donovan Baarda <abo@minkirri.apana.org.au>
"

REQUIRES="
	haiku$secondaryArchSuffix
	lib:libpopt$secondaryArchSuffix
"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libpopt$secondaryArchSuffix
"

BUILD_PREREQUIRES="
	cmd:aclocal
	cmd:autoconf
	cmd:automake
	cmd:autoreconf
	cmd:gcc$secondaryArchSuffix
	cmd:gawk
	cmd:grep
	cmd:libtoolize
	cmd:make
	cmd:perl
	cmd:sed
	cmd:which
"

PROVIDES="
	$portName                        = $portVersion
	cmd:rdiff$secondaryArchSuffix    = $portVersion
	lib:librsync$secondaryArchSuffix = 2.0.0 compat >= 2
"

PATCHES="librsync-${portVersion}.patchset"

BUILD()
{
	autoreconf -fi
	runConfigure ./configure \
		--enable-shared
	make $jobArgs
}

INSTALL()
{
	make install
	prepareInstalledDevelLibs librsync
	packageEntries devel \
		$developDir \
		$manDir/man3
}

TEST()
{
	make check
}

# Although the librsync soname is bumped to 2.0.0, it is purely an ABI change,
# so the compat level for the devel package remains at 1.
PROVIDES_devel="
	${portName}_devel           = $portVersion compat >= 1
	devel:librsync$secondaryArchSuffix = 2.0.0 compat >= 1
	"
REQUIRES_devel="
	librsync$secondaryArchSuffix == $portVersion base
	"

