# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=freerdp
pkgver=2.0.0_rc1
_hash=24a752a70840f3e4b027ba7c020af71f2bcfd94a
pkgrel=0
pkgdesc="Free RDP client"
url="http://freerdp.sourceforge.net"
arch="all"
license="GPL"
depends=""
subpackages="$pkgname-dev $pkgname-plugins $pkgname-libs"
makedepends="libressl-dev libxcursor-dev cups-dev alsa-lib-dev ffmpeg-dev
	cups-dev libxkbfile-dev libxinerama-dev libxv-dev libxdamage-dev
	libjpeg-turbo-dev libxi-dev cmake bsd-compat-headers
	gst-plugins-base-dev gsm-dev linux-headers"
source="$pkgname-$pkgver.tar.gz::https://github.com/FreeRDP/FreeRDP/archive/$_hash.tar.gz
	freerdp-cmake-list.patch
	freerdp-fixes-since-24a752a.patch
	freerdp-args.patch
	musl-fix.patch
	libressl-2.5.patch
	"

_builddir="$srcdir"/FreeRDP-$_hash

prepare() {
	cd "$_builddir"
	for i in $source; do
		case $i in
		*.patch) msg $i; patch -p1 -i "$srcdir"/$i || return 1;;
		esac
	done
}

build() {
	cd "$_builddir"
	export CFLAGS="$CFLAGS -D_BSD_SOURCE"
	cmake -DCMAKE_BUILD_TYPE=Release \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DWITH_ALSA=ON \
		-DWITH_CUPS=ON \
		-DWITH_CHANNELS=ON -DSTATIC_CHANNELS=OFF \
		-DWITH_DIRECTFB=OFF \
		-DWITH_FFMPEG=OFF \
		-DWITH_GSM=ON \
		-DWITH_GSTREAMER_1_0=ON \
		-DWITH_IPP=OFF \
		-DWITH_JPEG=ON \
		-DWITH_OPENSSL=ON \
		-DWITH_PCSC=OFF \
		-DWITH_PULSE=OFF \
		-DWITH_WAYLAND=OFF \
		-DWITH_SERVER=ON \
		-DWITH_X11=ON \
		-DWITH_XCURSOR=ON \
		-DWITH_XEXT=ON \
		-DWITH_XKBFILE=ON \
		-DWITH_XI=ON \
		-DWITH_XINERAMA=ON \
		-DWITH_XRENDER=ON \
		-DWITH_XV=ON \
		-DWITH_ZLIB=ON \
		-DWITH_NEON=OFF \
		-DARM_FP_API=hard \
		|| return 1
	make
}

package() {
	cd "$_builddir"
	make DESTDIR="$pkgdir" install || return 1
}

libs() {
	pkgdesc="Free RDP client - Libraries"
	replaces="libfreerdp"
	mkdir -p "$subpkgdir"/usr
	mv "$pkgdir"/usr/lib "$subpkgdir"/usr/
}

plugins() {
	pkgdesc="Free RDP client - plugins"
	replaces="libfreerdp"
	mkdir -p "$subpkgdir"/usr/lib
	mv "$pkgdir"/usr/lib/freerdp "$subpkgdir"/usr/lib/
}

sha512sums="9bafea8e76748ac1bf278172a6876f84304197136f582a511923a6837d2bb5adf1ca85b361bb183802e631243bc97b0b72e9eafa323470b08c715b2ad711f508  freerdp-2.0.0_rc1.tar.gz
c98a19630213c7cce1fc4256987586ff38102560cff0ee4df0c937b2030f6c066e0da8337379b14d41c821652b1a85f5d296efee426e28dc0a1603b9d5ade0f7  freerdp-cmake-list.patch
76aaa3b3b631728ecf8567a09c44f5b84af494d42b4437ec5198a1fe9d0a7312fcfa5acbf45b2d2b1cda60a530c36e108d7a50581c6f63b2058fcd785499842a  freerdp-fixes-since-24a752a.patch
a845b77b6106d9a3e9d69bc0a6df3f80a6f37bed2847ace387739def695a3b07acc5e859893a9af11b7c74d96b4eeea99d9a79d5c4e4b504bacd51d612882b01  freerdp-args.patch
2a3edc5df8f2374c023b604b3f523bbc9e510a35707bef2100ac64677109dc7615a11567558aeda3b032576308ef026ed9b80ef2c479d1004f840f18d6cf0890  musl-fix.patch
2efa371fed576c08daa5450dcb48147db5740965c9b3334a842d945bd316e42f50299cbc6f137c9a0242038bf294db284bec0f214002fc313b0d795f172f0d46  libressl-2.5.patch"
