#!/usr/bin/make -f
# debian/rules for biomaj
# Author: Olivier Sallou <olivier.sallou@irisa.fr>
# License: CeCILL

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

# This has to be exported to make some magic below work.
export DH_OPTIONS

export ANT_HOME=/usr/share/ant
#export JAVA_HOME=/usr/lib/jvm/java-6-openjdk/
JAVA_HOME=$(readlink -f /usr/bin/javac | sed "s:/bin/javac::")

%:
	dh $@ --with javahelper

override_dh_auto_build:
	ant -f usr/share/biomaj/lib/vendor/commons-cli2.xml
	cp usr/share/biomaj/lib/vendor/commons-cli2-build/dist/commons-cli-2.0-SNAPSHOT.jar usr/share/biomaj/lib/
	ant -f usr/share/biomaj/lib/vendor/commons-cli2.xml clean
	ant -f usr/share/biomaj/build.xml
	javac -d usr/share/biomaj/bin usr/share/biomaj/bin/Configurator.java

override_dh_clean:
	dh_clean
	if test -e usr/share/biomaj/lib/vendor/commons-cli2-build;then ant -f usr/share/biomaj/lib/vendor/commons-cli2.xml clean;fi;
	rm -f usr/share/biomaj/lib/commons-cli-2.0-SNAPSHOT.jar
	rm -rf usr/share/biomaj/build
	rm -rf usr/share/biomaj/dist
	rm -f usr/share/biomaj/lib/biomaj.jar
	rm -f usr/share/biomaj/bin/*.class

override_dh_install:
	# dh_install
	dh_install --exclude=usr/share/biomaj/lib/vendor --exclude=usr/share/biomaj/build --exclude=usr/share/biomaj/dist usr/share/biomaj
	dh_install usr/share/doc
	dh_install usr/bin/biomaj
	dh_install var/lib/biomaj
	dh_install var/log/biomaj
	dh_install etc/biomaj

get-orig-source:
	. debian/get-orig-source
