#!/usr/bin/make -f
include /usr/share/dpkg/default.mk

export CLASSPATH=/usr/share/java/truffle.jar

%:
	dh $@ --with javahelper

override_jh_build:
	jh_build --javacopts="-source 7" --javadoc-opts="-source 7"

override_jh_installlibs:
	mh_installpoms -plib$(DEB_SOURCE)-java
	mh_installjar  -plib$(DEB_SOURCE)-java -l debian/pom.xml $(DEB_SOURCE).jar

override_dh_clean:
	dh_clean
	mh_clean

V := $(DEB_VERSION_UPSTREAM)
MAVEN_ROOT := https://repo1.maven.org/maven2/com/oracle/$(DEB_SOURCE)

get-orig-pom:
	curl -L -o debian/pom.xml $(MAVEN_ROOT)/$(V)/$(DEB_SOURCE)-$(V).pom

get-orig-source:
	curl -L -O $(MAVEN_ROOT)/$(V)/$(DEB_SOURCE)-$(V)-sources.jar
	unzip -d $(DEB_SOURCE)-$(V).orig $(DEB_SOURCE)-$(V)-sources.jar
	GZIP=--best tar --numeric-owner --owner 0 --group 0 -zcf \
		$(DEB_SOURCE)_$(V).orig.tar.gz $(DEB_SOURCE)-$(V).orig
	-rm -rf $(DEB_SOURCE)-$(V).orig $(DEB_SOURCE)-$(V)-sources.jar
