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"
SOURCE_URI="ftp://ftp.remotesensing.org/pub/libtiff/tiff-$portVersion.tar.gz"
CHECKSUM_SHA256="ea1aebe282319537fb2d4d7805f478dd4e0e05c33d0928baba76a7c963684872"
LICENSE="MIT"
COPYRIGHT="1988-1997 Sam Leffler
	1991-1997 Silicon Graphics, Inc."
REVISION="1"
ARCHITECTURES="x86_gcc2 x86 x86_64"
SECONDARY_ARCHITECTURES="x86_gcc2 x86"

PROVIDES="
	tiff4$secondaryArchSuffix = $portVersion compat >= 4
	lib:libtiff$secondaryArchSuffix = 5.2.0 compat >= 5
	lib:libtiffxx$secondaryArchSuffix = 5.2.0 compat >= 5
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libGL$secondaryArchSuffix
	lib:libjpeg$secondaryArchSuffix
	lib:libz$secondaryArchSuffix
	lib:libstdc++$secondaryArchSuffix
	"
BUILD_REQUIRES="
	devel:libGL$secondaryArchSuffix
	devel:libjpeg$secondaryArchSuffix
	devel:libz$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	haiku${secondaryArchSuffix}_devel
	cmd:aclocal
	cmd:autoconf
	cmd:automake
	cmd:gcc$secondaryArchSuffix
	cmd:ld$secondaryArchSuffix
	cmd:libtoolize
	cmd:make
	"
PATCHES="
	tiff-4.0.3.patch
"

PATCH()
{
	if [ $effectiveTargetArchitecture == x86_gcc2 ]; then
		sed -i 's/ios::pos_type/streampos/g' libtiff/tif_stream.cxx
		sed -i 's/ios::off_type/streamoff/g' libtiff/tif_stream.cxx
	fi
}

SOURCE_DIR="tiff-$portVersion"

BUILD()
{
	autoreconf -fi
	runConfigure ./configure --with-docdir=$documentationDir/$portName
#		--enable-shared
	make $jobArgs
}

INSTALL()
{
	make install

	prepareInstalledDevelLibs libtiff libtiffxx
	fixPkgconfig

	# 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="
	tiff4${secondaryArchSuffix}_devel = $portVersion compat >= 4
	devel:libtiff$secondaryArchSuffix = 5.2.0 compat >= 5
	devel:libtiffxx$secondaryArchSuffix = 5.2.0 compat >= 5
	"
REQUIRES_devel="
	tiff4$secondaryArchSuffix == $portVersion base
	"
CONFLICTS_devel="
	tiff${secondaryArchSuffix}_devel
	"

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

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