#!/usr/bin/make -f

include /usr/share/javahelper/java-vars.mk
include /usr/share/dpkg/pkg-info.mk

export LEIN_HOME=$(CURDIR)/.lein
export LEIN_OFFLINE=true

UPSTREAM_VERSION := $(shell echo $(DEB_VERSION_UPSTREAM) | sed -e 's/\+dfsg//')
NAME=digest

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

override_dh_auto_configure:
	cd debian && ln -sf /usr/share/maven-repo .

override_dh_auto_build:
	lein pom debian/pom.xml
	lein jar
	# symlink so we don't need a version in debian/*.poms
	cd target && ln -sf $(NAME)-$(UPSTREAM_VERSION).jar $(NAME).jar
	# This is a temporary measure not to create breakage. We eventually need to
	# get rid of the old name.
	cd target && ln -sf $(NAME)-$(UPSTREAM_VERSION).jar clj-$(NAME).jar

override_dh_auto_test:
	cp debian/patches/debian.png test/debian.png
	lein test

override_jh_installlibs:
	jh_installlibs target/$(NAME).jar
	# This is a temporary measure not to create breakage. We eventually need to
	# get rid of the old name.
	jh_installlibs target/clj-$(NAME).jar

override_dh_clean:
	rm -f debian/maven-repo
	rm -Rf target
	rm -f debian/pom.xml
	rm -f test/debian.png
	dh_clean
