SUMMARY="A parallel implementation of gzip for multi-processor machines"
DESCRIPTION="
pigz, which stands for Parallel Implementation of GZip, is a fully functional \
replacement for gzip that exploits multiple processors and multiple cores to \
the hilt when compressing data.

pigz was written by Mark Adler, and uses the zlib and pthread libraries.

This version of pigz is written to be portable across Unix-style operating \
systems that provide the zlib and pthread libraries."
HOMEPAGE="http://www.zlib.net/pigz"
COPYRIGHT="2008-2013 Mark Adler"
LICENSE="Zlib"
REVISION="1"
SOURCE_URI="http://www.zlib.net/pigz/pigz-$portVersion.tar.gz"
CHECKSUM_SHA256="b4c9e60344a08d5db37ca7ad00a5b2c76ccb9556354b722d56d55ca7e8b1c707"

ARCHITECTURES="all !x86_gcc2"
if [ "$targetArchitecture" = x86_gcc2 ]; then
SECONDARY_ARCHITECTURES="x86"
fi

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

PROVIDES="
	pigz$secondaryArchSuffix = $portVersion
	cmd:pigz = $portVersion
	cmd:unpigz = $portVersion
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libz$secondaryArchSuffix
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libz$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:gcc$secondaryArchSuffix
	cmd:make
	"

PATCH()
{
	sed -i 's/-lm//g' Makefile
	sed -i 's/-lpthread//g' Makefile
	sed -i 's/ln -f/ln -sf/g' Makefile
}

BUILD()
{
	make
}

INSTALL()
{
	mkdir -p $commandBinDir
	cp -af pigz unpigz $commandBinDir
	mkdir -p $manDir/man1
	cp -af pigz.1 $manDir/man1
}

TEST()
{
	make test
}
