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

_realname=cpptest
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=2.0.0
pkgrel=1
pkgdesc="A C++ Unit Testing Framework (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32')
url="https://cpptest.sourceforge.io/"
license=('LGPL')
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc" "automake" "autoconf")
source=("https://downloads.sourceforge.net/project/${_realname}/${_realname}/${_realname}-${pkgver}/${_realname}-${pkgver}.tar.gz"
        "${_realname}-${pkgver}.patch")
sha256sums=('d5b2ac40850ebe3464b499354a213f8944f7cda556f92a00cc3a74e9841bfe52'
            '364c89e288e181247ddf8a3c585f6b88dfc7f3199cf90c2a877055434175f36c')

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

build() {
  [[ -d ${srcdir}/build-${MINGW_CHOST} ]] && rm -rf ${srcdir}/build-${MINGW_CHOST}
  mkdir "${srcdir}/build-${MINGW_CHOST}"
  cd "${srcdir}/build-${MINGW_CHOST}"

  ../${_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-${MINGW_CHOST}"
  make DESTDIR="${pkgdir}" install
}
