# Maintainer: Márcio Silva <coadde@hyperbola.info>

_pkgname=xpra
pkgname=$_pkgname-gtk2
pkgver=0.17.6
pkgrel=1
pkgdesc='multi-platform X11 screen and application forwarding system'
arch=('i686' 'x86_64' 'armv7h')
license=('GPL2')
url="https://www.$_pkgname.org"
backup=("etc/$_pkgname/"{xorg,$_pkgname}".conf")
depends=('pygtk' 'ffmpeg' 'python2-cairo' 'xorg-server' 'xvidcore') # 'libwebp' disabled tmp
optdepends=('cups: CUPS (printing) support'
            'python2-lcms: LittleCMS support'
            'python2-lz4: LZ4 compression support'
            'python2-lzo: LZO compression support'
            'python2-pycups: CUPS (printing) support'
            'python2-pyopencl: OpenCL support'
            'x11-ssh-askpass: OpenSSH passphrase dialog support'
            'xf86-video-dummy: Xdummy support')
makedepends=('cups' 'cython2' 'lsb-release' 'xf86-video-dummy')
conflicts=("$_pkgname")
source=("$url/src/$_pkgname-$pkgver.tar.xz")
sha1sums=('9559c384531aaba051182b9a9c50dde82435fa17')

prepare() {
  cd $_pkgname-$pkgver
  # remove xvid pkgconfig, due xvidcore package does not exist
  sed -i 's|[ ]and[ ]pkg_config_ok[(]["]--exists["][,][ ]["]xvid["][)]||
          \|xvid_pkgconfig[ ][=][ ]pkgconfig[(]["]xvid["][)]|d
          s|[[]["]xpra/codecs/xvid/encoder[.]pyx["][,][ ]buffers_c[]][,]|["xpra/codecs/xvid/encoder.pyx", buffers_c]))|
          \|[*][*]xvid_pkgconfig[)][)]|d
         ' setup.py
}

package() {
  cd $_pkgname-$pkgver
  CFLAGS="$CFLAGS -fno-strict-aliasing" python2 setup.py build install \
    --root=$pkgdir \
    --with-{csc_opencl,gtk_x11,server,shadow,verbose,Xdummy{,_wrapper},xvid} \
    --without-{csc_libyuv,webp}
}
