pkgname=check
pkgver=0.15.2
pkgdesc="Unit testing framework for C"
url="https://libcheck.github.io/check/"
arch=(x86_64)
license=(LGPL-2.1-or-later)
depends=(
  awk
  gcc-libs
  glibc
)
makedepends=(
  cmake
  ninja
)
_patches=("check-0.14.0-r2-disable-automagic-dep.patch"
  "check-0.15.2-Fix-pkgconfig-file-s-libdir-value.patch"
  "check-0.15.2-avoid-static-lib.patch"
)
_patch_sums=("2db61d66f1e7fe682db3670f581d300a"
  "a05bd4221f99dcc3d920ced659a26b35"
  "9bfe4e3f930d58ba691d99c7cd39b965"
)
sources=("${pkgname}-${pkgver}.tar.gz"
  "${_patches[@]}"
)
urls=("https://github.com/libcheck/check/archive/${pkgver}.tar.gz"
  "${_patches[@]}"
)
md5sums=("2528f5cff61db6d53d44fb95da0c7fce"
  "${_patch_sums[@]}"
)

src_prepare() {
  tar -xf ${distdir}/${sources[0]} --strip-components=1
  for _patch in ${_patches[@]}; do
    patch -p1 -i ${filedir}/${_patch}
  done
}

src_build() {
  local cmake_options=(
    -D AWK_GSUB_DBL_BSLASH='\\\\'
    -D CHECK_ENABLE_TIMEOUT_TESTS=OFF
    -D CMAKE_BUILD_TYPE=None
    -D CMAKE_INSTALL_PREFIX=/usr
    -D CHECK_ENABLE_SUBUNIT=OFF
  )
  cmake -B build -G Ninja "${cmake_options[@]}"
  cmake --build build
}

src_install() {
  DESTDIR="$pkgdir" cmake --build build --target install
}

# vim:ft=sh syn=sh et sw=2:
