# Copyright 1999-2015 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/dev-ml/uutf/uutf-0.9.4.ebuild,v 1.3 2015/04/02 08:34:38 aballier Exp $

EAPI="5"

inherit multilib

DESCRIPTION="tool to correlate occurrences of code patterns across multiple versions of a software project"
HOMEPAGE="http://coccinelle.lip6.fr/herodotos/herodotos.php"
#SRC_URI="http://coccinelle.lip6.fr/herodotos/distrib/${P}release.tbz2"
SRC_URI="https://github.com/coccinelle/herodotos/archive/v${PV}.tar.gz -> ${P}.tar.gz"

LICENSE="BSD"
SLOT="0/${PV}"
KEYWORDS="~amd64"
IUSE="doc eps pdf svg test"

RDEPEND=">=dev-lang/ocaml-3.12:=
	dev-ml/menhir:=
	dev-ml/postgresql-ocaml:=
	dev-ml/xml-light:=
	dev-ml/bolt:=
	dev-ml/parmap:=
	eps? (	dev-java/jgraph 
			app-text/ps2eps )
	svg? ( media-gfx/inkscape )
	pdf? ( app-text/pdftk
			app-text/ghostscript-gpl )"
DEPEND="${RDEPEND}
	test? ( dev-ml/cmdliner )"

DOCS=( CHANGELOG TODO )

src_configure() {
	for d in herodotos org2sql sql2jgr; do
	    cd $d
		sed -e "s:^LIBDIR=.*:LIBDIR=/usr/$(get_libdir)/ocaml/stublibs/:" \
			-e "s:^SHAREDIR=.*:SHAREDIR=/usr/$(get_libdir)/ocaml/${PN}/:" \
			-i Makefile || die
		sed -e 's:*3\\.:*4\\.:' -i configure || die
		sed -e 's:3\\.09:4\\.02\\.1:' -i configure || die
		if [ "xsql2jgr" = "x${d}" ]; then
			sed -e 's:3.0[9]:4\\.02\\.1:' -i configure || die #sql2jgr
		fi
		#econf
		./configure --opt --prefix="${EPREFIX}"/usr || die
		if [ "xsql2jgr" = "x${d}" ]; then
			echo ""
		else
			sed -e 's:/usr/man:/usr/share/man:' -i Makefile.config || die
		fi
		cd - 2> /dev/null
	done
}

src_compile() {
	emake depend || die
	emake || die
}

src_install() {
	default
}