SUMMARY="A utility for lossy compression of PNG images"
DESCRIPTION="Pngquant converts 32-bit RGBA PNGs to 8-bit (or smaller) \
RGBA-palette PNGs, optionally using Floyd-Steinberg dithering.

The conversion reduces file sizes significantly (often as much as 70%) and \
preserves full alpha transparency. Generated images are compatible with all \
modern web browsers, and have better fallback in IE6 than 24-bit PNGs."
HOMEPAGE="https://pngquant.org/"
COPYRIGHT="2009-2016 by Kornel Lesiński"
LICENSE="GNU GPL v3"
REVISION="3"
SOURCE_URI="https://github.com/pornel/pngquant/archive/$portVersion.tar.gz"
CHECKSUM_SHA256="071e1af157ed2044d68522f4a18c5d94c5b6cbd83827a08e1bdf0ec0649f9cc9"

ARCHITECTURES="all !x86_gcc2"
SECONDARY_ARCHITECTURES="!x86_gcc2 x86"

PROVIDES="
	pngquant$secondaryArchSuffix = $portVersion
	cmd:pngquant = $portVersion
	lib:libimagequant$secondaryArchSuffix = 0
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:liblcms2$secondaryArchSuffix
	lib:libpng16$secondaryArchSuffix
	lib:libz$secondaryArchSuffix
	"

PROVIDES_devel="
	pngquant${secondaryArchSuffix}_devel = $portVersion
	devel:libimagequant$secondaryArchSuffix = 0
	"
REQUIRES_devel="
	pngquant$secondaryArchSuffix == $portVersion base
	"

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

BUILD()
{
	runConfigure ./configure
	make staticlib sharedlib bin.shared
}

INSTALL()
{
	make install MANPREFIX=$manDir
	install -d -m 755 $libDir $includeDir
	install -t $libDir lib/libimagequant.{a,so.0}
	install -t $includeDir lib/libimagequant.h

	prepareInstalledDevelLib libimagequant

	# devel package
        packageEntries devel \
                $developDir
}

TEST()
{
	LIBRARY_PATH=$sourceDir/lib:$LIBRARY_PATH make test.shared
}
