# Maintainer: Levente Polyak <anthraxx[at]archlinux[dot]org>
# Contributor: Bartłomiej Piotrowski <bpiotrowski@archlinux.org>
# Contributor: jason ryan <jasonwryan@gmail.com>
# Contributor: Christian Rebischke <chris.rebischke@archlinux.org>

pkgbase=profanity
pkgname=('profanity' 'profanity-gtk')
pkgver=0.18.0
pkgrel=1
epoch=1
pkgdesc='Console based XMPP client'
url='https://profanity-im.github.io'
arch=('x86_64')
license=('GPL3')
_clidepends=(
  'libcurl.so' 'libncursesw.so' 'expat' 'glib2' 'libotr'
  'libnotify.so' 'libgpgme.so' 'python' 'libgcrypt' 'libsignal-protocol-c'
  'glibc' 'libreadline.so' 'libassuan' 'libgpg-error' 'libstrophe.so'
  )
_gtkdepends=(
  'libgtk-3.so' 'libxss' 'libx11' 'gdk-pixbuf2' 'cairo'
  )
makedepends=(
  ${_clidepends[@]} ${_gtkdepends[@]} 'meson'
  )
checkdepends=('cmocka')
source=(https://github.com/profanity-im/profanity/archive/${pkgver}/${pkgbase}-${pkgver}.tar.gz)
sha256sums=('6d5571ba15968bbc010c43d4f31a2274718cbfe431cc309f3838c8012c1c54d7')
sha512sums=('f7f9ecb62acf31acfb415804022be1667cff55afbe47764b8fe828feef3521f231fd6a1a5182fa7a2ee1dacbab61c9069579984a5efd55688681763a4bde2810')
b2sums=('1c97975dda361d18df529165899221e2e1a1fc99d41a015a100064f114d879927d8eef055f8c512d583fb6680fcdf5fb2d95f5d8942485f8180e6ae7dc632fdc')

prepare() {
  cp -a "${srcdir}"/${pkgname}-${pkgver}{,-gtk}
}

build() {
  echo "Building non-gtk variant..."
  (
    local meson_options=(
      -D icons-and-clipboard=disabled
      -D xscreensaver=disabled
      -D notifications=enabled
      -D python-plugins=enabled
      -D c-plugins=enabled
      -D otr=enabled
      -D omemo=enabled
      -D pgp=enabled
    )

    arch-meson ${pkgname}-${pkgver} build "${meson_options[@]}"
    meson compile -C build
  )
  echo "Building gtk variant..."
  (
    local meson_options=(
      -D icons-and-clipboard=enabled
      -D xscreensaver=enabled
      -D notifications=enabled
      -D python-plugins=enabled
      -D c-plugins=enabled
      -D otr=enabled
      -D omemo=enabled
      -D pgp=enabled
    )

    arch-meson ${pkgname}-${pkgver} build-gtk "${meson_options[@]}"
    meson compile -C build-gtk
  )
}

package_profanity() {
  depends=(
    ${_clidepends[@]}
  )
  meson install -C build --destdir "${pkgdir}"
}

package_profanity-gtk() {
  pkgdesc+=' (gtk support)'
  depends=(
    ${_clidepends[@]} ${_gtkdepends[@]}
  )
  provides=('profanity')
  conflicts=('profanity')
  meson install -C build-gtk --destdir "${pkgdir}"
}

# vim: ts=2 sw=2 et:
