SUMMARY="Portable Network Graphics library"
DESCRIPTION="libpng is the official PNG reference library. It supports almost \
all PNG features, is extensible, and has been extensively tested for over 17 \
years."
HOMEPAGE="http://www.libpng.org/"
COPYRIGHT="1998-2017 Glenn Randers-Pehrson
	1996-1997 Andreas Dilger
	1995-1996 Guy Eric Schalnat, Group 42 Inc."
LICENSE="LibPNG"
REVISION="2"
SOURCE_URI="https://downloads.sourceforge.net/libpng/libpng-$portVersion.tar.xz"
CHECKSUM_SHA256="7d76275fad2ede4b7d87c5fd46e6f488d2a16b5a69dc968ffa840ab39ba756ed"

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

# define libVersion as xy.z.0 when portVersion is x.y.z.
libVersion="${portVersion/\./}.0"
libVersionCompat="$libVersion compat >= ${libVersion%%.*}"
portVersionCompat="$portVersion compat >= 1.5"

PROVIDES="
	libpng$secondaryArchSuffix = $portVersionCompat
	lib:libpng15$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libz$secondaryArchSuffix
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	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()
{
	aclocal
	libtoolize --force --copy --install
	./autogen.sh
	runConfigure ./configure
	make $jobArgs
}

INSTALL()
{
	make install

	rm $libDir/libpng*.la

	rm -Rf $manDir/man5

	prepareInstalledDevelLibs libpng libpng15
	fixPkgconfig

	if [ -z "$secondaryArchSuffix" ]; then
		maybe_manDir_man3=$manDir/man3
	else
		maybe_manDir_man3=
		rm -rf $manDir/man3
	fi

	rm -rf \
		$binDir \
		$developDir \
		$maybe_manDir_man3

	rmdir $manDir
}

TEST()
{
	make check
}
