# Contributor: Alan Lacerda <alacerda@alpinelinux.org>
# Maintainer: Alan Lacerda <alacerda@alpinelinux.org>
pkgname=xrdp
pkgver=0.9.2
pkgrel=3
pkgdesc="An open source RDP server"
url="http://www.xrdp.org/"
arch="all"
license="GPL-2.0"
depends=""
depends_dev=""
makedepends="$depends_dev autoconf automake libtool libressl-dev libx11-dev
	libxfixes-dev libxrandr-dev libjpeg-turbo-dev fuse-dev linux-headers
	nasm"
install=""
subpackages="$pkgname-doc $pkgname-dev"
source="https://github.com/neutrinolabs/xrdp/releases/download/v$pkgver/xrdp-$pkgver.tar.gz
	xrdp.initd
	dynamic-link.patch
	libressl-support.patch
	"

builddir="$srcdir/$pkgname-$pkgver"

build() {
	local _simd_opt=""
	if [ "$CARCH" = "x86" ]; then
		_simd_opt="--without-simd"
	fi
	cd "$builddir"
	./bootstrap || return 1
	./configure \
		--prefix=/usr \
		--disable-static \
		--sysconfdir=/etc \
		--localstatedir=/var \
		--sbindir=/usr/sbin \
		--enable-fuse \
		--disable-pam \
		--enable-tjpeg \
		$_simd_opt \
		|| return 1
	make || return 1
}

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

	install -m755 -D "$srcdir"/$pkgname.initd \
                "$pkgdir"/etc/init.d/$pkgname || return 1
	ln -s $pkgname $pkgdir/etc/init.d/$pkgname-sesman
}

sha512sums="49626a75b0cf432436d3ac39a91d10224a264e8603523baf441e1f95f44c7cca02c0824ca48406aacfe1d9b2475abfc5703ce44254c95fd49382a57b62ee636e  xrdp-0.9.2.tar.gz
22b44398f4014ee67831051d1a1a859c6f4a601d75a03b33142ce7ea1e3f00082134337efb7da69e964f4a369d2b22114973221be2131f384f9459cc8e82fc13  xrdp.initd
c20de35c4623bcdeae2ba8a740f965b5f320c506ff9a7b9444ec0c8300af518fd3a84b8c28f6e775b7bab73bdac7433be9261d133fc767d953ac54cb2d3b0afd  dynamic-link.patch
33447c194d97b3f04e697fcdc3d0d5ca8af13c986132f9c2caa3e1173a01cfdfb9cd3bc8695558aa6b804d0f5806b2580f0a8c84a4b40d44c1d11d02c2dc002d  libressl-support.patch"
