#!/usr/bin/make -f

#export DH_VERBOSE=1
#export PYBUILD_VERBOSE=1

ifneq (,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
    NUMJOBS = $(patsubst parallel=%,%,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
else
    NUMJOBS = auto
endif

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

override_dh_auto_clean:
	dh_auto_clean
	# Remove __pycache__ directories created by "setup.py clean"
	rm -rf pybiklib/__pycache__ tools/__pycache__
	rm -f debian/README

override_dh_auto_build-arch:
	dh_auto_build -- --build-args="--arch-only"

override_dh_auto_build-indep:
	python3 tools/create_docs.py --skip-install README=debian/README
	dh_auto_build -- --build-args="--indep-only --parallel=$(NUMJOBS)"

override_dh_auto_install-arch:
	dh_auto_install -- --install-args=" \
	                        --arch-only \
	                        --install-lib=/usr/lib/pybik"

override_dh_auto_install-indep:
	dh_auto_install -- --install-args=" \
	                        --indep-only \
	                        --install-lib=/usr/lib/pybik \
	                        --install-scripts=/usr/lib/pybik \
	                        --data-dir=/usr/share"

override_dh_auto_test:
	# Pybik has no unittests, skip autodetection due to false positive

override_dh_python3:
	dh_python3 -p pybik
	dh_python3 -p pybik-bin usr/lib/pybik/pybiklib/

override_dh_builddeb:
	dh_builddeb -- -Zxz

