#!/usr/bin/make -f

# DH_VERBOSE := 1

include /usr/share/dpkg/default.mk

export JAVA_HOME=/usr/lib/jvm/default-java
export LC_ALL=C.UTF-8

%:
	dh $@ --with javahelper

override_dh_clean:
	# Removing all the sidx files created during the tests. Then one of them must
	# be restored, it has been saved prior to the tests.
	find . \( -name "*.sidx" -a ! -name "gnomad_db_multiple_entries.vcf.sidx" \) -delete
	if [ -e test/ann/gnomad_db_multiple_entries.vcf.sidx.old ]; then \
	    mv test/ann/gnomad_db_multiple_entries.vcf.sidx.old test/ann/gnomad_db_multiple_entries.vcf.sidx; \
	fi
	# Restoring another file modified during the tests
	if [ -e test/gt_test.01.gt.vcf.old ]; then \
	    mv test/gt_test.01.gt.vcf.old test/gt_test.01.gt.vcf; \
	fi
	dh_clean

execute_before_dh_auto_test:
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
	# Saving some files that are modified during the tests, in order to restore them later.
	cp test/ann/gnomad_db_multiple_entries.vcf.sidx test/ann/gnomad_db_multiple_entries.vcf.sidx.old
	cp test/gt_test.01.gt.vcf test/gt_test.01.gt.vcf.old
endif
