# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=ocaml-ppx_tools_versioned
_pkgname=ppx_tools_versioned
pkgver=5.1
pkgrel=3
pkgdesc="Tools for authors of ppx rewriters"
url="https://github.com/ocaml-ppx/ppx_tools_versioned"
arch="all !x86 !armhf !s390x"  # limited by ocaml aport
license="MIT"
depends="ocaml-runtime ocaml-migrate-parsetree"
makedepends="ocaml ocaml-compiler-libs ocaml-findlib ocaml-migrate-parsetree-dev ocaml-result-dev"
# textrels needed for ppc64le
# no tests provided
options="textrels !check"
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
}

package() {
	cd "$builddir"

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

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

dev() {
	default_dev
	depends="$pkgname=$pkgver-r$pkgrel"
	local sitelib="usr/lib/ocaml/$_pkgname"

	cd "$pkgdir"/$sitelib

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

sha512sums="b3412dc204ed3aed42c99f0e900108f5003a96e39b3a78df279c5e9512f14ceb77dde2ff2d552fb0386d43a5f276feca3bd306286a860e13680c94d39421125d  ocaml-ppx_tools_versioned-5.1.tar.gz"
