# Copyright 1999-2007 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header$

inherit eutils java-pkg-opt-2

DESCRIPTION="GEZEL is a language and open environment for exploration, simulation and implementation of domain-specific micro-architectures."
HOMEPAGE="http://rijndael.ece.vt.edu/gezel2/index.php/Main_Page"
SRC_URI="mirror://gentoo/${P}.tar.gz"

LICENSE="LGPL-2.1"
SLOT="0"
KEYWORDS="~ppc ~x86"
IUSE="java"

RDEPEND="dev-libs/gmp
	java? ( >=virtual/jre-1.4 )"

DEPEND="dev-libs/gmp
	java? ( >=virtual/jdk-1.4 )"

src_unpack(){
	unpack ${A}
	epatch ${FILESDIR}/gezel-1.7_gentoo.patch
	# forcing regeneration of files from bison
	touch ${S}/gezel/fdl.ll
}

src_compile() {
	econf  --with-pic --enable-gezel51 $(use_enable java)|| die 'configure failed'
	emake JAVAC=javac JAVAH=javah || die 'compile failed'
	if use java; then
		cd ${S}/java/
		find . -name "*.class" | xargs jar -cf ${PN}.jar \
			|| die "failed to create jar"
		cd ${S}
	fi
}

src_install() {
	make DESTDIR=${D} install || die
	if use java; then
		rm ${D}/usr/share/*.class
		java-pkg_newjar ${S}/java/${PN}.jar
	fi

	dodoc AUTHORS BUGS NEWS README TODO doc/*.*
	docinto umlistings
	dodoc doc/umlistings/*
}


pkg_postinst() {
	if use java; then
		elog "If you want to build java apps using gezel"
		elog "add `java-config -p gezel` to your classpath "
	fi
}