#!/usr/bin/make -f

export DH_VERBOSE=1

include $(CURDIR)/build.number
BUNDLE_VERSION="$(version.major).$(version.minor).$(version.patch)"

%:
	dh $@ --with javahelper --with jh_maven_repo_helper

override_dh_auto_build:
	# Build Jline
	ant -f debian/build-jline.xml -propertyfile debian/ant-jline.properties
	# Build Scala
	ANT_OPTS="-Xmx1024M -Xss64M" \
	ant -Dversion.number=$(BUNDLE_VERSION) \
	    -Djunit.version=4.x \
	    -Dextra.repo.url=file:///usr/share/maven-repo \
	    -Dlibrary.starr.jar=/usr/share/java/scala-library.jar \
	    -Dreflect.starr.jar=/usr/share/java/scala-reflect.jar \
	    -Dcompiler.starr.jar=/usr/share/java/scala-compiler.jar \
	    fastdist-opt

	for file in scala scala-library; do \
		sed "s/@VERSION@/$(BUNDLE_VERSION)/" debian/$${file}.pom.xml.in > debian/$${file}.pom.xml; \
	done

override_dh_auto_clean:
	rm -rf build dists lib/jline.jar buildcharacter.properties

override_dh_compress:
	dh_compress -X.js -X.scala
	# dh_compress is executed after mh_installpoms and mh_linkjars
	# ugly hack to fix #654549
	find debian/scala \( -type f -or -type l \) -name "scala-library*.jar" -delete

get-orig-source:
	uscan --download-current-version --rename
