SUMMARY="Open-source implementation of the Java Platform, SE"
DESCRIPTION="OpenJDK (Open Java Development Kit) is a free and open source \
implementation of the Java Platform, Standard Edition (Java SE). It is the \
result of an effort Sun Microsystems began in 2006. The implementation is \
licensed under the GNU General Public License (GNU GPL) with a linking \
exception. Were it not for the GPL linking exception, components that linked \
to the Java class library would be subject to the terms of the GPL license. \
OpenJDK is the official Java SE 7 reference implementation."
HOMEPAGE="http://openjdk.java.net/"
COPYRIGHT="2012 Oracle and/or its affiliates."
LICENSE="GNU GPL v2"
REVISION="1"
case "$effectiveTargetArchitecture" in
	x86)
SOURCE_URI="https://korli.keybase.pub/openjdk_x86-1.7.u80_b32-3-x86_gcc2.hpkg#noarchive"
CHECKSUM_SHA256="1fb7a47c0b5b630905884eee3a080b35a3cd2b1d8dbe9ecfe8d0206c1f39e76a"
		;;
	x86_64)
SOURCE_URI="https://korli.keybase.pub/openjdk-1.8.u192_b26-haiku-x86_64.tar.gz#noarchive"
CHECKSUM_SHA256="ccd8cf571db45b6e130d0309f4ae5c861710d910cb69456306c4cccf82603a3e"
		;;
esac

ARCHITECTURES="all !x86_gcc2"
SECONDARY_ARCHITECTURES="x86"
DISABLE_SOURCE_PACKAGE="yes"

PROVIDES="
	openjdk7_bin$secondaryArchSuffix = $portVersion compat >= 1.7
	java:environment = 7
	"

REQUIRES="
	haiku$secondaryArchSuffix
	lib:libfreetype$secondaryArchSuffix
	lib:libiconv$secondaryArchSuffix
	lib:libz$secondaryArchSuffix
	"

BUILD_REQUIRES="
	haiku
	"

BUILD_PREREQUIRES="
	cmd:gzip
	cmd:tar
	"

INSTALL()
{
	jdkDir=$libDir/openjdk7
	mkdir -p $(dirname $jdkDir)

	case "$effectiveTargetArchitecture" in
		x86)
		package extract $sourceDir/openjdk_x86-1.7.u80_b32-3-x86_gcc2.hpkg \
			lib/x86/openjdk
		mv lib/x86/openjdk $jdkDir
			;;
		x86_64)
		tar xvf $sourceDir/openjdk-1.8.u192_b26-haiku-x86_64.tar.gz -C $libDir
		mv $libDir/openjdk8 $jdkDir
			;;
	esac

	# create a profile.d file that sets up JDK7_HOME
	jdkProfile=$dataDir/profile.d/openjdk7.sh
	mkdir -p $(dirname $jdkProfile)
	echo "JDK7_HOME=$jdkDir" > $jdkProfile
	echo "export JDK7_HOME" >> $jdkProfile
}
