SUMMARY="A library for interfacing Music Player Daemon"
DESCRIPTION="Music Player Daemon (MPD) is a flexible, powerful, server-side application \
for playing music. Through plugins and libraries it can play a variety \
of sound files while being controlled by its network protocol."
HOMEPAGE="https://www.musicpd.org/"
COPYRIGHT="2003-2020 The Music Player Daemon Project"
LICENSE="BSD (3-clause)"
REVISION="1"
SOURCE_URI="https://github.com/MusicPlayerDaemon/libmpdclient/archive/v$portVersion.tar.gz"
CHECKSUM_SHA256="9b97d00022f2053c06d87bff40b319dfab930ee2b5fa9b8dec208a2911ca3efc"
SOURCE_FILENAME="libmpdclient-$portVersion.tar.gz"

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

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

PROVIDES="
	libmpdclient$secondaryArchSuffix = $portVersion
	lib:libmpdclient$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES="
	haiku$secondaryArchSuffix
	"

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

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libcheck$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:doxygen
	cmd:gcc$secondaryArchSuffix
	cmd:ld$secondaryArchSuffix
	cmd:libtoolize$secondaryArchSuffix
	cmd:make
	cmd:meson
	cmd:ninja
	cmd:pkg_config$secondaryArchSuffix
	"

defineDebugInfoPackage libmpdclient$secondaryArchSuffix \
	$libDir/libmpdclient.so.$libVersion

BUILD()
{
	rm -rf build_haiku
	mkdir -p build_haiku; cd build_haiku

	export LDFLAGS="-lnetwork"
	meson --prefix=$prefix \
		--libdir=$libDir \
		--includedir=$includeDir \
		--mandir=$manDir \
		--infodir=$infoDir \
		-Dtest=true

	ninja $jobArgs
}

INSTALL()
{
	cd build_haiku
	ninja install

	mkdir -p $docDir
	mv $prefix/share/doc/libmpdclient/* $docDir
	rm -rf $prefix/share

	# prepare devel/lib
	prepareInstalledDevelLibs libmpdclient
	fixPkgconfig

	# devel package
	packageEntries devel \
		$developDir
}

TEST()
{
	cd build_haiku
	ninja test
}
