SUMMARY="Robust, somewhat scalable, cross-platform client-server solution"
DESCRIPTION="The MUSCLE system is a robust, somewhat scalable, cross-platform \
client-server solution for dynamic distributed applications for Haiku and \
other operating systems.
It allows (n) client programs (each of which may be running on a \
separate computer and/or under a different OS) to communicate with each other \
in a many-to-many message-passing style. It employs a central server to which \
client programs may connect or disconnect at any time (this design is similar \
to other client-server systems such as Quake servers, IRC servers, and Napster \
servers, but more general in application).
In addition to the client-server \
system, MUSCLE contains classes to support peer-to-peer message streaming \
connections, as well as some handy miscellaneous utility classes."
HOMEPAGE="https://public.msli.com/lcs/muscle/"
COPYRIGHT="2000-2009 Meyer Sound Laboratories Inc.
	2000-2017 Jeremy Friesner"
LICENSE="BSD (3-clause)"
REVISION="1"
SOURCE_URI="https://public.msli.com/lcs/muscle/muscle$portVersion.zip"
CHECKSUM_SHA256="125f65ad90a8352f46135697365eca87c8ac0a636c1e4e737e19835a609b586b"
SOURCE_DIR="muscle"
PATCHES="muscle-$portVersion.patchset"

#TODO:enable multithreading for the devel package!

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

PROVIDES="
	muscle$secondaryArchSuffix = $portVersion
	cmd:muscled$secondaryArchSuffix = $portVersion
	cmd:muscled_admin$secondaryArchSuffix = $portVersion
	"
REQUIRES="
	haiku$secondaryArchSuffix
	"

PROVIDES_devel="
	muscle${secondaryArchSuffix}_devel = $portVersion
	devel:muscle$secondaryArchSuffix = $portVersion
	devel:libmuscle$secondaryArchSuffix = $portVersion
	"
REQUIRES_devel="
	muscle$secondaryArchSuffix == $portVersion base
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libz$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:gcc$secondaryArchSuffix
	cmd:ld$secondaryArchSuffix
	cmd:make
	"

BUILD()
{
	if [ $effectiveTargetArchitecture == x86_64 ]; then
		CXXFLAGS="-DMUSCLE_64_BIT_PLATFORM"
	fi
	export CXXFLAGS="-D_BSD_SOURCE $CXXFLAGS"
	cd server
	make $jobArgs all libmuscle.a
}

INSTALL()
{
	mkdir -p $binDir

	cd server
	cp muscled $binDir
	cp admin $binDir/muscled-admin

	mkdir -p $developLibDir
	mkdir -p $includeDir/muscle

	cp libmuscle.a $developLibDir
	cd ..
	#XXX: do we really need all of those?
	for d in message besupport dataio iogateway reflector regex \
		util support syslog system zlib zlib/zlib; do
		mkdir -p $includeDir/muscle/$d
		cp $d/*.h $includeDir/muscle/$d
	done
	packageEntries devel \
			$developDir
}
