#!/usr/bin/make -f

export DEB_BUILD_MAINT_OPTIONS = hardening=+all
DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)
# IMPORTANT:
# Drop the /usr prefix when building for a distribution before trixie.
LIBDIR = /usr/lib/$(DEB_HOST_MULTIARCH)
export DEB_CFLAGS_MAINT_APPEND = -Wno-error=stringop-truncation
%:
	dh $@

override_dh_auto_configure:
	dh_auto_configure -- --libdir=$(LIBDIR) --enable-config-file --enable-filtering --prefix=/usr --sysconfdir=/etc --with-message-format='[login:%{login} ssh:(%{env:SSH_CONNECTION}) sid:%{sid} tty:%{tty} (%{tty_uid}/%{tty_username}) uid:%{username}(%{uid})/%{eusername}(%{euid}) cwd:%{cwd}]: %{cmdline}'

override_dh_auto_test:

override_dh_auto_install:
	dh_auto_install
	find debian/ -name "*.la" -delete
	# remove snoopy-enable and snoopy-disable, on debian we use
	# dpkg-reconfigure instead
	rm -r debian/snoopy/usr/sbin

override_dh_clean:
	dh_clean
	find . -name Makefile.in -exec rm {} \+
	rm -f aclocal.m4 compile configure test-drive

override_dh_installdeb: debian/snoopy.postinst
	dh_installdeb

debian/snoopy.postinst: debian/snoopy.postinst.in
	sed 's|#LIBDIR#|$(LIBDIR)|g' $< > $@

override_dh_missing:
	dh_missing --fail-missing