SUMMARY="Routing application based on openstreetmap data"
DESCRIPTION="Routino is an application for finding a route between two points \
using the dataset of topographical information collected by \
http://www.OpenStreetMap.org."
HOMEPAGE="http://www.routino.org/"
COPYRIGHT="2008-2019 Andrew M. Bishop"
LICENSE="AGPL-3.0"
REVISION="1"
SOURCE_URI="http://www.routino.org/download/routino-$portVersion.tgz"
CHECKSUM_SHA256="4b7174d76955e058986d343635e0a184385f2756fa4ffc02eb5e2399921e9db1"

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

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

# On x86_gcc2 we don't want to install the commands in bin/<arch>/, but in bin/.
commandSuffix=$secondaryArchSuffix
commandBinDir=$binDir
if [ "$targetArchitecture" = x86_gcc2 ]; then
    commandSuffix=
    commandBinDir=$prefix/bin
fi

PROVIDES="
	routino$secondaryArchSuffix = $portVersion
	cmd:filedumper$commandSuffix = $portVersion
	cmd:filedumper_slim$commandSuffix = $portVersion
	cmd:filedumperx$commandSuffix = $portVersion
	cmd:planetsplitter$commandSuffix = $portVersion
	cmd:planetsplitter_slim$commandSuffix = $portVersion
	cmd:router$commandSuffix = $portVersion
	cmd:router+lib$commandSuffix = $portVersion
	cmd:router+lib_slim$commandSuffix = $portVersion
	cmd:router_slim$commandSuffix = $portVersion
	lib:libroutino$secondaryArchSuffix = $libVersionCompat
	lib:libroutino_slim$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libbz2$secondaryArchSuffix
	lib:libz$secondaryArchSuffix
	"

PROVIDES_devel="
	routino${secondaryArchSuffix}_devel = $portVersion
	devel:libroutino$secondaryArchSuffix = $libVersionCompat
	devel:libroutino_slim$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES_devel="
	haiku$secondaryArchSuffix
	routino$secondaryArchSuffix == $portVersion base
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libbz2$secondaryArchSuffix
	devel:libz$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:g++$secondaryArchSuffix
	cmd:make
	cmd:perl
	"

defineDebugInfoPackage routino$secondaryArchSuffix \
	"$libDir"/libroutino.so.$libVersion \
	"$libDir"/libroutino-slim.so.$libVersion

PATCH()
{
	sed -i 's|pthread|lpthread|' Makefile.conf
	sed -i 's,prefix=/usr/local',prefix?=/usr/local, Makefile.conf
	sed -i 's,bindir=$(prefix)/bin',bindir=$commandBinDir, Makefile.conf
	sed -i 's,incdir=$(prefix)/include',incdir=$includeDir, Makefile.conf
	sed -i 's,libdir=$(prefix)/lib',libdir=$libDir, Makefile.conf
	sed -i 's,docdir=$(prefix)/doc/routino',docdir=$docDir, Makefile.conf
	sed -i 's,datadir=$(prefix)/share/routino',datadir=$dataDir/routino, Makefile.conf
}

BUILD()
{
	make PREFIX=$prefix $jobArgs
}

INSTALL()
{
	make PREFIX=$prefix install

	# prepare develop/lib
	prepareInstalledDevelLibs libroutino libroutino-slim

	# devel package
	packageEntries devel \
		$developDir
}

TEST()
{
	make test
}
