#!/usr/bin/make -f
# -*- makefile -*-

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1
export GOPATH:=$(CURDIR)
export PATH:=$(GOPATH)/bin:$(PATH)

%:
	dh $@

COMMON_FLAGS:= -x -v

override_dh_auto_install:
	go install $(COMMON_FLAGS) \
		github.com/CanonicalLtd/candid/cmd/candidsrv \
		github.com/CanonicalLtd/candid/cmd/candid
	# It is tempting to run go test here. However, that would require the
	# PPA build server to install mongodb. Instead, go test is run in
	# buildpackage.sh before building the source package.
	dh_install bin/candidsrv usr/sbin/
	dh_install bin/candid usr/bin/
	cp src/github.com/CanonicalLtd/candid/cmd/candidsrv/config.yaml config.yaml.sample
	dh_install config.yaml.sample etc/candid/
	dh_install src/github.com/CanonicalLtd/candid/static/ usr/share/candid/
	dh_install src/github.com/CanonicalLtd/candid/templates/ usr/share/candid/
	dh_auto_install

override_dh_auto_clean:
	rm -rf pkg bin
	dh_auto_clean

override_dh_builddeb:
	dh_builddeb -- -Zxz

override_dh_gencontrol:
	dh_gencontrol -- $(DB_DEP)

# Override as we don't ship a init.d script
override_dh_installinit:
	:
