# Maintainer: Diego Sogari <diego.sogari@falker.com.br>

_realname=cpptest
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=2.0.0
pkgrel=2
pkgdesc="A C++ Unit Testing Framework (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clangarm64')
url="https://cpptest.sourceforge.io/"
license=('LGPL')
depends=("${MINGW_PACKAGE_PREFIX}-cc-libs")
makedepends=("${MINGW_PACKAGE_PREFIX}-cc"
             "${MINGW_PACKAGE_PREFIX}-autotools")
source=("https://github.com/${_realname}/${_realname}/releases/download/${pkgver}/${_realname}-${pkgver}.tar.bz2"
        "${_realname}-${pkgver}.patch")
sha256sums=('7c258936a407bcd1635a9b7719fbdcd6c6e044b5d32f53bbf6fbf6f205e5e429'
            '364c89e288e181247ddf8a3c585f6b88dfc7f3199cf90c2a877055434175f36c')

prepare() {
  cd "${srcdir}/${_realname}-${pkgver}"
  patch -Np1 -i "${srcdir}/${_realname}-${pkgver}.patch"
  autoreconf -fvi
}

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

  ../${_realname}-${pkgver}/configure \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST} \
    --prefix=${MINGW_PREFIX} \
    --includedir=${MINGW_PREFIX}/include/cpptest

  make
}

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