#!/usr/bin/bash
# JOBoRun		: Jwm OpenBox Obarun RUNit
# Maintainer		: Joe Bo Run <joborun@disroot.org>
# PkgSource		: url="https://gittea.disroot.org/joborun-pkg/jobcore/$pkgname"
#-----------------------------------------| DESCRIPTION |---------------------------------------

pkgname=json-c
pkgver=0.17
pkgrel=01
pkgdesc="A JSON implementation in C"
url="https://github.com/json-c/json-c/wiki"
depends=(glibc)
makedepends=(git cmake ninja)
provides=(libjson-c.so)
#options=(debug)
_commit=b4c371fa0cbc4dcbaccc359ce9e957a22988fb34  # tags/json-c-0.17-20230812^0
source=("git+https://github.com/json-c/json-c#commit=$_commit")

pkgver() {
  cd json-c
  local tag="$(git describe --tags --abbrev=0)"
  local ver="$(git describe --tags)"
  echo "${tag%-*}${ver#$tag}" | sed 's/^json-c-//;s/[^-]*-g/r&/;s/-/+/g'
}

prepare() {
  cd json-c
}

build() {
  cmake -S json-c -B build -G Ninja \
    -DCMAKE_BUILD_TYPE=None \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DCMAKE_INSTALL_LIBDIR=/usr/lib \
    -DBUILD_STATIC_LIBS=OFF \
    -DENABLE_THREADING=ON \
    -DENABLE_RDRAND=OFF
  cmake --build build
}

check() {
  cd build
  ctest --output-on-failure --stop-on-failure -j$(nproc)

}

package() {
  DESTDIR="$pkgdir" cmake --install build
  install -Dt "$pkgdir/usr/share/licenses/$pkgname" -m644 json-c/COPYING
}

#---- arch license gpg-key & sha256sums ----

arch=(x86_64)

license=(MIT)

sha256sums=(SKIP)

##  2d75b90af733938b77b372e8a2884d4d96d25206b691646e655ca6042ad2e459  json-c-0.17-01-x86_64.pkg.tar.lz

