# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
setvar pkgname = 'java-jffi'
setvar _pkgname = ${pkgname#java-}
setvar pkgver = '1.2.16'
setvar _libver = ${pkgver%.*}
setvar pkgrel = '0'
setvar pkgdesc = ""Java Foreign Function Interface""
setvar url = ""https://github.com/jnr/jffi""
setvar arch = ""all""
setvar license = ""ASL-2.0""
setvar depends = ""openjdk8-jre-base""
setvar makedepends = ""apache-ant file openjdk8""
setvar subpackages = ""$pkgname-native""
setvar source = ""https://github.com/jnr/$_pkgname/archive/$_pkgname-$pkgver.tar.gz""
setvar builddir = ""$srcdir/$_pkgname-$_pkgname-$pkgver""

proc build {
	cd $builddir
	ant jar
}

proc check {
	cd $builddir
	ant test
}

proc package {
	setvar depends = ""$pkgname-native""

	install -m644 -D "$builddir"/dist/jffi.jar \
		"$pkgdir"/usr/share/java/$_pkgname-$pkgver.jar || return 1
	ln -sf $_pkgname-$pkgver.jar "$pkgdir"/usr/share/java/$_pkgname.jar
}

proc native {
	# Note: jffi expects file named libjffi-x.y.so, not libjffi.so.x.y.
	install -m755 -D "$builddir"/build/jni/libjffi-$_libver.so \
		"$subpkgdir"/usr/lib/libjffi-$_libver.so
}

setvar sha512sums = ""f454b719c42fbfe1f43007c4a2c509424b7689f4a926432b6706e505b3b90e6cdae58695413a62655ad2e9513c206d0965e72a865a63c9806687238def230bf2  jffi-1.2.16.tar.gz""