SUMMARY="Free implementation of the Remote Desktop Protocol"
DESCRIPTION="FreeRDP is a free implementation of the Remote Desktop Protocol (RDP), \
released under the Apache license. Enjoy the freedom of using your software wherever \
you want, the way you want it, in a world where interoperability can finally \
liberate your computing experience."
HOMEPAGE="https://freerdp.com"
COPYRIGHT="FreeRDP team"
LICENSE="Apache v2"
REVISION="1"
SOURCE_URI="https://github.com/FreeRDP/FreeRDP/releases/download/$portVersion/freerdp-$portVersion.tar.gz"
CHECKSUM_SHA256="ef75c87926643a0d0041f6556e343ac037380d4260c64885e7cdd20da0147edf"
SOURCE_DIR="freerdp-$portVersion"
PATCHES="freerdp-$portVersion.patchset"

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

PROVIDES="
	freerdp$secondaryArchSuffix = $portVersion
	cmd:FreeRDP$secondaryArchSuffix = $portVersion
	cmd:winpr_hash$secondaryArchSuffix = $portVersion
	cmd:winpr_makecert$secondaryArchSuffix = $portVersion
	lib:libfreerdp2$secondaryArchSuffix = $portVersion
	lib:libfreerdp_client2$secondaryArchSuffix = $portVersion
	lib:libwinpr2$secondaryArchSuffix = $portVersion
	lib:libwinpr_tools2$secondaryArchSuffix = $portVersion
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libavcodec$secondaryArchSuffix
	lib:libavformat$secondaryArchSuffix
	lib:libavutil$secondaryArchSuffix
	lib:libcrypto$secondaryArchSuffix
	lib:libexecinfo$secondaryArchSuffix
	lib:libjpeg$secondaryArchSuffix
	lib:libssl$secondaryArchSuffix
	lib:libz$secondaryArchSuffix
	"

PROVIDES_devel="
	freerdp${secondaryArchSuffix}_devel = $portVersion
	devel:libfreerdp2$secondaryArchSuffix = $portVersion
	devel:libfreerdp_client2$secondaryArchSuffix = $portVersion
	devel:libwinpr2$secondaryArchSuffix = $portVersion
	devel:libwinpr_tools2$secondaryArchSuffix = $portVersion
	"
REQUIRES_devel="
	freerdp$secondaryArchSuffix == $portVersion base
	haiku$secondaryArchSuffix
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libavcodec$secondaryArchSuffix
	devel:libavformat$secondaryArchSuffix
	devel:libavutil$secondaryArchSuffix
	devel:libcrypto$secondaryArchSuffix
	devel:libexecinfo$secondaryArchSuffix
	devel:libjpeg$secondaryArchSuffix
	devel:libssl$secondaryArchSuffix
	devel:libz$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:cmake
	cmd:gcc$secondaryArchSuffix
	cmd:ld$secondaryArchSuffix
	cmd:make
	cmd:pkg_config$secondaryArchSuffix
	"

BUILD()
{
	mkdir -p build
	cd build
	LDFLAGS=-Wl,--no-undefined \
	cmake .. $cmakeDirArgs \
		-DCMAKE_BUILD_TYPE=Release \
		-DWITH_GSTREAMER_1_0=OFF \
		-DWITH_FFMPEG=ON \
		-DWITH_SWSCALE=ON \
		-DWITH_JPEG=ON \
		-DWITH_CUPS=OFF \
		-DWITH_OSS=OFF \
		-DWITH_PULSE=OFF \
		-DCHANNEL_URBDRC=OFF \
		-DBUILD_SHARED_LIBS=ON
	make $jobArgs
}

INSTALL()
{
	cd build
	make install
	mkdir -p $includeDir
	cp -f client/Haiku/FreeRDP $binDir
	ln -s $binDir/FreeRDP $binDir/freerdp
	mv $prefix/include/* $includeDir
	rm -rf $prefix/include

	fixPkgconfig

	prepareInstalledDevelLibs \
		libfreerdp-client2 \
		libfreerdp2 \
		libwinpr-tools2 \
		libwinpr2

	packageEntries devel \
		$developDir \
		$libDir/cmake
}
