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-2005 Jean-loup Gailly and Mark Adler"
LICENSE="Zlib"
SRC_URI="http://zlib.net/zlib-1.2.8.tar.gz"
CHECKSUM_SHA256="36658cb768a54c1d4dec43c3116c27ed893e88b02ecfcb44f2166f9c0b7f2a0d"
REVISION="4"
ARCHITECTURES="x86_gcc2 x86 x86_64 arm"
SECONDARY_ARCHITECTURES="x86_gcc2 x86"

PROVIDES="
	zlib$secondaryArchSuffix = $portVersion compat >= 1
	lib:libz$secondaryArchSuffix = $portVersion compat >= 1
	"
REQUIRES="
	haiku$secondaryArchSuffix >= $haikuVersion
	"
BUILD_REQUIRES="
	"
BUILD_PREREQUIRES="
	haiku${secondaryArchSuffix}_devel >= $haikuVersion
	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

	prepareInstalledDevelLibs libz

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

# ----- devel package -------------------------------------------------------

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
	"
