#!/usr/bin/make -f

SHELL := sh -e

include /usr/share/dpkg/architecture.mk

%:
	dh ${@} --buildsystem=meson

override_dh_builddeb:
	dh_builddeb -- -Zgzip

override_dh_auto_configure-indep:

override_dh_auto_build-indep:

override_dh_auto_test:
	# Disabling test suite, incomplete

override_dh_auto_install-arch:
	dh_auto_install

	# Removing useless files
	rm -f \
        debian/tmp/usr/share/doc/taler-merchant/COPYING \
        debian/tmp/usr/lib/x86_64-linux-gnu/libmustach.a

override_dh_auto_install-indep:

override_dh_auto_clean:
	dh_auto_clean

override_dh_installsystemd:
	# Need to specify units manually, since we have multiple
	# and dh_installsystemd by default only looks for "<package>.service".
	dh_installsystemd -ptaler-merchant --name=taler-merchant-depositcheck --no-start --no-enable
	dh_installsystemd -ptaler-merchant --name=taler-merchant-httpd --no-start --no-enable
	dh_installsystemd -ptaler-merchant --name=taler-merchant-exchangekeyupdate --no-start --no-enable
	dh_installsystemd -ptaler-merchant --name=taler-merchant-donaukeyupdate --no-start --no-enable
	dh_installsystemd -ptaler-merchant --name=taler-merchant-kyccheck --no-start --no-enable
	dh_installsystemd -ptaler-merchant --name=taler-merchant-reconciliation --no-start --no-enable
	dh_installsystemd -ptaler-merchant --name=taler-merchant-report-generator --no-start --no-enable
	dh_installsystemd -ptaler-merchant --name=taler-merchant-webhook --no-start --no-enable
	dh_installsystemd -ptaler-merchant --name=taler-merchant-wirewatch --no-start --no-enable
	dh_installsystemd -ptaler-merchant --name=taler-merchant-dbinit-gc --no-start --no-enable
	dh_installsystemd -ptaler-merchant --name=taler-merchant --no-start --no-enable
	# final invocation to generate daemon reload
	dh_installsystemd

override_dh_install:
	dh_install
# Must be done manually for debhelper-compat<13
	dh_installtmpfiles
# Remove files already present in libtalermerchant from main taler-merchant package
	cd debian/libtalermerchant-dev; find . -type f -exec rm -f ../taler-merchant/{} \;
	cd debian/libtalermerchant-dev; find . -type f -exec rm -f ../libtalermerchant/{} \;
	cd debian/libtalermerchant; find . -type f -exec rm -f ../taler-merchant/{} \;
