# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=check
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=0.15.2
pkgrel=4
pkgdesc="A unit testing framework for C (mingw-w64)"
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
url="https://libcheck.github.io/check/"
msys2_repository_url="https://github.com/libcheck/check"
license=("spdx:LGPL-2.1-or-later")
depends=("${MINGW_PACKAGE_PREFIX}-cc-libs"
         "${MINGW_PACKAGE_PREFIX}-libwinpthread")
makedepends=("${MINGW_PACKAGE_PREFIX}-autotools" "${MINGW_PACKAGE_PREFIX}-cc")
source=(https://github.com/libcheck/check/releases/download/${pkgver}/${_realname}-${pkgver}.tar.gz
        001-fix-build-with-mingw-w64-clang.patch)
sha256sums=('a8de4e0bacfb4d76dd1c618ded263523b53b85d92a146d8835eb1a52932fa20a'
            'b5207b8b02b47154b69b9b29a2dd0c0a9a08f0df06942babc3b9ca9c570b66b9')

prepare() {
  cd ${_realname}-${pkgver}
  patch -p1 -i "${srcdir}"/001-fix-build-with-mingw-w64-clang.patch
}

build() {
  mkdir -p "${srcdir}"/build-${MSYSTEM} && cd "${srcdir}"/build-${MSYSTEM}

  ../${_realname}-${pkgver}/configure \
    --prefix=${MINGW_PREFIX} \
    --enable-static \
    --enable-shared

  make
}

package() {
  cd "${srcdir}/build-${MSYSTEM}"
  make DESTDIR="${pkgdir}" install
}
