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

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

%:
	dh $@ --with javahelper

override_dh_auto_build:
	# create backups of original buildnum resources to enable building twice in a row
	for component in chiropraxis driftwood extratools king molikin ; do \
	  if [ -e $$component/resource/$$component/buildnum.props ] ; then \
	    cp -a $$component/resource/$$component/buildnum.props $$component/resource/$$component/buildnum.props.orig ; \
	  fi ; \
	done
	mkdir -p lib
	ant -buildfile chiropraxis/build.xml
	ant -buildfile extratools/build.xml
	ant -buildfile king/build.xml dist-exe

override_dh_auto_clean:
	ant -buildfile king/build.xml clean
	ant -buildfile chiropraxis/build.xml clean
	ant -buildfile driftwood/build.xml clean
	ant -buildfile extratools/build.xml clean
	ant -buildfile molikin/build.xml clean
	rm -rf king_jar

	# restore backups of original buildnum resources to enable building twice in a row
	for component in chiropraxis driftwood extratools king molikin ; do \
	  rm -rf $$component/resource/$$component/buildnum.props ; \
	  if [ -e $$component/resource/$$component/buildnum.props.orig ] ; then \
	    mv $$component/resource/$$component/buildnum.props.orig $$component/resource/$$component/buildnum.props ; \
	  fi ; \
	done

	find . -name "*.class" -delete
	rm -rf lib

override_dh_compress:
	dh_compress --exclude=.pdf
