SUMMARY="A library for the Mac OS 'icns' format"
DESCRIPTION="libicns is a library for manipulation of the Mac OS 'icns' \
resource format, also known as the IconFamily resource type. It can read \
and write files from the Mac OS X icns format, as well as read from Mac OS \
resource files and macbinary encoded Mac OS resource forks."
HOMEPAGE="https://sourceforge.net/projects/icns"
COPYRIGHT="2001-2012 Matthew Eis"
LICENSE="GNU LGPL v2.1"
REVISION="8"
SOURCE_URI="http://sourceforge.net/projects/icns/files/libicns-$portVersion.tar.gz"
CHECKSUM_SHA256="335f10782fc79855cf02beac4926c4bf9f800a742445afbbf7729dab384555c2"
PATCHES="libicns-$portVersion.patchset
	support-libopenjp2.patch"

ARCHITECTURES="all"
SECONDARY_ARCHITECTURES="x86_gcc2 x86"

PROVIDES="
	libicns$secondaryArchSuffix = $portVersion compat >= 0.8
	lib:libicns$secondaryArchSuffix = 1.2.0 compat >= 1
	"
if [ -z "$secondaryArchSuffix" ]; then
	PROVIDES="$PROVIDES
		cmd:icns2png
		cmd:icontainer2icns
		cmd:png2icns
	"
fi
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libopenjp2$secondaryArchSuffix
	lib:libpng16$secondaryArchSuffix
	lib:libz$secondaryArchSuffix
	"

PROVIDES_devel="
	libicns${secondaryArchSuffix}_devel = $portVersion compat >= 0.8
	devel:libicns$secondaryArchSuffix = 1.2.0 compat >= 1
	"
REQUIRES_devel="
	libicns$secondaryArchSuffix == $portVersion base
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libopenjp2$secondaryArchSuffix
	devel:libpng16$secondaryArchSuffix
	devel:libz$secondaryArchSuffix >= 1.0.4
	"
BUILD_PREREQUIRES="
	cmd:aclocal
	cmd:autoconf
	cmd:automake
	cmd:gcc$secondaryArchSuffix
	cmd:ld$secondaryArchSuffix
	cmd:libtoolize$secondaryArchSuffix
	cmd:make
	"

BUILD()
{
	autoreconf -fi
	runConfigure ./configure
	make $jobArgs
}

INSTALL()
{
	make install

	rm $libDir/libicns.la

	# Remove stuff we don't need in the secondary architecture base package.
	if [ -n "$secondaryArchSuffix" ]; then
		rm -rf $binDir
	fi

	prepareInstalledDevelLibs libicns
	fixPkgconfig

	# devel package
	packageEntries devel \
		$developDir
}
