SUMMARY="Open source command-line RTMP client"
DESCRIPTION="rtmpdump is an open-source command-line RTMP client intended \
to stream audio of video flash content."
HOMEPAGE="http://rtmpdump.mplayerhq.hu/"
COPYRIGHT="2009 Andrej Stepanchuk
	2009-2011 Howard Chu
	2010 2a665470ced7adb7156fcef47f8199a6371c117b8a79e399a2771e0b36384090
	2011 33ae1ce77301f4b4494faaa5f609f3c48b9dcf82
	"
LICENSE="GNU LGPL v2.1
	GNU GPL v2
	"
REVISION="6"
SOURCE_URI="https://sources.voidlinux.org/rtmpdump-2.4.20161210/rtmpdump-2.4_p20161210.tar.gz"
CHECKSUM_SHA256="d6da3b683f1045f02d94a81b0c583318dba021f69bdab970c5d5d73e8c38860f"
SOURCE_DIR=""
PATCHES="
	rtmpdump-2.4_git.patch
	rtmpdump-openssl-1.1-v2.patch
	"

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

PROVIDES="
	rtmpdump$secondaryArchSuffix = $portVersion compat >= 2.4
	cmd:rtmpdump = $portVersion compat >= 2.4
	cmd:rtmpgw = $portVersion compat >= 2.4
	cmd:rtmpsrv = $portVersion compat >= 2.4
	cmd:rtmpsuck = $portVersion compat >= 2.4
	lib:librtmp.1$secondaryArchSuffix = 1 compat >= 1
	"
# commands are provided in /bin regardless
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libssl$secondaryArchSuffix
	lib:libz$secondaryArchSuffix
	"

PROVIDES_devel="
	rtmpdump${secondaryArchSuffix}_devel = $portVersion compat >= 2.4
	devel:librtmp$secondaryArchSuffix = 1 compat >= 1
	devel:librtmp.1$secondaryArchSuffix = 1 compat >= 1
	"
REQUIRES_devel="
	rtmpdump$secondaryArchSuffix == $portVersion
	"

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

BUILD()
{
	make $jobArgs SYS=haiku \
		prefix=$prefix \
		bindir=$binDir \
		sbindir=$binDir \
		incdir=$includeDir \
		libdir=$libDir \
		mandir=$manDir
}

INSTALL()
{
	mkdir -p $libDir $binDir $manDir $includeDir

	make $jobArgs SYS=haiku \
		prefix=$prefix \
		bindir=$binDir \
		sbindir=$binDir \
		incdir=$includeDir \
		libdir=$libDir \
		mandir=$manDir \
		install

	prepareInstalledDevelLibs \
		librtmp.1
	rm $libDir/librtmp.so
	mv $libDir/librtmp.a $developLibDir

	mkdir $includeDir/librtmp
	mv $includeDir/*.h $includeDir/librtmp

	fixPkgconfig

	sed -i "s|libdir=.*|libdir=$developLibDir|" $developLibDir/pkgconfig/librtmp.pc
	sed -i "s|incdir=.*|incdir=$includeDir|" $developLibDir/pkgconfig/librtmp.pc

	# devel package
	packageEntries devel \
		$developDir

}
