# $Id: PKGBUILD 140567 2015-09-17 20:53:53Z foutrelis $
# Maintainer: Massimiliano Torromeo <massimiliano.torromeo@gmail.com>
# Contributor: David Stelter <david.stelter@gmail.com>
# Contributor: Francisco Lopes <chico.lopes@gmail.com>

pkgname='pfff'
pkgver=0.29
pkgrel=3

pkgdesc='Tools and APIs for code analysis, visualization and transformation'
arch=('i686' 'x86_64')
url='https://github.com/facebook/pfff'
license=('LGPL2.1')
depends=('ocaml' 'ocaml-findlib' 'camlp4' 'zlib')
optdepends=('gtk2: required by codegraph and codemap')
options=(!makeflags staticlibs) # parallel build fails, need *.a files
source=("$pkgname-$pkgver.tar.gz::https://github.com/facebook/pfff/archive/v$pkgver.tar.gz"
"lang_js-analyze-module_js.ml-Fix-invalid-documentati.patch"
"lang_js-analyze-utils_js.mli.patch")
sha256sums=('d31c68f1ebb1770297eb26441d21d83728c0fbdb9c7bb3be27625db45fae72d1'
            '28b220807087b9378e0fcab1187163cdeb8d3da80f53f00ec9af434467ace57f'
            'bb10f6b25afe0cd0df5084d9e3624f43cbf7489b148c67d99479d11cf90999b7')

prepare() {
	cd "$srcdir"/$pkgname-$pkgver
	patch -Np1 -i ../lang_js-analyze-utils_js.mli.patch
	patch -Np1 -i ../lang_js-analyze-module_js.ml-Fix-invalid-documentati.patch
}

build() {
	cd "$srcdir"/$pkgname-$pkgver
	./configure --prefix=/usr
	make clean
	make depend
	make
	make opt
}

package() {
	cd "$srcdir"/$pkgname-$pkgver
	make DESTDIR=$pkgdir install
	install -dm755 "$pkgdir"/usr/lib/ocaml
	make OCAMLFIND_LDCONF="$pkgdir"/tmp/ld.conf OCAMLFIND_DESTDIR="$pkgdir"/usr/lib/ocaml install-findlib
}
