#!/usr/bin/make -f

export PYBUILD_SYSTEM := pyproject

# export PYBUILD_VERBOSE := 1
# export DH_VERBOSE := 1

export DEB_BUILD_MAINT_OPTIONS = hardening=+all

PACKAGE = $(firstword $(shell dh_listpackages))
TMP     = $(CURDIR)/debian/$(PACKAGE)

%:
	dh ${@} --with python3 --buildsystem=pybuild

override_dh_auto_clean:
	$(MAKE) V=1 -j1 clean

override_dh_auto_build:
	$(MAKE) V=1
	PYBUILD_NAME=pycriu PYBUILD_DIR=lib \
	pybuild --build

	PYBUILD_NAME=crit PYBUILD_DIR=crit \
	pybuild --build -d crit

override_dh_auto_install:
	$(MAKE) install V=1 DESTDIR="$(CURDIR)/debian/criu" PREFIX="/usr" LIBEXECDIR="/usr/lib"
	PYBUILD_NAME=pycriu PYBUILD_DIR=lib \
	pybuild --install --dest-dir $(CURDIR)/debian/criu -d lib

	PYBUILD_NAME=crit PYBUILD_DIR=crit \
	pybuild --install --dest-dir $(CURDIR)/debian/criu -d crit

	# Remove amdgpu_plugin manpage until we really provide the plugin
	$(RM) --verbose $(TMP)/usr/share/man/man1/amdgpu_plugin.1.gz

override_dh_auto_test:
	# disabled: not appropriate to run as part of the package build

override_dh_strip:
	dh_strip --ddeb-migration='criu-dbg (<< 1.8-2~)'
