#!/usr/bin/make -f
include /usr/share/dpkg/architecture.mk

%:
	dh $@

override_dh_auto_build:
	mkdir -p build
	CGO_ENABLED=0 GOOS=linux GOARCH=$(DEB_HOST_ARCH) go build -trimpath -ldflags '-X main.version=$(shell dpkg-parsechangelog -SVersion)' -o build/stratum ./cmd/stratum

override_dh_auto_test:
	go test ./...

# Go emits its own DWARF; GNU dwz cannot process the compressed sections.
override_dh_dwz:
	:

override_dh_auto_clean:
	rm -f build/stratum
	dh_auto_clean

override_dh_installsystemd:
	dh_installsystemd -pstratum-core --name=stratum-core-banner --no-enable --no-start
	dh_installsystemd -pstratum-core --name=stratum-core-banner-clear --no-enable --no-start

execute_after_dh_install:
	chmod 0755 debian/stratum-core/etc/update-motd.d/20-stratum-core
	install -D -m 0644 banner/systemd/getty-stratum-core.conf \
		debian/stratum-core/usr/lib/systemd/system/getty@.service.d/stratum-core-banner.conf
