# Template file for 'freerdp'
pkgname=freerdp
version=2.9.0
revision=1
build_style=cmake
configure_args="-DWITH_ALSA=ON -DWITH_CUPS=OFF -DWITH_FFMPEG=ON
 -DWITH_GSTREAMER_0_10=OFF -DWITH_GSTREAMER_1_0=OFF -DWITH_JPEG=ON
 -DWITH_LIBSYSTEMD=OFF -DWITH_PCSC=OFF -DWITH_PULSE=ON -DWITH_WAYLAND=ON
 -DWITH_XCURSOR=ON -DWITH_XEXT=ON -DWITH_XI=ON -DWITH_XINERAMA=ON
 -DWITH_XKBFILE=ON -DWITH_XRENDER=ON -DWITH_XV=ON -DWITH_SERVER=ON
 -DWAYLAND_SCANNER=/usr/bin/wayland-scanner -DWITH_CAIRO=ON"
hostmakedepends="pkg-config xmlto wayland-devel"
makedepends="alsa-lib-devel ffmpeg-devel glib-devel libusb-devel
 libXcursor-devel libXinerama-devel libXrandr-devel libXv-devel
 libjpeg-turbo-devel openssl-devel libxkbfile-devel pulseaudio-devel
 libxkbcommon-devel wayland-devel cairo-devel libXdamage-devel"
short_desc="Free RDP (Remote Desktop Protocol) client"
maintainer="Orphaned <orphan@voidlinux.org>"
license="Apache-2.0"
homepage="https://www.freerdp.com/"
changelog="https://raw.githubusercontent.com/FreeRDP/FreeRDP/stable-2.0/ChangeLog"
distfiles="https://github.com/FreeRDP/FreeRDP/archive/${version}.tar.gz"
checksum=ab8de7e962bdc3c34956160de2de8ed28423d39a78452b7686b72c94b1953b27
CFLAGS="-Wno-dev"

case "$XBPS_TARGET_MACHINE" in
	i686*|x86_64*) configure_args+=" -DWITH_SSE2=ON";;
	armv5tel*) configure_args+=" -DWITH_NEON=OFF";;
esac

post_install() {
	rm -f ${DESTDIR}/usr/lib64
}

# first we want to separate -server, everything else then goes to client
subpackages="libfreerdp-server freerdp-server freerdp-server-devel libfreerdp
 freerdp-devel"

libfreerdp_package() {
	replaces="${sourcepkg}<1.0.2_2"
	short_desc+=" - runtime libraries"
	pkg_install() {
		vmove "usr/lib/*.so.*"
	}
}

freerdp-devel_package() {
	short_desc+=" - development files"
	depends="openssl-devel lib${sourcepkg}>=${version}_${revision}"
	pkg_install() {
		vmove usr/include
		vmove usr/lib/cmake
		vmove usr/lib/pkgconfig
		vmove "usr/lib/*.so"
	}
}

libfreerdp-server_package() {
	short_desc="Free RDP (Remote Desktop Protocol) server - runtime files"
	depends="libfreerdp>=${version}_${revision}"
	pkg_install() {
		vmove "usr/lib/libfreerdp-server*.so.*"
		vmove "usr/lib/libfreerdp-shadow*.so.*"
	}
}

freerdp-server_package() {
	short_desc="Free RDP (Remote Desktop Protocol) server"
	depends="libfreerdp-server>=${version}_${revision}"
	pkg_install() {
		vmove usr/bin/freerdp-proxy
		vmove usr/bin/freerdp-shadow-cli
		vmove usr/share/man/man1/freerdp-shadow-cli.1
	}
}

freerdp-server-devel_package() {
	depends="libfreerdp-server>=${version}_${revision}"
	short_desc="Free RDP (Remote Desktop Protocol) server - development files"
	pkg_install() {
		vmove usr/lib/cmake/FreeRDP-Server2
		vmove usr/lib/cmake/FreeRDP-Shadow2
		vmove usr/lib/pkgconfig/freerdp-server2.pc
		vmove usr/lib/pkgconfig/freerdp-shadow2.pc
		vmove "usr/lib/libfreerdp-server*.so"
		vmove "usr/lib/libfreerdp-shadow*.so"
	}
}
