#!/usr/bin/make -f
export DH_VERBOSE=1

export GOCACHE=$(shell mktemp -d /tmp/gocache-XXXX)

# We want to copy special files from our monorepo like "common/version".
export DH_GOLANG_INSTALL_ALL=1

# We want to take whatever ubuntu propose to us (as it won’t download a newer version),
# as long as it matches the go.mod go stenza which is the language requirement.
export GOTOOLCHAIN := local

# Computes the version ID and updates vendoring
export GOFLAGS := $(shell ./debian/prepare-source.sh)

%:
	@echo "Building with flags $(GOFLAGS)"
	dh $@ --builddirectory=_build --with=apport

override_dh_auto_install:
	dh_auto_install -- --no-source

	# systemd services
	mkdir -p debian/wsl-pro-service/lib/systemd/system
	cp -a services/* debian/wsl-pro-service/lib/systemd/system/

	# Install our service in libexec as it's not intended for end user
	mv debian/wsl-pro-service/usr/bin/ debian/wsl-pro-service/usr/libexec/

override_dh_auto_test:
	cd _build && GOWORK=off go test -mod=vendor github.com/canonical/ubuntu-pro-for-wsl/wsl-pro-service/...

# dwz does not support golang binaries yet
override_dh_dwz:
