#!/usr/bin/make -f
# -*- makefile -*-
#  # Uncomment this to turn on verbose mode.
export DH_VERBOSE=1

# Hardening
DPKG_EXPORT_BUILDFLAGS = 1
include /usr/share/dpkg/buildflags.mk

# In fact, we are not using pybuild at all.
#export PYBUILD_NAME=mypaint
export PYBUILD_DESTDIR_python3=debian/tmp/

# Python variable
PYTHON = python3

# For tests, as suggested by upstream
export XDG_CACHE_HOME := $(CURDIR)/fakehome/

%:
	dh $@ --buildsystem=pybuild

override_dh_clean:
	# As suggested by upstream
	$(PYTHON) setup.py clean --all
	rm -f lib/_mypaintlib*.so
	dh_clean

override_dh_auto_build:
	# As suggested by upstream
	$(PYTHON) setup.py build

override_dh_auto_test:
ifeq ($(filter nocheck,$(DEB_BUILD_OPTIONS)),)
	# Known to be failing, just ignore failure for now
	# Suggested by upstream, disabled due to usage of obsolete nosetests
	#$(PYTHON) setup.py nosetests \
	#    --ignore-files="(objfactory)|(widgets).py"
	# Heavy tests including C++ part
	-$(PYTHON) setup.py test
endif

override_dh_auto_install:
	# From AUR package
	$(PYTHON) setup.py install \
	        --root=$(CURDIR)/debian/tmp/ \
	        --prefix=/usr/ \
		--skip-build

override_dh_installchangelogs:
	dh_installchangelogs Changelog.md
