#!/usr/bin/make -f
#DH_VERBOSE=1
export DH_OPTIONS
export DH_GOLANG_EXCLUDES := cmd/opparse
export DH_GOPKG := github.com/danos/op

GOBUILDDIR := _build

# Uncomment to enable race detection
# This should only be done for local test builds; tests run very slow
# See https://golang.org/doc/articles/race_detector.html#Runtime_Overheads
#GORACE=-race

# If the cover tool is present, use it in tests
GOCOVER=$(if $(shell go doc cmd/cover >/dev/null 2>&1 && echo true),-cover,)

%:
	dh $@ --buildsystem=golang --with=systemd,golang,yang --builddirectory=$(GOBUILDDIR)

override_dh_auto_build: vet
	dh_auto_build -- $(GORACE)

vet:
	if go doc cmd/vet >/dev/null 2>&1; then \
		GOPATH=$(CURDIR)/$(GOBUILDDIR) go vet $$(find . -type f -name \*.go | \
	    xargs dirname | sort -u | grep -v "/vendor/"); \
	fi

override_dh_strip:

override_dh_auto_test:
	dh_auto_test -- $(GORACE) $(GOCOVER)
