#!/usr/bin/make -f

include /usr/share/dpkg/default.mk

built_binaries := $(shell dh_listpackages)

export DEB_BUILD_MAINT_OPTIONS = hardening=+all
export DEB_LDFLAGS_MAINT_APPEND = -Wl,-O1 -Wl,-z,defs

export HOME=$(CURDIR)/debian/home
export XDG_RUNTIME_DIR=$(HOME)/run
unexport XDG_CACHE_HOME
unexport XDG_CONFIG_DIRS
unexport XDG_CONFIG_HOME
unexport XDG_DATA_DIRS
unexport XDG_DATA_HOME
export VERBOSE=1

meson_options =

ifeq ($(filter libportal-tests,$(built_binaries)),)
meson_options += -Dbuild-portal-test=false
else
meson_options += -Dbuild-portal-test=true
endif

%:
	dh $@

override_dh_auto_configure:
	mkdir -p debian/home/run
	chmod 0700 debian/home/run
	dh_auto_configure \
		-- \
		$(meson_options) \
		$(NULL)

override_dh_missing:
	dh_missing --fail-missing
