#!/usr/bin/make -f

export DEB_BUILD_MAINT_OPTIONS = hardening=+all

%:
	dh $@ --buildsystem=meson+ninja

CONFIGURE_OPTS = \
 -Dwith-appletalk=true \
 -Dwith-dbus-daemon-path=/usr/bin/dbus-daemon \
 -Dwith-init-hooks=false \
 -Dwith-init-style=debian-sysv,systemd \
 -Dwith-install-hooks=false \
 -Dwith-krbV-uam=true \
 -Dwith-ldsoconf=false \
 -Dwith-overwrite=true \
 -Dwith-pam-config-path=/etc/pam.d \
 -Dwith-pkgconfdir-path=/etc/netatalk \
 -Dwith-rpath=false \
 -Dwith-spooldir=/var/spool/netatalk \
 -Dwith-tracker-prefix=/usr \
 -Dwith-testsuite=true \
 -Dwith-unicode-data=true \

ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
CONFIGURE_OPTS += \
 -Dwith-tests=true
endif

# generate documentation unless nodoc requested
ifneq (,$(filter nodoc,$(DEB_BUILD_OPTIONS)))
CONFIGURE_OPTS += \
 -Dwith-docs=
endif

# ensure a final statedir of /var/lib/netatalk
# (FHS and Debian possibly disagree in defaults - see also bug#1082436)
CONFIGURE_OPTS += \
 -Dwith-statedir-path=/var/lib

override_dh_auto_configure:
	dh_auto_configure --buildsystem=meson+ninja -- $(CONFIGURE_OPTS)

execute_after_dh_auto_install:
# Install initscripts with debhelper to add pre- and postinst routines
	mv debian/tmp/etc/init.d/a2boot debian/a2boot.init
	mv debian/tmp/etc/init.d/atalkd debian/atalkd.init
	mv debian/tmp/etc/init.d/macipgw debian/macipgw.init
	mv debian/tmp/etc/init.d/netatalk debian/netatalk.init
	mv debian/tmp/etc/init.d/papd debian/papd.init
	mv debian/tmp/etc/init.d/timelord debian/timelord.init
	mv debian/tmp/usr/lib/systemd/system/a2boot.service debian/
	mv debian/tmp/usr/lib/systemd/system/atalkd.service debian/
	mv debian/tmp/usr/lib/systemd/system/macipgw.service debian/
	mv debian/tmp/usr/lib/systemd/system/netatalk.service debian/
	mv debian/tmp/usr/lib/systemd/system/papd.service debian/
	mv debian/tmp/usr/lib/systemd/system/timelord.service debian/
