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

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

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

override_dh_auto_clean:
	[ -d vendor/ ] || go mod vendor
	rm -f grubzfs-tests
	rm -rf mocks/
	dh_auto_clean

override_dh_auto_build:
	go test -c -o grubzfs-tests
	mkdir -p mocks
	for mock in `ls cmd/`; do \
		go build -o mocks/$$mock/$$mock cmd/$$mock/*.go; \
	done
	rm -rf $(GOCACHE)

override_dh_auto_test:
	# we only have integration tests for zfs+grub, as autopkgtests

override_dh_auto_install:
	dh_auto_install -- --no-source
