#!/usr/bin/make -f
#export DH_VERBOSE=1

export DEB_CFLAGS_MAINT_APPEND=-std=gnu90
export DEB_BUILD_MAINT_OPTIONS = hardening=+all

%:
	dh $@

override_dh_auto_build:
	dh_auto_build
	cp SeqPrep seqprep
	mv ${CURDIR}/debian/README.html ${CURDIR}

override_dh_clean:
	dh_clean
	rm -f seqprep
	rm -f README.html

override_dh_auto_test:
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
	# This checks that the tests run and produce byte-identical results.
	cd Test && mkdir -p out info && \
	    bash -xc 'gzcat(){ zcat "$$@" ; } ; . RUNTEST.sh'
	[ `cat Test/info/pe_*.txt | md5sum | cut -b -10` = 8bc8e0787e ]
	# remove output dirs right after testing to make sure the files
	# will not be included in the data package
	rm -rf Test/info Test/out
endif

override_dh_install-indep:
	dh_install
	sed -i 's#../SeqPrep#/usr/bin/seqprep#' $(CURDIR)/debian/seqprep-data/usr/share/doc/seqprep/examples/RUNTEST.sh
