# Contributor: William Pitcock <nenolod@dereferenced.org>
# Maintainer: William Pitcock <nenolod@dereferenced.org>
pkgname=icedtea-web
pkgver=1.6.2
pkgrel=0
pkgdesc="web integration packages for icedtea"
url="http://icedtea.classpath.org/wiki/IcedTea-Web"
arch="x86 x86_64 ppc64le"
license="GPL"
depends="openjdk8-jre bash"
depends_dev="openjdk8 gtk+2.0-dev nspr-dev"
makedepends="tar zip bash $depends_dev npapi-sdk"
install=""
subpackages="$pkgname-mozilla $pkgname-doc"
source="http://icedtea.wildebeest.org/download/source/icedtea-web-$pkgver.tar.gz
	"
_jdkver="1.8"

_builddir="$srcdir"/icedtea-web-$pkgver
prepare() {
	local i
	cd "$_builddir"
	for i in $source; do
		case $i in
		*.patch) msg $i; patch -p1 -i "$srcdir"/$i || return 1;;
		esac
	done
}

build() {
	cd "$_builddir"
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr/lib/jvm/java-$_jdkver-openjdk \
		--datarootdir=/usr/share \
		--sysconfdir=/etc \
		--mandir=/usr/share/man \
		--infodir=/usr/share/info \
		--localstatedir=/var \
		--with-jdk-home=/usr/lib/jvm/java-$_jdkver-openjdk \
		--with-pkgversion=Alpine \
		--disable-docs \
		|| return 1
	make || return 1
}

package() {
	cd "$_builddir"
	make -j1 DESTDIR="$pkgdir" install || return 1
}

mozilla() {
	pkgdesc="web integration packages for icedtea - mozilla plugin"
	install_if="$pkgname=$pkgver-r$pkgrel firefox"
	mkdir -p "$subpkgdir"/usr/lib/mozilla/plugins
	mkdir -p "$subpkgdir"/usr/lib/jvm/java-$_jdkver-openjdk/lib
	mv "$pkgdir"/usr/lib/jvm/java-$_jdkver-openjdk/lib/IcedTeaPlugin.so \
		"$subpkgdir"/usr/lib/jvm/java-$_jdkver-openjdk/lib
	ln -sf /usr/lib/jvm/java-$_jdkver-openjdk/lib/IcedTeaPlugin.so \
		"$subpkgdir"/usr/lib/mozilla/plugins/libjavaplugin.so
	return 0
}

md5sums="ef9b7746dab933afa871428da73169f6  icedtea-web-1.6.2.tar.gz"
sha256sums="ce67034096d6b960e2b6cfb5c41a7bd6b30eb2ec7f13bf3ecdb477ff6ce69300  icedtea-web-1.6.2.tar.gz"
sha512sums="32c9618a575bf05d3fbe5fec3f8429d55036acde70bf7ccf40b59e14eba775d1f561640acbf673b1737a8c5c3a8eadb74e8f1bef525cfa6060e3f1968d45b3f7  icedtea-web-1.6.2.tar.gz"
