# Author: Bruno Pagani <archange@archlinux.org>
# Maintainer: Zhiwei Chen <condy0919@gmail.com)

_pkgname=yojson
pkgname=ocaml-${_pkgname}
pkgver=3.0.0
pkgrel=5
pkgdesc="Low level JSON binary for OCaml"
arch=('x86_64')
url="https://github.com/ocaml-community/${_pkgname}"
license=('BSD')
options=('!strip' 'staticlibs')
depends=('ocaml' 'ocaml-biniou' 'ocaml-easy-format')
makedepends=('dune')
source=(https://github.com/ocaml-community/${_pkgname}/releases/download/${pkgver}/${_pkgname}-${pkgver}.tbz)
sha256sums=('99414da7609b92a02474ef4b49ecda15edc8cbba5229341b124e7e4695c39610')

build() {
	cd ${_pkgname}-${pkgver}

	# no benchmarks
	rm -rf bench/

	# we're using ocaml > 4.08
	sed -i '/libraries seq/d' lib/dune

    dune build -p yojson
}

package() {
	cd ${_pkgname}-${pkgver}

	DESTDIR="${pkgdir}" dune install -p yojson --prefix=/usr --libdir="/usr/lib/ocaml"

	# remove rogue dune-package file
	rm -r "${pkgdir}"/usr/doc
	rm -r "${pkgdir}"/usr/lib/ocaml/${_pkgname}/dune-package
}
