SUMMARY="BitTorrent DHT library"
DESCRIPTION="dht implement the variant of the Kademlia Distributed Hash \
Table (DHT) used in the Bittorrent network (\"mainline\" variant)."
HOMEPAGE="https://github.com/transmission/dht"
COPYRIGHT="2009-2010 by Juliusz Chroboczek"
LICENSE="MIT"
REVISION="1"
SOURCE_URI="https://github.com/transmission/dht/archive/dht-$portVersion.tar.gz"
CHECKSUM_SHA256="3873d54b786cf74090672ed6f786b82510ae375d5a8d8f4d99314e358d898baa"
SOURCE_DIR="dht-dht-$portVersion"

ARCHITECTURES="all ?x86_gcc2 ?x86"
SECONDARY_ARCHITECTURES="x86"

libVersion="2.1"
libVersionCompat="$libVersion compat >= 2"

PROVIDES="
	dht$secondaryArchSuffix = $portVersion
	lib:libdht$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES="
	haiku$secondaryArchSuffix
	"

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

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	"
BUILD_PREREQUIRES="
	cmd:gcc$secondaryArchSuffix
	"

BUILD()
{
	gcc -o dht.o -c dht.c
	gcc -shared -o libdht.so dht.o
}

INSTALL()
{
	mkdir -p $includeDir/dht $libDir
	cp dht.h $includeDir/dht
	cp libdht.so $libDir

	mkdir -p $developLibDir/pkgconfig
	# No need to call prepareInstalledDevelLibs
	cat > $developLibDir/pkgconfig/dht.pc << EOF
prefix=${prefix}
exec_prefix=${prefix}
libdir=${libDir}
includedir=${includeDir}

Name: dht
Description: BitTorrent DHT library
Version: $portVersion
Libs: -L${developLibDir} -ldht
Cflags: -I${includeDir}/dht
EOF

	prepareInstalledDevelLibs libdht
	packageEntries devel \
		$developDir
}
