# Maintainer (aur): Olivia Mackintosh <livvy@base.nu>
# Contributor: Bryce Chidester <bryce@cobryce.com>
# Contributor: bill-auger <bill-auger@programmer.net>


# parabola changes and rationale:
# - in [libre] for pbot


pkgname=purple-matrix
pkgver=20210210
_gitrev=2fcd5b8f901034980616e5f719750c48f37a332f
pkgrel=2
pkgdesc="Libpurple protocol plugin for matrix."
arch=(armv7h ui686 x86_64)
url="https://github.com/matrix-org/purple-matrix"
license=('GPL2')
depends=('libpurple' 'http-parser' 'glib2' 'json-glib')
depends+=('libgcrypt' 'libolm')
source=(${pkgname}-${pkgver}.tar.gz::https://github.com/matrix-org/${pkgname}/archive/${_gitrev}.tar.gz)
sha256sums=('80a41992c6cb3bae3248af463e9b1a051e9553664ecba2d38ad1f193932e92d3')


source+=(matrix-segfault.patch
matrix-chat.patch
cloudflare.patch)
sha256sums+=('9103debb8189dbc194e5c759ce8b9d1c607e50af005e291e5a405a161342f63f'
            'd1ba04c302686b49940f1048032adeb08667e74325cf9cb3973971f15579cb0c'
            '7d5d360bc69cc32d7c18cb867c2c23560a5e9518c97d42ff0ec90915d2ce8aac')




prepare()
{
  cd "${srcdir}"/${pkgname}-${_gitrev}

  echo "applying matrix-segfault.patch"
  patch -Np1 < "${srcdir}"/matrix-segfault.patch
  echo "applying matrix-chat.patch"
  patch -Np1 < "${srcdir}"/matrix-chat.patch
  echo "applying cloudflare.patch"
  patch -Np1 < "${srcdir}"/cloudflare.patch
}


build()
{
  cd "${srcdir}"/${pkgname}-${_gitrev}

  export CPPFLAGS="$CPPFLAGS -O2"
  make
}

package()
{
  cd "${srcdir}"/${pkgname}-${_gitrev}

  make DESTDIR="${pkgdir}" install
}
