#!/usr/bin/make -f

%:
	dh $@ --with maven_repo_helper

SCALA_VERSION=$(shell scala -version 2>&1 | cut -f 5 -d ' ')
SCALA_MAJOR=$(shell scala -version 2>&1 | cut -f 5 -d ' ' | cut -f 1 -d '.')
SCALA_MINOR=$(shell scala -version 2>&1 | cut -f 5 -d ' ' | cut -f 2 -d '.')
SCALA_BINARY_VERSION=$(SCALA_MAJOR).$(SCALA_MINOR)

include /usr/share/dpkg/default.mk

SOURCE_FILES=$(shell find src/main/scala -name *.scala)

override_dh_auto_build:
	mkdir -p target/classes
	scalac -d target/classes -cp /usr/share/java/scala-xml_$(SCALA_BINARY_VERSION).jar $(SOURCE_FILES)

	echo "scala.version.number=$(SCALA_VERSION)"               >> target/classes/scala-xml.properties
	echo "scala.binary.version.number=$(SCALA_BINARY_VERSION)" >> target/classes/scala-xml.properties
	echo "version.number=$(DEB_VERSION_UPSTREAM)"              >> target/classes/scala-xml.properties

	jar cfm target/scala-xml.jar debian/manifest -C target/classes .
	mkdir -p html
	scaladoc -d html $(SOURCE_FILES)

override_dh_auto_clean:
	rm -Rf target html
