SUMMARY="Tiff library"
DESCRIPTION="
TIFF the Tag Image File Format, is a widely used format for storing image \
data. Included in this software is a library, libtiff, for reading and writing \
TIFF.
"
HOMEPAGE="http://www.libtiff.org" 
SRC_URI="ftp://ftp.remotesensing.org/pub/libtiff/tiff-3.9.6.tar.gz"
CHECKSUM_SHA256="0fba119156236074343a14afbd3a47907e3a5952c9c86102305d4eeb06ad6833"
REVISION="1"
LICENSE="MIT"
COPYRIGHT="1988-1997 Sam Leffler
	1991-1997 Silicon Graphics, Inc."

REVISION="2"
ARCHITECTURES="x86_gcc2 x86 x86_64"
SECONDARY_ARCHITECTURES="x86_gcc2 x86"

PATCHES="tiff-${portVersion}.patchset"

PROVIDES="
	tiff$secondaryArchSuffix = $portVersion compat >= 3
	lib:libtiff$secondaryArchSuffix = $portVersion compat >= 3
	lib:libtiffxx$secondaryArchSuffix = $portVersion compat >= 3
	"
REQUIRES="
	haiku$secondaryArchSuffix >= $haikuVersion
	lib:libjpeg$secondaryArchSuffix
	lib:libz$secondaryArchSuffix
	"
BUILD_REQUIRES="
	devel:libjpeg$secondaryArchSuffix
	devel:libz$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	haiku${secondaryArchSuffix}_devel >= $haikuVersion
	cmd:aclocal
	cmd:autoconf
	cmd:automake
	cmd:gcc$secondaryArchSuffix
	cmd:ld$secondaryArchSuffix
	cmd:libtoolize
	cmd:make
	"

BUILD()
{
	aclocal
	libtoolize --force --copy --install
	automake --add-missing
	autoconf
	autoheader
	runConfigure ./configure --with-docdir=$documentationDir
	make $jobArgs
}

INSTALL()
{
	make install

	prepareInstalledDevelLibs libtiff libtiffxx

	# devel package
	packageEntries devel \
		$developDir

	# tools package
	if [ -z "$secondaryArchSuffix" ]; then
		packageEntries tools \
			$binDir \
			$documentationDir
	fi

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

# ----- devel package -------------------------------------------------------

PROVIDES_devel="
	tiff${secondaryArchSuffix}_devel = $portVersion compat >= 3
	devel:libtiff$secondaryArchSuffix = $portVersion compat >= 3
	devel:libtiffxx$secondaryArchSuffix = $portVersion compat >= 3
	"
REQUIRES_devel="
	tiff$secondaryArchSuffix == $portVersion base
	"

# ----- tools package -------------------------------------------------------

if [ -z "$secondaryArchSuffix" ]; then
	SUMMARY_tools="The TIFF tools"
	PROVIDES_tools="
		tiff_tools = $portVersion compat >= 3
		cmd:bmp2tiff = $portVersion compat >= 3
		cmd:fax2ps = $portVersion compat >= 3
		cmd:fax2tiff = $portVersion compat >= 3
		cmd:gif2tiff = $portVersion compat >= 3
		cmd:pal2rgb = $portVersion compat >= 3
		cmd:ppm2tiff = $portVersion compat >= 3
		cmd:ras2tiff = $portVersion compat >= 3
		cmd:raw2tiff = $portVersion compat >= 3
		cmd:rgb2ycbcr = $portVersion compat >= 3
		cmd:thumbnail = $portVersion compat >= 3
		cmd:tiff2bw = $portVersion compat >= 3
		cmd:tiff2pdf = $portVersion compat >= 3
		cmd:tiff2ps = $portVersion compat >= 3
		cmd:tiff2rgba = $portVersion compat >= 3
		cmd:tiffcmp = $portVersion compat >= 3
		cmd:tiffcp = $portVersion compat >= 3
		cmd:tiffcrop = $portVersion compat >= 3
		cmd:tiffdither = $portVersion compat >= 3
		cmd:tiffdump = $portVersion compat >= 3
		cmd:tiffinfo = $portVersion compat >= 3
		cmd:tiffmedian = $portVersion compat >= 3
		cmd:tiffset = $portVersion compat >= 3
		cmd:tiffsplit = $portVersion compat >= 3     
		"
	REQUIRES_tools="
		haiku >= $haikuVersion
		lib:libjpeg
		lib:libz
		tiff == $portVersion base
		"
fi
