# Maintainer: freaj <freaj@riseup.net>
# Contributor (AUR): HÃ¥vard Pettersson <mail@haavard.me>
# Contributor (AUR): naxuroqa <naxuroqa at gmail.com>
# Contributor (AUR): Boohbah <boohbah at gmail.com>
# Contributor (AUR): Kevin MacMartin <prurigro at gmail dot com>

_pkgname=tox
pkgname=tox-git
pkgver=r3418.4b9425f
pkgrel=1
pkgdesc='Secure, configuration-free, P2P Skype replacement backend'
arch=('i686' 'x86_64')
url='https://tox.im'
license=('GPL3')
depends=(
  'libconfig>=1.4'
  'libsodium>=1.0'
  'libvpx'
  'opus'
)
makedepends=('git' 'check')
optdepends=('qtox-git: qt-based Tox client'
            'utox-git: lightweight Tox client'
            'toxic-git: ncurses-based Tox client')
conflicts=("$_pkgname")
provides=("$_pkgname")
replaces=("$_pkgname")
source=("$_pkgname::git+https://github.com/irungentoo/toxcore.git")
sha512sums=('SKIP')

pkgver() {
  cd $_pkgname
  printf 'r%s.%s' "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
}

build() {
  cd $_pkgname
  autoreconf -if
  ./configure \
    --prefix=/usr \
    --enable-daemon \
    --disable-ntox \
    --disable-tests
  make
}

check() {
  cd $_pkgname
  make check
}

package() {
  cd $_pkgname
  make DESTDIR="$pkgdir" install
  install -Dm644 ./other/bootstrap_daemon/tox-bootstrapd.service "$pkgdir/usr/lib/systemd/system/tox-bootstrapd.service"
}