_realname=jq
pkgname=${_realname}
pkgver=1.8.1
pkgrel=1
pkgdesc="Command-line JSON processor"
arch=('x86_64')
url='https://jqlang.github.io/jq/'
msys2_repository_url="https://github.com/jqlang/jq"
msys2_references=(
  "cpe: cpe:/a:jq_project:jq"
)
license=('spdx:MIT')
depends=('gcc-libs' 'oniguruma')
makedepends=("autotools" "gcc")
source=(
  "https://github.com/jqlang/${_realname}/releases/download/${_realname}-${pkgver}/${_realname}-${pkgver}.tar.gz"
)
sha512sums=('b09d48dbeaac7b552397b75692ed7833afa72186de80d977fb1b887a14ac66c02f677acdd79f9a2736db1fd738b7ce57a39725e34846bfa21ed3728cd7adc187')

prepare() {
  cd "${pkgname}-${pkgver}"

  # avoid it asking git for the version
  echo "echo ${pkgver}" > scripts/version
  autoreconf -fiv
}

build() {
  cd "${pkgname}-${pkgver}"

  ./configure \
    --prefix=/usr \
    --disable-docs \
    ac_cv_lib_m_scalb=no \
    ac_cv_lib_m_significand=no

  make
}

check() {
  cd "${pkgname}-${pkgver}"
  MSYSTEM=CYGWIN make check
}

package() {
  cd "${pkgname}-${pkgver}"
  make install DESTDIR="${pkgdir}"
}
