#! /usr/bin/make -f

export DH_VERBOSE = 1

include /usr/share/dpkg/default.mk
include /usr/share/rustc/architecture.mk
export CFLAGS CXXFLAGS CPPFLAGS LDFLAGS
export DEB_HOST_RUST_TYPE DEB_HOST_GNU_TYPE
export PATH := /usr/share/cargo/bin:$(PATH)
export CARGO=/usr/share/cargo/bin/cargo
export CARGO_HOME=$(CURDIR)/debian/cargo_home
export CARGO_REGISTRY=$(CURDIR)/debian/cargo_registry
export DEB_CARGO_CRATE=$(DEB_SOURCE)_$(DEB_VERSION_UPSTREAM)
export DEB_BUILD_MAINT_OPTIONS=hardening=+bindnow
export PYBUILD_TEST_ARGS=-k 'not (test_sqlite_lca_db_create_readonly or test_compare_no_such_file or test_metagenome_kreport_out_fail or test_do_sourmash_index_multiscaled_rescale_fail)'
# test_sqlite_lca_db_create_readonly, fails when building as root
# test_compare_no_such_file. due to the ValueError being swallowed (?)
# test_metagenome_kreport_out_fail, same as test_compare_no_such_file
# test_do_sourmash_index_multiscaled_rescale_fail, same as above


%:
	dh $@ --buildsystem=pybuild

execute_after_dh_auto_clean:
	rm -rf debian/cargo_registry

execute_before_dh_auto_configure:
	$(CARGO) prepare-debian debian/cargo_registry --link-from-system
	rm -f Cargo.lock
	# needed because we patch Cargo.toml
	cargo generate-lockfile --manifest-path src/core/Cargo.toml --offline

execute_after_dh_auto_install:
	/usr/share/cargo/bin/dh-cargo-built-using sourmash

override_dh_python3:
	dh_python3 --no-ext-rename
