# Maintainer: Alexey Pavlov <alexpux@gmail.com>
# Maintainer: Chilledheart <rwindz0@gmail.com>
# Contributor: Andrew Sun <adsun701@gmail.com>

_realname=jansson
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=2.14.1
pkgrel=3
pkgdesc="C library for encoding, decoding and manipulating JSON data (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clangarm64')
url="https://www.digip.org/jansson/"
msys2_references=(
  "cpe: cpe:/a:jansson_project:jansson"
)
license=('spdx:MIT')
depends=("${MINGW_PACKAGE_PREFIX}-libwinpthread")
makedepends=("${MINGW_PACKAGE_PREFIX}-autotools" "${MINGW_PACKAGE_PREFIX}-cc")
source=("https://github.com/akheron/${_realname}/releases/download/v${pkgver}/${_realname}-${pkgver}.tar.gz")
sha256sums=('2521cd51a9641d7a4e457f7215a4cd5bb176f690bc11715ddeec483e85d9e2b3')

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}

  make
}

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

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