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

inherit java-pkg-2 cvs

MY_PV=${PV//./_}
DESCRIPTION="JAI-IMAGEIO is a class library for managing images based of JAI."
HOMEPAGE="https://jai-imageio.dev.java.net/"

ECVS_SERVER="cvs.dev.java.net:/cvs"
ECVS_MODULE="jai-imageio-core"
ECVS_USER="gentoo_linux"
ECVS_PASS="peerlesspenguin"
ECVS_BRANCH="jai-imageio-1_1-fcs"

BASE=http://download.java.net/media/jai-imageio/builds/release/${PV}
MY_P="jai_imageio-${MY_PV}"

LICENSE="sun-bcla-jai-imageio"
SLOT="0"
KEYWORDS="~amd64 ~x86"
DEPEND="${DEPEND}
>=virtual/jdk-1.4
>=dev-java/ant-1.6
dev-java/java-config:2
dev-java/sun-jai-bin"
RDEPEND="dev-java/sun-jai-bin
>=virtual/jre-1.4"
IUSE=""
RESTRICT="mirror"

S=${WORKDIR}/jai-imageio-core/

src_compile() { 
	cd ${S} || die
	CLASSPATH=$CLASSPATH:`java-config -p sun-jai-bin` ant || die
	export LOC=`ant echo | grep platform | cut -d '=' -f 2 | sed -e 's/ //g'`
}

src_install() {
	OPT=${S}/build/${LOC}/opt
	cd ${OPT} || die

	dodoc *.txt || die
	
	cd ${OPT}/lib/ext || die
	java-pkg_dojar *.jar
	use x86 && cd ../i586 && java-pkg_doso *.so
	use amd64 && cd ../amd64 && java-pkg_doso *.so
	java-pkg_register-dependency sun-jai-bin
}

pkg_postinst() {
	elog "This ebuild installs /usr/share/${PN}"
	elog 'To use you need to pass the following to java'
	if use x86 || use amd64; then
		elog '-Djava.library.path=$(java-config -i sun-jai-imageio)'
	fi
	elog '-classpath $(java-config -p sun-jai-imageio)'
}