#!/usr/bin/make -f

include /usr/share/dpkg/pkg-info.mk
include /usr/share/dpkg/architecture.mk

export DEB_LDFLAGS_MAINT_APPEND=-Wl,--as-needed -Wl,-O1
export DEB_BUILD_MAINT_OPTIONS=hardening=+all

DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)
DEB_HOST_ARCH ?= $(shell dpkg-architecture -qDEB_HOST_ARCH)

devi := $(shell lsb_release -r -s | cut -d '.'  -f1)
ifeq ($(shell if [ $(devi) -gt 7 ] ; then echo gt ; else echo lt ; fi),gt)
   DEBVE=yes
else
   DEBVE=no
endif

ifeq ($(shell if [ $(devi) -gt 8 ] ; then echo gt ; else echo lt ; fi),gt)
   DEBVE2=yes
else
   DEBVE2=no
endif


override_dh_auto_configure:
	dh_auto_configure -- --with-greeter-user=lightdm --with-user-session=lightdm-xsession --enable-introspection=yes --disable-silent-rules --libexecdir=/usr/lib/$(DEB_HOST_MULTIARCH)/$(DEB_SOURCE)/

override_dh_installchangelogs:
	dh_installchangelogs -- NEWS

override_dh_installinit:
	dh_installinit --noscripts

override_dh_install:
	find debian/tmp -name '*.la' -delete
	find debian/tmp/etc/apparmor.d -type f -exec chmod 0644 '{}' \;
	dh_install --fail-missing -X etc/init/lightdm.conf -X etc/apparmor.d/lightdm-guest-session

%:

ifeq ($(DEBVE2),yes)
	dh $@ --with systemd --parallel
else
	dh $@ --parallel
endif

override_dh_auto_test:
	

ifeq ($(DEBVE2),yes)
override_dh_systemd_start:
	dh_systemd_start -plightdm --no-start -r lightdm.service
endif
