# Maintainer: nobody

_realname=libconfini
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=1.16.0
pkgrel=1
pkgdesc='Yet another INI parser (mingw-w64)'
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32')
url='https://madmurphy.github.io/libconfini'
license=('GPL')
options=('staticlibs')
makedepends=('tar')
source=("${_realname}-${pkgver}.tar.gz"::"https://github.com/madmurphy/${_realname}/archive/${pkgver}.tar.gz")
sha256sums=('38dd76b90facb93c499766e62397766d52be7fafe91d1d0020e169eb3d4308a4')
noextract=(${_realname}-${pkgver}.tar.gz)

prepare() {
  [ -d "${srcdir}/${_realname}-${pkgver}" ] && rm -rf "${srcdir}/${_realname}-${pkgver}"
  tar -xzf "${srcdir}/${_realname}-${pkgver}.tar.gz" -C "${srcdir}"
  cd "${srcdir}/${_realname}-${pkgver}"
  ./bootstrap --noconfigure
}

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

check() {
  cd "${srcdir}/build-${MINGW_CHOST}"
  make check
}

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