#!/usr/bin/make -f
# -*- makefile -*-
#export DH_VERBOSE=1

export DEB_BUILD_MAINT_OPTIONS = hardening=+all

include /usr/share/dpkg/architecture.mk

SDDM_CMAKE_ARGS = -DCMAKE_INSTALL_LIBEXECDIR=/usr/lib/${DEB_HOST_MULTIARCH}/sddm \
	    -DSESSION_COMMAND="/etc/sddm/Xsession" \
	    -DWAYLAND_SESSION_COMMAND="/etc/sddm/wayland-session" \
	    -DBUILD_MAN_PAGES=ON \
	    -DDBUS_CONFIG_FILENAME="sddm_org.freedesktop.DisplayManager.conf"

ifneq ($(DEB_HOST_ARCH_OS),linux)
  SDDM_CMAKE_ARGS += -DNO_SYSTEMD=ON -DENABLE_JOURNALD=OFF
endif

%:
	dh $@

override_dh_auto_configure:
	dh_auto_configure -- ${SDDM_CMAKE_ARGS}

override_dh_installsystemd:
	dh_installsystemd -psddm --no-start -r sddm.service

override_dh_installinit:
	dh_installinit --noscripts

execute_after_dh_auto_install:
	# not installed, as the Debian version is used instead
	rm -f $(CURDIR)/debian/tmp/lib/systemd/system/sddm.service $(CURDIR)/debian/tmp/usr/lib/systemd/system/sddm.service

execute_after_dh_fixperms-arch:
	# ensure script is marked as executable
	chmod +x $(CURDIR)/debian/sddm/etc/sddm/Xsession

execute_after_dh_installpam:
	dh_installpam --name=sddm-autologin
	dh_installpam --name=sddm-greeter
