# Maintainer (AUR): Jakob Gahde <j5lx@fmail.co.uk>

# parabola changes and rationale:
#  - renamed tarball to avoid collisions

pkgname=jbuilder
pkgver=1.0+beta14
pkgrel=1
pkgdesc="A composable build system for OCaml"
arch=('x86_64' 'i686' 'armv7h')
url="https://github.com/janestreet/jbuilder"
license=('Apache')
depends=('ocaml' 'opam')
optdepends=('ocaml-findlib')
makedepends=('clingo')
source=("$pkgname-$pkgver.tar.gz::https://github.com/janestreet/${pkgname}/archive/${pkgver}.tar.gz")
md5sums=('7c1e8fc5fd5aa36b72c3349ba2ff3162')

prepare() {
  export OPAMROOT="${srcdir}/.opam"
  opam init -n
}

build() {
  cd "${srcdir}/dune-${pkgver/+/-}"

  make release
}

package() {
  cd "${srcdir}/dune-${pkgver/+/-}"

  export OPAMROOT="${srcdir}/.opam"

  install -dm755 "${pkgdir}$(ocamlc -where)" "${pkgdir}/usr/share"
  make install INSTALL_ARGS="'--prefix=${pkgdir}/usr' '--libdir=${pkgdir}$(ocamlc -where)'"

  mv "${pkgdir}/usr/doc" "${pkgdir}/usr/share/"
  mv "${pkgdir}/usr/man" "${pkgdir}/usr/share/"
}
