# Maintainer: David Grayson <davidegrayson@gmail.com>

_realname=confuse
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=3.3
pkgrel=4
pkgdesc='Library for parsing configuration files (mingw-w64)'
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clangarm64')
url="https://github.com/martinh/libconfuse"
msys2_references=(
  "cpe: cpe:/a:libconfuse_project:libconfuse"
)
license=('custom')
makedepends=("${MINGW_PACKAGE_PREFIX}-cc" "${MINGW_PACKAGE_PREFIX}-autotools" "${MINGW_PACKAGE_PREFIX}-gettext-tools")
depends=("${MINGW_PACKAGE_PREFIX}-gettext-runtime")
source=("https://github.com/martinh/libconfuse/releases/download/v${pkgver}/confuse-${pkgver}.tar.xz")
sha256sums=('1dd50a0320e135a55025b23fcdbb3f0a81913b6d0b0a9df8cc2fdf3b3dc67010')

build() {
  rm -rf "${srcdir}/build-${MSYSTEM}"
  mkdir -p "${srcdir}/build-${MSYSTEM}"
  cd "${srcdir}/build-${MSYSTEM}"
  "../${_realname}-${pkgver}/configure" \
    --prefix="${MINGW_PREFIX}" \
    --build="${MINGW_CHOST}" \
    --host="${MINGW_CHOST}" \
    --enable-static \
    --enable-shared \
    --disable-examples

  make
}

check() {
  cd "${srcdir}/build-${MSYSTEM}"
  make check || true
}

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

  # Note that the license also gets installed in share/doc/confuse along with
  # other documentation.
  cd "${srcdir}/${_realname}-${pkgver}"
  install -Dm644 LICENSE "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/LICENSE"
}
