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

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1
export PYTHON_PREFIX_ARG=--install-layout=deb

include /usr/share/dpkg/default.mk
export DESTDIR=$(shell pwd)/debian/tmp

%:
	dh $@ --with systemd,python3 --with=config-package

override_dh_auto_build:
	make all

override_dh_auto_install:
	make install-deb
	make -C app-menu install
	make -C config-overrides install
	make -C filesystem install
	make -C misc install
	make -C network install
	make -C package-managers install
	make -C package-managers install-apt
	make -C passwordless-root install install-debian
	make -C qubes-rpc install
	make -C qubes-rpc/kde install
	make -C qubes-rpc/nautilus install
	make -C qubes-rpc/thunar install
	install -D -m 0644 boot/grub.qubes $(DESTDIR)/etc/default/grub.d/30-qubes.cfg

override_dh_fixperms:
	dh_fixperms -a -Xqfile-unpacker

override_dh_systemd_start:
	dh_systemd_start --no-restart-on-upgrade

override_dh_install:
	dh_install --fail-missing

override_dh_gencontrol:
ifneq ($(shell grep -o '^9\|^10' /etc/debian_version),)
	echo "pythonver:Depends=python" >> debian/qubes-core-agent-nautilus.substvars
else
	echo "pythonver:Depends=python3" >> debian/qubes-core-agent-nautilus.substvars
endif
	dh_gencontrol