#!/usr/bin/make -f

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

%:
	dh $@ --with javahelper

override_dh_auto_configure:
	# move files from freehep-jaida into place - unfortunately these files do not build
	# mkdir -p src/hep
	# cp -a debian/freehep-jaida src/hep/aida
	dh_auto_configure

override_dh_auto_build:
	#Make this directory on build because GIT won't let you commit an empty
	#directory
	mkdir -p lib
	# Fix broken encodings that were not catched in fix_invalid_encoding.patch
	for utf16 in `find . -name "*.java" -exec file \{\} \; | grep "ISO-8859 text" | sed 's/: .*//'` ; do \
		echo "Fixing ISO-8859 encoding of $$utf16" ; \
		sed -i '/^Copyright/{;N;s/Copyright.*1999 CERN - European Organization for Nuclear Research/Copyright (c) 1999 CERN - European Organization for Nuclear Research/;}' $$utf16; \
	done
	ant -Dant.build.javac.source=1.5 -Dant.build.javac.target=1.5 build

override_dh_installdocs:
	dh_installdocs
	rm -rf debian/libcolt-java-doc/usr/share/doc/libcolt-java/licenses

override_dh_clean:
	dh_clean
	rm -rf build
	rm -rf lib/*.jar
	#This will deliberately fail if lib contains anything but jars
	! [ -d lib ] || rmdir lib
	rm -rf src/hep/aida

override_jh_installlibs:
	#In this case leave on the +dfsg version suffix as it affects the methods
	#available vs. the vanilla upstream lib.
	jh_installlibs -v --version-strip=X

get-orig-source:
	mkdir -p ../tarballs
	uscan --verbose --force-download --repack --compression xz --destdir ../tarballs
