#!/usr/bin/make -f
# -*- makefile -*-

# Uncomment this to turn on verbose mode.
export DH_VERBOSE=1
export QT_SELECT=qt5

export DEB_BUILD_MAINT_OPTIONS = hardening=+all

include /usr/share/dpkg/buildflags.mk
include /usr/share/dpkg/architecture.mk

testskip_architectures := powerpc

ifneq ($(DEB_BUILD_GNU_TYPE),$(DEB_HOST_GNU_TYPE))
export DEB_BUILD_PROFILES := cross
endif

ifneq (,$(findstring nocheck,$(DEB_BUILD_OPTIONS)))
export CONFIGURE_FLAGS := -DENABLE_TESTS=OFF
endif



export HOME=$(CURDIR)/debian/build

override_dh_auto_configure:
	# Debian defines CMAKE_INSTALL_LOCALSTATEDIR as /usr/var, which is wrong.
	# So until Debian bug 719148 is fixed, do it ourselves.
	dh_auto_configure -- -DCMAKE_INSTALL_LOCALSTATEDIR="/var"	\
	                     -DMODERN_PYTHON_DBUSMOCK=ON		\
	                     $(CONFIGURE_FLAGS)

override_dh_auto_build:
	dh_auto_build --parallel

override_dh_auto_clean:
	dh_auto_clean
	rm -rf $(BUILDHOME)

override_dh_auto_test:
	mkdir -p $(HOME)
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
ifneq (,$(filter $(DEB_HOST_ARCH),$(testskip_architectures)))
	-dh_auto_test --no-parallel
else
	dh_auto_test --no-parallel
endif
endif

override_dh_install:
#	cd tests/autopilot; \
#	set -ex; for python in $(shell py3versions -r); do \
#		$$python setup.py install --root=$(CURDIR)/debian/tmp --install-layout=deb; \
#	done; \
#	cd $(CURDIR)
	dh_install -X'*.pyc'

override_dh_makeshlibs:
	dh_makeshlibs -Xusr/lib/$(DEB_HOST_MULTIARCH)/ubuntu-system-settings

override_dh_missing:
	dh_missing --fail-missing

%:
	dh $@ --with python3

get-orig-source:
	uscan --noconf --force-download --rename --download-current-version --destdir=..
