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

_realname=bcunit
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=3.0.2
pkgrel=1
pkgdesc="Lightweight system for writing, administering, and running unit tests in C (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32')
url="https://github.com/BelledonneCommunications/bcunit"
license=('LGPL2')
makedepends=('autogen')
source=("${_realname}-${pkgver}.tar.gz::https://github.com/BelledonneCommunications/bcunit/archive/${pkgver}.tar.gz")
sha256sums=('eb7090aca5006aa0cea425722cb3fa1a7139185a7d9d1734d57844f69084713f')

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

build() {
  cd "${srcdir}"/${_realname}-${pkgver}
  [[ -d "${srcdir}"/build-${CARCH} ]] && rm -rf "${srcdir}"/build-${CARCH}
  mkdir -p "${srcdir}"/build-${CARCH} && cd "${srcdir}"/build-${CARCH}
  ../${_realname}-${pkgver}/configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST} \
    --enable-static \
    --enable-shared

  make
}

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