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.
"
COPYRIGHT="2000-2009 Meyer Sound Laboratories Inc."
LICENSE="BSD (3-clause)"
HOMEPAGE="https://public.msli.com/lcs/muscle/index.html"
SOURCE_URI="https://public.msli.com/lcs/muscle/muscle6.00.zip"
CHECKSUM_SHA256="b12abe12b5cc4aa93126f86ae07a4bcd02ee8d89d692789435debd5becc53437"
REVISION="2"

#TODO:enable multithreading for the devel package!

ARCHITECTURES="x86 x86_64"
if [ $effectiveTargetArchitecture != x86_gcc2 ]; then
	# x86_gcc2 is fine as primary target architecture as long as we're building
	# for a different secondary architecture.
	ARCHITECTURES="$ARCHITECTURES x86_gcc2"
fi
SECONDARY_ARCHITECTURES="x86"

PROVIDES="
	muscle$secondaryArchSuffix = $portVersion
	cmd:muscled$secondaryArchSuffix = $portVersion
	cmd:muscled_admin$secondaryArchSuffix = $portVersion
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libstdc++$secondaryArchSuffix
	lib:libgcc_s$secondaryArchSuffix
	"
BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libz$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:gcc$secondaryArchSuffix
	cmd:ld$secondaryArchSuffix
	cmd:make
	"

SOURCE_DIR="muscle"

PATCHES="muscle-6.00.patchset"

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
}

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