#!/usr/bin/make -f
# -*- makefile -*-

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

JAVA_HOME=/usr/lib/jvm/default-java

%:
	dh $@  --with javahelper

override_dh_auto_configure:
	dh_auto_configure
	sed -e 's/BJLIB/biojava3-forester/g' debian/build.xml > biojava3-forester/build.xml
	sed -e 's/BJLIB/biojava3-aa-prop/g' debian/build.xml > biojava3-aa-prop/build.xml
	sed -e 's/BJLIB/biojava3-core/g' debian/build.xml > biojava3-core/build.xml
	sed -e 's/BJLIB/biojava3-alignment/g' debian/build.xml > biojava3-alignment/build.xml
	sed -e 's/BJLIB/biojava3-genome/g' debian/build.xml > biojava3-genome/build.xml
	sed -e 's/BJLIB/biojava3-modfinder/g' debian/build.xml > biojava3-modfinder/build.xml
	sed -e 's/BJLIB/biojava3-phylo/g' debian/build.xml > biojava3-phylo/build.xml
	sed -e 's/BJLIB/biojava3-sequencing/g' debian/build.xml > biojava3-sequencing/build.xml
	sed -e 's/BJLIB/biojava3-protein-disorder/g' debian/build.xml > biojava3-protein-disorder/build.xml
	sed -e 's/BJLIB/biojava3-structure/g' debian/build.xml > biojava3-structure/build.xml
	sed -e 's/BJLIB/biojava3-ws/g' debian/build.xml > biojava3-ws/build.xml
	sed -e 's/BJLIB/biojava3-structure-gui/g' debian/build.xml > biojava3-structure-gui/build.xml

override_dh_auto_build:
	cd biojava3-forester && ant jar
	cd biojava3-core && ant jar
	cd biojava3-phylo && ant jar
	cd biojava3-alignment && ant jar
	cd biojava3-aa-prop && ant jar
	cd biojava3-genome && ant jar
	cd biojava3-sequencing && ant jar
	cd biojava3-structure && ant jar
	cd biojava3-structure-gui && ant jar
	cd biojava3-modfinder && ant jar
	cd biojava3-protein-disorder && ant jar
	cd biojava3-ws && ant jar
	# make doc
	rm -rf biojavadoc
	mkdir biojavadoc
	cp -r biojava3-*/src biojavadoc/
	sed -e 's/BJLIB/biojava/g' debian/build.xml > biojavadoc/build.xml
	cd biojavadoc && ant javadocs
	rm -rf biojavadoc

override_dh_auto_test:
	cd biojava3-core && ant test
	cd biojava3-alignment && ant test
	cd biojava3-aa-prop && ant test
	# Skip, missing dependency
	#cd biojava3-genome && ant test
	cd biojava3-phylo && ant test
	# Native errors may cause issue on NFS...; skipping
	#cd biojava3-sequencing && ant test
	#cd biojava3-modfinder && ant test
	cd biojava3-protein-disorder && ant test
	# Requires remote access and tmp directory write access
	#cd biojava3-structure && ant test
	cd biojava3-structure-gui && ant test
	cd biojava3-ws && ant test




override_dh_clean:
	dh_clean
	rm -rf build
	rm -rf dist
	rm -rf javadoc
	rm -rf test
	rm -f biojava3-*/build.xml
	rm -rf biojavadoc
	rm -rf doc


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

