#!/usr/bin/make -f

export DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)

%:
	dh $@ --buildsystem=cmake

override_dh_auto_configure:
	dh_auto_configure -- \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib/$(DEB_HOST_MULTIARCH) \
		-DDATAPATH=/usr/share/authdb \
		-DCMAKE_BUILD_TYPE=Release \
		-DBUILD_BINDINGS=OFF

override_dh_install:
	dh_install
	install -D -m 644 debian/authdb.default-config.yaml debian/authdb/usr/share/authdb/authdb.default-config.yaml
	sed -i 's|DEB_HOST_MULTIARCH|$(DEB_HOST_MULTIARCH)|g' debian/authdb/usr/share/authdb/authdb.default-config.yaml
	install -D -m 644 debian/authdb.tmpfiles debian/authdb/usr/lib/tmpfiles.d/authdb.conf
	install -D -m 644 debian/authdb.sysusers debian/authdb/usr/lib/sysusers.d/authdb.conf
