#!/usr/bin/make -f

export DEB_BUILD_MAINT_OPTIONS = hardening=+bindnow
export PYBUILD_NAME=ariba

# Build only for Python 3.13 - pysam doesn't support 3.14 yet
export PYBUILD_VERSIONS=3.13

ifneq ($(shell py3versions -d),$(shell py3versions -s))
	export PYBUILD_TEST_ARGS_$(filter-out $(shell py3versions -d),$(shell py3versions -s))=-k "not test_load_fasta_files_and_write_clusters_file"
endif


mandir := $(CURDIR)/debian/man
debfolder := $(CURDIR)/debian

%:
	dh $@ --buildsystem=pybuild

override_dh_auto_clean:
	rm -rf $(mandir)
	dh_auto_clean --

override_dh_installman:
	mkdir -p $(mandir)
	asciidoctor -a docdate='' -b manpage -o $(mandir)/ariba.1 $(debfolder)/ariba.1.adoc
	dh_installman --

# Normalize timestamps of test data files modified during test runs (reproducibility fix)
override_dh_fixperms:
	dh_fixperms
	find debian/ariba -path '*/pubmlst_ref_prepare.test_load_fa_and_clusters.in/gene*.tfa' \
		-printf 'Normalizing timestamp: %p\n' \
		-exec touch --date="@$(SOURCE_DATE_EPOCH)" {} +
