#!/usr/bin/make -f
# -*- makefile -*-
# The get-orig-source was taken from:
# http://wiki.debian.org/SandroTosi/Svn_get-orig-source

SRC_PACKAGE = brailleutils
PACKAGE = $(SRC_PACKAGE)
LIBPACKAGE = lib$(PACKAGE)-java
SRC_VERSION = 1.2.1
VERSION = $(SRC_VERSION)
TARBALL = $(SRC_PACKAGE)_$(SRC_VERSION).orig.tar.gz
.PHONY: get-orig-source

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

%:
	dh $@  --buildsystem=ant --with maven_repo_helper

override_dh_auto_clean:
	-rm -rf ant-build/output/*

override_dh_install:
	mh_installpoms -p$(PACKAGE)
	mh_installjar -p$(LIBPACKAGE) -l debian/pom.xml ant-build/output/dist/brailleUtils-core.jar
	dh_install


#override_dh_auto_build:
#	ant -DuseExternalJarsOnLinux=true

get-orig-source:
	rm -rf get-orig-source $(TARBALL)
	mkdir get-orig-source
	svn export https://brailleutils.googlecode.com/svn/tags/release_1.2.1 \
		get-orig-source/$(SRC_PACKAGE)-$(SRC_VERSION).orig
	# Remove $SRC/lib and $SRC/ant-build/resources, because it's not necessary in Debian, dependencies are in Debian itself available
	rm -rf get-orig-source/$(SRC_PACKAGE)-$(SRC_VERSION).orig/lib
	rm -rf get-orig-source/$(SRC_PACKAGE)-$(SRC_VERSION).orig/ant-build/resources
	GZIP='--best --no-name' tar czf $(TARBALL) -C get-orig-source $(SRC_PACKAGE)-$(SRC_VERSION).orig
	rm -rf get-orig-source
	mv $(TARBALL) ..

#/usr/share/maven-repo/org/daisy/libs/libbrailleutils-java/libbrailleutils-java-debian.jar /usr/share/java/$(PACKAGE).jar
#understand that command:
#java -cp build/$(PACKAGE)-debian.jar:$(CLASSPATH) $(JAVA_OPTIONS) org.debian.maven.repo.POMCleaner --no-parent --has-package-version --rules=debian/maven.rules pom.xml \
#	debian/.mh/$(PACKAGE)-debian.pom debian/.mh/pom.properties 

