#!/usr/bin/make -f

export CARGO_HOME=$(shell pwd)/debian/cargo_home
DPKG_EXPORT_BUILDFLAGS = 1
include /usr/share/dpkg/buildflags.mk

ifneq (,$(findstring norust,$(DEB_BUILD_PROFILES)))
export PURE = 1
endif

%:
	dh $* --with python3 --buildsystem=pybuild

override_dh_auto_test:
ifeq (,$(findstring nocheck,$(DEB_BUILD_OPTIONS)))
	$(MAKE) check PYTHON=python3
endif

override_dh_auto_clean:
	if test -f Cargo.lock.saved; then mv Cargo.lock.saved Cargo.lock; fi
	dh_auto_clean
	rm -rf build*
	rm -f dulwich/*.so dulwich/*.o

override_dh_auto_build:
	mv Cargo.lock Cargo.lock.saved
	dh_auto_build

override_dh_installdocs:
	dh_installdocs -ppython3-dulwich docs/tutorial -X.gitignore -XMakefile

override_dh_strip:
	dh_strip -p python3-dulwich

override_dh_installchangelogs:
	dh_installchangelogs NEWS
