SUMMARY="A massively spiffy yet delicately unobtrusive compression library"
DESCRIPTION="Zlib is designed to be a free, general-purpose, legally \
unencumbered -- that is, not covered by any patents -- lossless \
data-compression library for use on virtually any computer hardware and \
operating system. The zlib data format is itself portable across platforms.

Unlike the LZW compression method used in Unix compress(1) and in the GIF \
image format, the compression method currently used in zlib essentially never \
expands the data. (LZW can double or triple the file size in extreme cases.) \
zlib's memory footprint is also independent of the input data and can be \
reduced, if necessary, at some cost in compression."
HOMEPAGE="http://www.zlib.net/"
COPYRIGHT="1995-2017 Jean-loup Gailly and Mark Adler"
LICENSE="Zlib"
REVISION="4"
SOURCE_URI="http://zlib.net/fossils/zlib-$portVersion.tar.gz"
CHECKSUM_SHA256="c3e5e9fdd5004dcb542feda5ee4f0ff0744628baf8ed2dd5d66f8ca1197cb1a1"
PATCHES="zlib-$portVersion.patchset"

ARCHITECTURES="all ?ppc"
SECONDARY_ARCHITECTURES="x86_gcc2 x86"

PROVIDES="
	zlib$secondaryArchSuffix = $portVersion compat >= 1
	lib:libz$secondaryArchSuffix = $portVersion compat >= 1
	"
REQUIRES="
	haiku$secondaryArchSuffix
	"

SUMMARY_devel="The zlib development files"
PROVIDES_devel="
	zlib${secondaryArchSuffix}_devel = $portVersion compat >= 1
	devel:libz$secondaryArchSuffix = $portVersion compat >= 1
	"
REQUIRES_devel="
	zlib$secondaryArchSuffix == $portVersion base
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	"
BUILD_PREREQUIRES="
	cmd:cmake
	cmd:gcc$secondaryArchSuffix
	cmd:grep
	cmd:ld$secondaryArchSuffix
	cmd:make
	cmd:sed
	"

PATCH()
{
	sed -i 's,${CMAKE_INSTALL_PREFIX}/bin',$binDir, CMakeLists.txt
	sed -i 's,${CMAKE_INSTALL_PREFIX}/include',$includeDir, CMakeLists.txt
	sed -i 's,${CMAKE_INSTALL_PREFIX}/lib',$libDir, CMakeLists.txt
	sed -i 's,${CMAKE_INSTALL_PREFIX}/share/man',$manDir, CMakeLists.txt
	sed -i 's,${CMAKE_INSTALL_PREFIX}/share/pkgconfig',$developLibDir/pkgconfig, \
		CMakeLists.txt
}

BUILD()
{
	rm -rf build
	mkdir build
	cd build

	cmake -DCMAKE_INSTALL_PREFIX:PATH=$prefix ..
	make $jobArgs
}

INSTALL()
{
	cd build
	make install

	touch $libDir/libz.so.1

	prepareInstalledDevelLib libz

	# devel package
	packageEntries devel \
		$developDir \
		$documentationDir
}
