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

export DEB_BUILD_MAINT_OPTIONS = hardening=+all

CHECK_HOME = $(CURDIR)/debian/tmp/home

CONFFLAGS := \
	-Dsystemd-user-unit-dir=/usr/lib/systemd/user \
	-Dintrospection=true \
	-Dvapi=false
%:
	dh $@

override_dh_auto_configure:
ifeq (gnome-shell-extension-gpaste,$(filter gnome-shell-extension-gpaste,$(shell dh_listpackages)))
	dh_auto_configure -- $(CONFFLAGS) \
		-Dgnome-shell=true
else
	dh_auto_configure -- $(CONFFLAGS) \
		-Dgnome-shell=false
endif

override_dh_auto_test:
ifeq (, $(filter nocheck, $(DEB_BUILD_OPTIONS)))
	mkdir -p -m0700 $(CHECK_HOME)
	XDG_RUNTIME_DIR=$(CHECK_HOME) dh_auto_test
endif

override_dh_gencontrol:
	dh_gencontrol -- \
		-Vgnome:MinimumVersion=$(shell python3 -c "import json; \
		print(min(int(x) for x in json.load(open('src/gnome-shell/metadata.json.in', 'rt'))['shell-version']))") \
		-Vgnome:MaximumVersion=$(shell python3 -c "import json; \
		print(1+max(int(x) for x in json.load(open('src/gnome-shell/metadata.json.in', 'rt'))['shell-version']))")
