#!/usr/bin/make -f

# export DH_VERBOSE=1
export PYBUILD_NAME=binwalk

PYVER := $(shell py3versions -d)

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

override_dh_auto_clean:
	# Upstream setup.py clean does not accept options passed by
	# pybuild
	python3 setup.py clean

override_dh_auto_test:
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
	HOME= PYTHONPATH=src python3 setup.py test || true
endif

override_dh_install:
	dh_install
	mkdir -p debian/binwalk/usr/bin
	mv debian/python3-binwalk/usr/bin debian/binwalk/usr
	# run tests again, here we have a properly installed binwalk into debian directory
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
	HOME= PYTHONPATH=debian/python3-binwalk/usr/lib/$(PYVER)/dist-packages/ python3 setup.py test
endif
