# Maintainer: Felix Yan <felixonmars@archlinux.org>
# Contributor: zlowly <zlowly@gmail.com>

pkgname=smartdns
pkgver=47.1
pkgrel=1
pkgdesc="A local DNS server to obtain the fastest website IP for the best Internet experience"
arch=('x86_64')
license=('GPL')
url="https://github.com/pymumu/smartdns"
backup=("etc/smartdns/smartdns.conf")
depends=('gcc-libs' 'openssl')
makedepends=('git' 'systemd')  # systemd.pc
checkdepends=('gtest' 'bind')
source=("git+https://github.com/pymumu/smartdns.git#tag=Release$pkgver")
sha512sums=('aef917257bf3cf3d2b9f93d6eaa72d460fc1b149ee0bf114c1e3651401c6bca67de5a255c3b2010a7f9517b60051c21368369ef72d0132e0635e2f4747e08574')

prepare() {
  # Unfortunately upstream does not provide a way to reuse .o files
  cp -a smartdns smartdns-test
}

build() {
  cd smartdns
  make RUNSTATEDIR=/run SBINDIR=/usr/bin
}

check() {
  cd smartdns-test
  make -C test test
}

package() {
  cd smartdns
  make RUNSTATEDIR=/run SBINDIR=/usr/bin DESTDIR="$pkgdir" install

  rm -r "$pkgdir"/etc/init.d
}
