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

pkgname=smartdns
pkgver=47
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=('2dc8593a5c83c78b23e87e569f8bc12cef7612b985d3ac4b142ee8d8947e06ff031597ce4fc9596734db6cc835535b935339f3ff8d75cfdc1bef82201212bd68')

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
}
