SUMMARY="Low-latency audio server"
DESCRIPTION="jack2 is a C++ version of the JACK low-latency audio server \
for multi-processor machines."
HOMEPAGE="https://github.com/Barrett17/jack2-for-haiku"
COPYRIGHT="2001-2011 Paul Davis."
LICENSE="GNU GPL v2"
REVISION="1"
srcGitRev="11d3d1aaf56ff5c323271db7f7e7353ba5e245c9"
SOURCE_URI="https://github.com/Barrett17/jack2/archive/$srcGitRev.tar.gz"
CHECKSUM_SHA256="e76472ae3895e885a5b25c714b760cfe034179eb67437aa4ba186f3cfe965708"
SOURCE_FILENAME="jack-$portVersion.tar.gz"
SOURCE_DIR="jack2-$srcGitRev"
PATCHES="jack2-$portVersion.patchset"

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

PROVIDES="
	jack2$secondaryArchSuffix = $portVersion
	cmd:jack_alias
	cmd:jack_bufsize
	cmd:jack_connect
	cmd:jack_control
	cmd:jack_cpu
	cmd:jack_cpu_load
	cmd:jack_disconnect
	cmd:jack_evmon
	cmd:jack_freewheel
	cmd:jack_iodelay
	cmd:jack_latent_client
	cmd:jack_load
	cmd:jack_lsp
	cmd:jack_metro
	cmd:jack_midi_dump
	cmd:jack_midi_latency_test
	cmd:jack_midiseq
	cmd:jack_midisine
	cmd:jack_monitor_client
	cmd:jack_multiple_metro
	cmd:jack_net_master
	cmd:jack_net_slave
	cmd:jack_rec
	cmd:jack_samplerate
	cmd:jack_server_control
	cmd:jack_session_notify
	cmd:jack_showtime
	cmd:jack_simple_client
	cmd:jack_simple_session_client
	cmd:jack_test
	cmd:jack_thru
	cmd:jack_transport
	cmd:jack_unload
	cmd:jack_wait
	cmd:jack_zombie
	cmd:jackd
	lib:libjack$secondaryArchSuffix = 0.1.0 compat >= 0
	lib:libjacknet$secondaryArchSuffix = 0.1.0 compat >= 0
	lib:libjackserver$secondaryArchSuffix = 0.1.0 compat >= 0
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libreadline$secondaryArchSuffix
	lib:libsamplerate$secondaryArchSuffix
	lib:libsndfile$secondaryArchSuffix
	"

PROVIDES_devel="
	jack2${secondaryArchSuffix}_devel
	devel:libjack$secondaryArchSuffix = 0.1.0 compat >= 0
	devel:libjacknet$secondaryArchSuffix = 0.1.0 compat >= 0
	devel:libjackserver$secondaryArchSuffix = 0.1.0 compat >= 0
	"
REQUIRES_devel="
	jack2$secondaryArchSuffix == $portVersion base
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libreadline$secondaryArchSuffix
	devel:libsamplerate$secondaryArchSuffix
	devel:libsndfile$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:g++$secondaryArchSuffix
	cmd:git
	cmd:pkg_config$secondaryArchSuffix
	cmd:python
	"

BUILD()
{
	python ./waf configure --prefix="$prefix" --libdir="$libDir" \
		--mandir="$manDir"
	python ./waf build
}

INSTALL()
{
	python ./waf build install

	mkdir -p "$includeDir"
	mv "$prefix"/include/jack/ "$includeDir"
	rmdir "$prefix"/include

	prepareInstalledDevelLibs libjack libjacknet libjackserver
	fixPkgconfig

	packageEntries devel \
		"$developDir"
}
