# 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.2
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=('f5cb8c4509a51bf293e6f46b3c7cb02092268a2feff36ab31e44fb7ff854b34f3d5ffa87de6ed223e4ed5fe374dce184356651633e5a32ba79c96a6cf3fd3d57')
b2sums=('a65bb070b96d8a68cc8366a547ebf841fbf0cccf4ee777f988e3df049d9a4d029df1bfe91f5f1fce4152254a6919b7ecd8e59aa01db387f893436a2581bb9887')
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/"
}
