SUMMARY="Numerical and networking C++ library"
DESCRIPTION="Dlib is a modern C++ toolkit containing machine learning \
algorithms and tools for creating complex software in C++ to solve real \
world problems."
HOMEPAGE="http://dlib.net/"
COPYRIGHT="2003-2020 Davis E. King"
LICENSE="Boost v1.0"
REVISION="1"
SOURCE_URI="https://downloads.sourceforge.net/dclib/dlib-$portVersion.tar.bz2
	http://dlib.net/files/dlib-$portVersion.tar.bz2"
CHECKSUM_SHA256="be728a03ae8c4dc8b48408d90392a3c28bc6642a6eb22f3885895b434d7df53c"

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

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

PROVIDES="
	dlib$secondaryArchSuffix = $portVersion
	lib:libdlib$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libgif$secondaryArchSuffix
	lib:libjpeg$secondaryArchSuffix
	lib:liblapack$secondaryArchSuffix
	lib:libopenblas$secondaryArchSuffix
	lib:libpng16$secondaryArchSuffix
	lib:libsqlite3$secondaryArchSuffix
	lib:libz$secondaryArchSuffix
	"

PROVIDES_devel="
	dlib${secondaryArchSuffix}_devel = $portVersion
	devel:libdlib$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES_devel="
	dlib$secondaryArchSuffix == $portVersion base
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libgif$secondaryArchSuffix
	devel:libjpeg$secondaryArchSuffix
	devel:liblapack$secondaryArchSuffix
	devel:libopenblas$secondaryArchSuffix
	devel:libpng16$secondaryArchSuffix
	devel:libsqlite3$secondaryArchSuffix
	devel:libz$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:cmake
	cmd:g++$secondaryArchSuffix
	cmd:make
	cmd:pkg_config$secondaryArchSuffix
	"

defineDebugInfoPackage dlib$secondaryArchSuffix \
	$libDir/libdlib.so.$libVersion.0

BUILD()
{
	mkdir -p build && cd "$_"

	cmake .. \
		-DBUILD_SHARED_LIBS=ON \
		$cmakeDirArgs

	make $jobArgs
}

INSTALL()
{
	cd build
	make install

	mkdir -p $libDir/cmake/

	prepareInstalledDevelLib libdlib

	sed  -i "1i prefix=$prefix" \
		$libDir/pkgconfig/dlib-1.pc

	fixPkgconfig

	packageEntries devel \
		$developDir \
		$libDir/cmake
}

TEST()
{
	#make test
	# dlib provides no tests through cmake AFAIK
	true
}
