SUMMARY="Audio fingerprint library"
DESCRIPTION="chromaprint is a client-side library that implements a custom \
algorithm for extracting fingerprints from any audio source."
HOMEPAGE="https://acoustid.org/chromaprint"
COPYRIGHT="2010-2012, 2015 Lukas Lalinsky"
LICENSE="GNU LGPL v2.1"
REVISION="1"
SOURCE_URI="https://github.com/acoustid/chromaprint/releases/download/v$portVersion/chromaprint-$portVersion.tar.gz"
CHECKSUM_SHA256="573a5400e635b3823fc2394cfa7a217fbb46e8e50ecebd4a61991451a8af766a"
SOURCE_DIR="chromaprint-v$portVersion"
PATCHES="chromaprint-$portVersion.patchset"

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

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

PROVIDES="
	chromaprint$secondaryArchSuffix = $portVersion
	lib:libchromaprint$secondaryArchSuffix = $libVersionCompat
	cmd:fpcalc = $portVersion
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libavcodec$secondaryArchSuffix
	lib:libavformat$secondaryArchSuffix
	lib:libavutil$secondaryArchSuffix
	"

PROVIDES_devel="
	chromaprint${secondaryArchSuffix}_devel = $portVersion
	devel:libchromaprint$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES_devel="
	chromaprint$secondaryArchSuffix == $portVersion base
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libavcodec$secondaryArchSuffix
	devel:libavformat$secondaryArchSuffix
	devel:libavutil$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:cmake
	cmd:gcc$secondaryArchSuffix
	cmd:ld$secondaryArchSuffix
	cmd:make
	"

defineDebugInfoPackage chromaprint$secondaryArchSuffix \
	"$libDir"/libchromaprint.so.$libVersion

BUILD()
{
	cmake -DCMAKE_INSTALL_PREFIX=$prefix \
		-DCMAKE_INSTALL_LIBDIR=$libDir \
		-DCMAKE_INSTALL_INCLUDEDIR=$includeDir \
		-DBUILD_TOOLS=ON \
		-DFFT_LIB=avfft \
		-DCMAKE_BUILD_TYPE=Release .

	make $jobArgs
}

INSTALL()
{
	make install

	prepareInstalledDevelLib libchromaprint
	fixPkgconfig

	# devel package
	packageEntries devel \
		$developDir
}
