#!/usr/bin/make -f

include /usr/share/dpkg/pkg-info.mk

# - t-03-queue_persistency is an artifact of dh_golang: there's a .go file with
#   a main in that directory which is used for integration tests, and should
#   not be included or built as part of the Debian package.
# - spf-check and cmd/dovecot-auth-cli are internal binaries useful for
#   development but not suited for production use.
export DH_GOLANG_EXCLUDES := t-03-queue_persistency \
	cmd/spf-check cmd/dovecot-auth-cli

BUILDFLAGS := -ldflags \
    " -X main.version=$(DEB_VERSION) \
      -X main.sourceDateTs=$(SOURCE_DATE_EPOCH)"

%:
	dh $@ --buildsystem=golang --with=golang

override_dh_auto_build:
	dh_auto_build -- $(BUILDFLAGS)

# No need to install the source files, this is a binary package.
override_dh_auto_install:
	dh_auto_install -- --no-source

# Enable both the service and the sockets (by default only the service will be
# enabled, and that's not enough for our case).
# This is based on openssh's package.
override_dh_installsystemd:
	dh_installsystemd --name chasquid chasquid.service
	dh_installsystemd --name chasquid --no-enable chasquid-smtp.socket
	dh_installsystemd --name chasquid --no-enable \
            chasquid-submission.socket
	dh_installsystemd --name chasquid --no-enable \
            chasquid-submission_tls.socket

override_dh_installchangelogs:
	dh_installchangelogs UPGRADING.md

# Don't run dh_dwz, which does not work on Go binaries (for now).
override_dh_dwz:
