SUMMARY="A C library for reading, creating, and modifying zip archives"
DESCRIPTION="libzip is a C library for reading, creating, and modifying zip \
archives."
HOMEPAGE="http://www.nih.at/libzip/"
COPYRIGHT="1999-2012 Dieter Baron and Thomas Klausner"
LICENSE="BSD (3-clause)"
REVISION="1"
SOURCE_URI="http://www.nih.at/libzip/libzip-0.10.1.tar.bz2"
CHECKSUM_SHA256="5b1eaf60968cb22df49d73bcaa759961fb27451917ac76b275374c2ed260ce92"

ARCHITECTURES="all"
SECONDARY_ARCHITECTURES="x86_gcc2 x86"

PROVIDES="
	libzip${secondaryArchSuffix} = $portVersion
	cmd:zipcmp${secondaryArchSuffix}
	cmd:zipmerge${secondaryArchSuffix}
	cmd:ziptorrent${secondaryArchSuffix}
	lib:libzip${secondaryArchSuffix} = $portVersion
	"
REQUIRES="
	haiku${secondaryArchSuffix}
	lib:libz${secondaryArchSuffix}
	"

PROVIDES_devel="
	libzip${secondaryArchSuffix}_devel = $portVersion
	devel:libzip$secondaryArchSuffix = $portVersion
	"
REQUIRES_devel="
	libzip$secondaryArchSuffix == $portVersion base
	"

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

BUILD()
{
	sed -i 's/DESTINATION lib\/libzip\/include/DESTINATION include/' CMakeLists.txt

	cmake -DCMAKE_INSTALL_PREFIX=$prefix
	make $jobArgs
}

INSTALL()
{
	make install

	# clean up includes
	mkdir -p $includeDir
	mv $prefix/include/* $includeDir/
	rm -rf $prefix/include

	# clean up man pages
	mkdir -p $manDir
	mv $prefix/man/* $manDir/
	rm -rf $prefix/man

    prepareInstalledDevelLibs \
        libzip \

    fixPkgconfig

    # devel package
    packageEntries devel \
        $developDir
}
