#!/usr/bin/make -f

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

export DH_GOLANG_GO_GENERATE := 1

export DEB_BUILD_MAINT_OPTIONS = hardening=+all
export DH_GOLANG_EXCLUDES := demo e2e
export DH_GOLANG_INSTALL_EXTRA = \
    client/getter/test-fixtures \
    client/driver/test-resources \
    command/agent/test-resources \
    command/agent/config-test-fixtures \
    jobspec/test-fixtures \
    generate.sh

%:
	dh $@ --buildsystem=golang --with=golang,bash-completion --builddirectory=_build

override_dh_clean:
	dh_clean
	## Remove Files-Excluded (when built from checkout or non-DFSG tarball):
	$(RM) -rv `perl -0nE 'say $$1 if m{^Files\-Excluded\:\s*(.*?)(?:\n\n|Files:|Comment:)}sm;' debian/copyright`
	-find . -type f -name '*.pb.go' -delete -printf 'removed %p\n'            ## delete generated .pb.go files
	-find vendor -type d -empty -delete -print

override_dh_auto_configure:
	dh_auto_configure

override_dh_auto_build:
#	export GOPATH=$(CURDIR)/_build \
#	&& $(MAKE) -C _build/src/github.com/hashicorp/nomad --makefile=$(CURDIR)/GNUmakefile generate
	dh_auto_build -v

override_dh_auto_test:
## 165 tests are failing. Please help.
	#-PATH="$(CURDIR)/_build/bin:$$PATH" dh_auto_test -v --max-parallel=2

override_dh_auto_install:
	dh_auto_install --destdir=debian/tmp

override_dh_installinit:
	dh_installinit --no-start

override_dh_installsystemd:
	dh_installsystemd --no-enable --no-start
