SUMMARY="Long Range ZIP or Lzma RZIP optimized for compressing large files"
DESCRIPTION="A compression utility that excels at compressing large files \
(usually > 10-50 MB). Larger files and/or more free RAM means that the utility \
will be able to more effectively compress your files \
(ie: faster / smaller size), especially if the filesize(s) exceed 100 MB. \
You can either choose to optimise for speed (fast compression / decompression) \
or size, but not both."
HOMEPAGE="http://lrzip.kolivas.org/"
COPYRIGHT="2016 lrzip Authors"
LICENSE="GNU GPL v2"
REVISION="2"
SOURCE_URI="http://ck.kolivas.org/apps/lrzip/lrzip-$portVersion.tar.bz2"
CHECKSUM_SHA256="0d11e268d0d72310d6d73a8ce6bb3d85e26de3f34d8a713055f3f25a77226455"
PATCHES="lrzip-$portVersion.patchset"

ARCHITECTURES="all !x86_gcc2"
SECONDARY_ARCHITECTURES="x86"

USER_SETTINGS_FILES="
	settings/lrzip.conf template $relativeDocDir/lrzip.conf.example
	"

libVersion="0.0.0"
libVersionCompat="$libVersion compat >= ${libVersion%%.*}"

PROVIDES="
	lrzip$secondaryArchSuffix = $portVersion
	cmd:lrunzip = $portVersion
	cmd:lrz = $portVersion
	cmd:lrzcat = $portVersion
	cmd:lrzip = $portVersion
	cmd:lrztar = $portVersion
	cmd:lrzuntar = $portVersion
	lib:liblrzip$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libbz2$secondaryArchSuffix
	lib:liblzo2$secondaryArchSuffix
	lib:libz$secondaryArchSuffix
	"

PROVIDES_devel="
	lrzip${secondaryArchSuffix}_devel = $portVersion
	devel:liblrzip$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES_devel="
	lrzip$secondaryArchSuffix == $portVersion base
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libbz2$secondaryArchSuffix
	devel:liblzo2$secondaryArchSuffix
	devel:libz$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:autoconf
	cmd:awk
	cmd:cmp
	cmd:doxygen
	cmd:find
	cmd:g++$secondaryArchSuffix
	cmd:gcc$secondaryArchSuffix
	cmd:make
	cmd:pod2man
	"

defineDebugInfoPackage lrzip$secondaryArchSuffix \
	"$prefix"/bin/lrzip \
	"$libDir"/liblrzip.so.$libVersion

BUILD()
{
	runConfigure --omit-dirs "binDir docDir" ./configure \
		--bindir="$prefix/bin" --docdir="$developDocDir"
	make $jobArgs
}

INSTALL()
{
	make install

	install -d -m 755 "$docDir"
	# There's no need for another version of GPL v2
	rm "$developDocDir"/COPYING

	mv -t "$docDir" "$developDocDir"/{AUTHORS,lrzip.conf.example,README.md}

	rm -f "$libDir"/*.la
	fixPkgconfig
	prepareInstalledDevelLib liblrzip
	packageEntries devel \
		"$developDir"
}
