# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=ocaml-findlib
_pkgname=findlib
pkgver=1.7.3
pkgrel=1
pkgdesc="OCaml package manager"
url="http://projects.camlcity.org/projects/findlib.html"
arch="all !x86 !armhf !s390x"  # limited by ocaml abuild
license="MIT"
depends="ocaml ocaml-runtime"
depends_dev="$pkgname=$pkgver-r$pkgrel"
makedepends="ocaml-compiler-libs m4 ncurses-dev"
options="textrels"
subpackages="$pkgname-dev $pkgname-doc"
source="http://download.camlcity.org/download/$_pkgname-$pkgver.tar.gz
	fix-reinstallation-of-num-for-ocaml-4.06.patch"
builddir="$srcdir/$_pkgname-$pkgver"

build() {
	cd "$builddir"

	./configure \
		-sitelib /usr/lib/ocaml \
		-mandir /usr/share/man \
		-config /etc/$_pkgname.conf \
		-no-camlp4
	make -j1 all opt
}

package() {
	cd "$builddir"

	make install prefix="$pkgdir"

	mkdir -p "$pkgdir"/usr/share/doc/$_pkgname/
	install -m 644 doc/README doc/QUICKSTART \
		"$pkgdir"/usr/share/doc/$_pkgname/
}

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

	default_dev

	cd "$pkgdir"
	mkdir -p "$subpkgdir"/$sitelib
	mv $sitelib/*.cmxa \
		$sitelib/*.mli \
		$sitelib/Makefile.config \
		"$subpkgdir"/$sitelib/
}

sha512sums="5fc8250c123e2f019406be487134523f964668d615b51b216551d74f6ec1999de43aa7babc9c2c75ebb87293b4b8c640548d562a98a6e5a6d7f663432869c886  findlib-1.7.3.tar.gz
07a31d46c102cc645c5f56cd78ba5472ee18a4b1a285ff2f1295fe3333e5562ed5cdae47c070d56635c445e6e3c4f4ba732152b987ac2ffa68c0a77d7b5ba26c  fix-reinstallation-of-num-for-ocaml-4.06.patch"
