# Maintainer: Andrew Sun <adsun701@gmail.com>

_realname=bcunit
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=5.4.88
pkgrel=1
pkgdesc="Lightweight system for writing, administering, and running unit tests in C (mingw-w64)"
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
url="https://github.com/BelledonneCommunications/bcunit"
msys2_repository_url='https://github.com/BelledonneCommunications/bcunit'
license=('spdx:LGPL-2.0-or-later')
makedepends=("${MINGW_PACKAGE_PREFIX}-cc"
             "${MINGW_PACKAGE_PREFIX}-autotools"
             'autogen')
source=("https://github.com/BelledonneCommunications/bcunit/archive/${pkgver}/${_realname}-${pkgver}.tar.gz")
sha256sums=('e02f1a5e93130d3a730f35cc22a57560ea39f02d6b108fcbb2d2f811e07889d1')

prepare() {
  cd "${srcdir}/${_realname}-${pkgver}"
  [ -x configure ] || ./autogen.sh
}

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

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

  make
}

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