# POWER Maintainer: Alexander Baldeck <alex.bldck@gmail.com>
# Maintainer: David Runge <dvzrv@archlinux.org>
# Contributor: Dave Reisner <dreisner@archlinux.org>
# Contributor: Daniel J Griffiths <ghost1227@archlinux.us>
# Contributor: Jeff Mickey <jeff@archlinux.org>
# Contributor: Alexander Fehr <pizzapunk gmail com>

pkgname=c-ares
pkgver=1.34.4
pkgrel=1
pkgdesc="A C library for asynchronous DNS requests"
arch=(x86_64 powerpc64le powerpc64 powerpc riscv64)
url="https://c-ares.org/"
_url=https://github.com/c-ares/c-ares
license=(MIT)
depends=(glibc)
makedepends=(
  cmake
  git
)
provides=(libcares.so)
source=(
  git+$_url.git?signed#tag=v$pkgver
)
sha512sums=('17a50051b73a6690b616fba45da1151c412c3112808c2636533a0b94b94fa8c34ecc0118d8fadaefa88423b6a66c66530bcd36a575aa2a7ae80b4e80c161d96b')
b2sums=('3c9f414a842911dca79cb2b550dd12eda073683b91537c2a205311cc0c75c97ed9ea86aa018cdf5909fed7e468d04b6a436700a0a7cbd0bd33c9517c136a3b80')
validpgpkeys=(
  27EDEAF22F3ABCEB50DB9A125CC908FDB71E12C2  # Daniel Stenberg <daniel@haxx.se>
  DA7D64E4C82C6294CB73A20E22E3D13B5411B7CA  # Brad House <brad@brad-house.com>
)

build() {
  local cmake_options=(
    -B build
    -D CMAKE_INSTALL_PREFIX=/usr
    -D CMAKE_BUILD_TYPE=None
    -S $pkgname
    -W no-dev
  )
  cmake "${cmake_options[@]}"
  cmake --build build --verbose
}

check() {
  ctest --test-dir build --output-on-failure
}

package() {
  DESTDIR="$pkgdir" cmake --install build
  install -vDm 644 $pkgname/LICENSE.md -t "$pkgdir/usr/share/licenses/$pkgname/"
  install -vDm 644 $pkgname/{AUTHORS,{CONTRIBUTING,README,RELEASE-NOTES}.md} -t "$pkgdir/usr/share/doc/$pkgname/"
}
