#! /usr/bin/make -f

# The options have been chooses as follows:
# - manually set pamlibdir because we'Re installing in /usr by default but
#   pam libs must go to /lib/*/security, same for udev rules
# - disable killing users processes by default. This is weird an unexpected
#   behavior
# - /sbin/poweroff is missing on runit systems, so use /sbin/shutdown instead
# - SELinux build is broken on 239 (fix available for 240)
# - tests disabled beacuase some of the tests seem to require elogind running.
#   Need to sort out which tests could be run

CONFFLAGS = \
  -Dpamlibdir=/lib/$(DEB_HOST_MULTIARCH)/security \
  -Drootlibdir=/usr/lib/$(DEB_HOST_MULTIARCH) \
  -Dsplit-usr=true \
  -Ddocdir=/usr/share/doc/elogind \
  -Dudevrulesdir=/lib/udev/rules.d \
  -Ddefault-kill-user-processes=false \
  -Dpoweroff-path=/sbin/shutdown \
  -Dselinux=false \
  -Dtests=false

CONFFLAGS_CGROUPCTRL_ELOGIND= \
  -Dcgroup-controller=elogind

override_dh_auto_configure:
	dh_auto_configure --builddirectory=build \
        -- $(CONFFLAGS) $(CONFFLAGS_CGROUPCTRL_ELOGIND)

override_dh_auto_install:
	dh_auto_install --builddirectory=build

override_dh_auto_clean:
	dh_auto_clean --builddirectory=build
	# remove Python byte code files
	rm -rf tools/__pycache__/

override_dh_missing:
	dh_missing --list-missing

override_dh_makeshlibs:
	dh_makeshlibs -pelogind -Xlibelogind-shared
	dh_makeshlibs --remaining

override_dh_shlibdeps:
	dh_shlibdeps -- -xlibeudev1

%:
	dh $@  --builddirectory=build --without autoreconf,systemd --buildsystem=meson
