# Maintainer: Christopher Degawa <ccom@randomderp.com>

_realname=jo
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=1.4
pkgrel=1
pkgdesc='JSON output from a shell (mingw-w64)'
arch=(any)
mingw_arch=(mingw32 mingw64 ucrt64)
url=https://github.com/jpmens/jo
license=(GPL2)
source=("https://github.com/jpmens/$_realname/releases/download/$pkgver/$_realname-$pkgver.tar.gz")
sha256sums=(24c64d2eb863900947f58f32b502c95fec8f086105fd31151b91f54b7b5256a2)

build() {
  rm -rf "${srcdir}/build-${MINGW_CHOST}"
  mkdir -p "${srcdir}/build-${MINGW_CHOST}"
  cd "${srcdir}/build-${MINGW_CHOST}"  || return 1

  ../${_realname}-${pkgver}/configure \
    --prefix="${MINGW_PREFIX}" \
    --build="${MINGW_CHOST}" \
    --host="${MINGW_CHOST}"
  make
}

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

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

  # License
  install -Dm644 "${srcdir}/${_realname}-${pkgver}/COPYING" "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/COPYING"
}
