SUMMARY="Portable Network Graphics library (BeOS compatibility version)"
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.

This is libpng 1.2, an older version which may be needed for compatibility \
with BeOS application. For new developments please use the current libpng \
package."
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="1"
SOURCE_URI="https://downloads.sourceforge.net/libpng/libpng-$portVersion.tar.gz"
CHECKSUM_SHA256="4bd4b5ce04ce634c281ae76174714fa02b053b573ac2181c985db06aa57e1e9e"
SOURCE_DIR="libpng-$portVersion"

ARCHITECTURES="x86_gcc2"
SECONDARY_ARCHITECTURES="x86_gcc2"

# define libVersion as 3.z.0 when portVersion is 1.2.z.
libVersion="3.${portVersion#1\.2\.}.0"
libVersionCompat="$libVersion compat >= 3"

# define lib12Version as 0.z.0 when portVersion is 1.2.z.
lib12Version="0.${portVersion#1\.2\.}.0"
lib12VersionCompat="$lib12Version compat >= 0"

portVersionCompat="$portVersion compat >= 1.2"

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

PROVIDES_devel="
	libpng12${secondaryArchSuffix}_devel = $portVersionCompat
	cmd:libpng_config$secondaryArchSuffix = $portVersionCompat
	cmd:libpng12_config$secondaryArchSuffix = $portVersionCompat
	devel:libpng$secondaryArchSuffix = $libVersionCompat
	devel:libpng12$secondaryArchSuffix = $lib12VersionCompat
	"
REQUIRES_devel="
	libpng12$secondaryArchSuffix == $portVersion base
	"
CONFLICTS_devel="
	libpng${secondaryArchSuffix}_devel
	libpng16${secondaryArchSuffix}_devel
	"

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
	"

defineDebugInfoPackage libpng12$secondaryArchSuffix \
	"$libDir"/libpng.so.$libVersion \
	"$libDir"/libpng12.so.$lib12Version

BUILD()
{
	aclocal
	libtoolize --force --copy --install
	./autogen.sh
	runConfigure ./configure
	make $jobArgs
}

INSTALL()
{
	make install

	rm $libDir/libpng*.la

	prepareInstalledDevelLibs libpng libpng12
	fixPkgconfig

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

	# devel package
	packageEntries devel \
		$binDir \
		$developDir \
		$maybe_manDir
}

TEST()
{
	make check
}
