SUMMARY="A cartographic projection software"
DESCRIPTION="Proj.6 is a library for performing conversions between \
cartographic projections."
HOMEPAGE="https://proj4.org/index.html"
COPYRIGHT="2000-2018 Frank Warmerdam"
LICENSE="MIT"
REVISION="1"
SOURCE_URI="http://download.osgeo.org/proj/proj-$portVersion.tar.gz"
CHECKSUM_SHA256="b300c0f872f632ad7f8eb60725edbf14f0f8f52db740a3ab23e7b94f1cd22a50"

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

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

libVersion="15.2.0"
libVersionCompat="$libVersion compat >= ${libVersion%%.*}"

PROVIDES="
	proj$secondaryArchSuffix = $portVersion
	lib:libproj$secondaryArchSuffix = $libVersionCompat
	cmd:cct$commandSuffix = $portVersion
	cmd:cs2cs$commandSuffix = $portVersion
	cmd:geod$commandSuffix = $portVersion
	cmd:gie$commandSuffix = $portVersion
	cmd:invgeod$commandSuffix = $portVersion
	cmd:invproj$commandSuffix = $portVersion
	cmd:proj$commandSuffix = $portVersion
	cmd:projinfo$commandSuffix = $portVersion
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libsqlite3$secondaryArchSuffix
	"

PROVIDES_devel="
	proj${secondaryArchSuffix}_devel = $portVersion
	devel:libproj$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES_devel="
	proj$secondaryArchSuffix == $portVersion base
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libsqlite3$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:aclocal
	cmd:autoconf
	cmd:automake
	cmd:awk
	cmd:gcc$secondaryArchSuffix
	cmd:ld$secondaryArchSuffix
	cmd:libtoolize$secondaryArchSuffix
	cmd:make
	cmd:pkg_config$secondaryArchSuffix
	cmd:sqlite3
	"

defineDebugInfoPackage proj$secondaryArchSuffix \
	"$commandBinDir"/cct \
	"$commandBinDir"/cs2cs \
	"$commandBinDir"/geod \
	"$commandBinDir"/gie \
	"$commandBinDir"/proj \
	"$commandBinDir"/projinfo \
	"$libDir"/libproj.so.$libVersion

BUILD()
{
	autoreconf -fi
	runConfigure --omit-dirs binDir ./configure \
		--bindir="$commandBinDir"

	make $jobArgs
}

INSTALL()
{
	make install

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

	prepareInstalledDevelLibs libproj
	fixPkgconfig

	# devel package
	packageEntries devel \
		"$developDir" \
		"$manDir"/man3
}

TEST()
{
	make check
}
