SUMMARY="Proj.4 cartographic projection software"
DESCRIPTION="Proj.4 is a library for performing conversions between \
cartographic projections."
HOMEPAGE="https://trac.osgeo.org/geotiff/"
COPYRIGHT="1999-2012 Frank Warmerdam"
LICENSE="GNU GPL v2"
REVISION="1"
SOURCE_URI="https://download.osgeo.org/geotiff/libgeotiff/libgeotiff-$portVersion.tar.gz"
CHECKSUM_SHA256="9311017e5284cffb86f2c7b7a9df1fb5ebcdc61c30468fb2e6bca36e4272ebca"

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

portVersionCompat="$portVersion compat >= ${portVersion%%.*}"
libVersion="5.1.0"
libVersionCompat="$libVersion compat >= ${libVersion%%.*}"

if [ "$targetArchitecture" != x86_gcc2 ]; then
	commandSuffix=$secondaryArchSuffix
	commandBinDir=$binDir
else
	commandSuffix=
	commandBinDir=$prefix/bin
fi

PROVIDES="
	libgeotiff$secondaryArchSuffix = $portVersionCompat
	lib:libgeotiff$secondaryArchSuffix = $libVersionCompat
	cmd:applygeo$commandSuffix = $portVersionCompat
	cmd:geotifcp$commandSuffix = $portVersionCompat
	cmd:listgeo$commandSuffix = $portVersionCompat
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libjpeg$secondaryArchSuffix
	lib:libproj$secondaryArchSuffix
	lib:libtiff$secondaryArchSuffix
	lib:libz$secondaryArchSuffix
	"

PROVIDES_devel="
	libgeotiff${secondaryArchSuffix}_devel = $portVersionCompat
	devel:libgeotiff$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES_devel="
	libgeotiff$secondaryArchSuffix == $portVersion base
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libjpeg$secondaryArchSuffix
	devel:libproj$secondaryArchSuffix >= 15
	devel:libtiff$secondaryArchSuffix >= 5
	devel:libz$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:awk
	cmd:diff
	cmd:gcc$secondaryArchSuffix
	cmd:ld$secondaryArchSuffix
	cmd:make
	cmd:pkg_config$secondaryArchSuffix
	"

BUILD()
{
	jpegDir=$portPackageLinksDir/lib~libjpeg
	zlibDir=$portPackageLinksDir/lib~libz

	runConfigure --omit-dirs binDir ./configure \
		--bindir=$commandBinDir \
		--with-zlib=$zlibDir \
		--with-jpeg=$jpegDir
	make $jobArgs
}

INSTALL()
{
	make install

	rm -f "$libDir"/*.la "$libDir"/libgeotiff.a

	prepareInstalledDevelLibs libgeotiff
	fixPkgconfig

	# devel package
	packageEntries devel \
		$developDir
}

TEST()
{
	make check
}
