# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=ocaml-ppx_tools
_pkgname=ppx_tools
pkgver=5.1
pkgrel=0
_ocamlver=4.06
_pkgver="$pkgver+$_ocamlver.0"
pkgdesc="Tools for authors of ppx rewriters"
url="https://github.com/ocaml-ppx/ppx_tools"
arch="all !x86 !armhf !s390x"  # limited by ocaml aport
license="MIT"
depends="ocaml-findlib ocaml-runtime"
depends_dev="$pkgname=$pkgver-r$pkgrel"
makedepends="ocaml=~$_ocamlver ocaml-compiler-libs=~$_ocamlver"
options="!check"  # no tests provided
subpackages="$pkgname-dev"
source="$pkgname-$pkgver.tar.gz::https://github.com/ocaml-ppx/$_pkgname/archive/$_pkgver.tar.gz"
builddir="$srcdir/$_pkgname-${_pkgver/+/-}"

build() {
	cd "$builddir"
	make -j1
}

package() {
	cd "$builddir"

	mkdir -p "$pkgdir/usr/lib/ocaml"
	OCAMLFIND_DESTDIR="$pkgdir/usr/lib/ocaml" \
		make install

	# Remove annotation files.
	rm -Rf "$pkgdir"/usr/lib/ocaml/$_pkgname/*.cmt*
}

dev() {
	local sitelib="usr/lib/ocaml/$_pkgname"
	default_dev

	cd "$pkgdir"/$sitelib

	mkdir -p "$subpkgdir"/$sitelib
	mv *.cmx *.cmxa *.mli "$subpkgdir"/$sitelib/
}

sha512sums="9adab758f2e68f155775559ed6568b1c3338d03291a27108b7e47a4fc5bbe65c6451c9bb90fc3270b62148213dfcc30b709b6a95e99d218884f915b48ecda9ff  ocaml-ppx_tools-5.1.tar.gz"
