#!/usr/bin/make -f

export DH_GOLANG_GO_GENERATE := 1
export DH_GOLANG_INSTALL_EXTRA := $(shell find . -name fixtures-expired) \
                                  $(shell find . -name fixtures)

# The ignored pkgs are aligned with upstream ./test file,
# see variables IGNORE_PKGS and INTEGRATION_PKGS in ./test
export TEST_EXCLUDES := cmd/ etcdserverpb rafttest gopath.proto v3lockpb v3electionpb \
                        integration e2e contrib functional

export INTEGRATION_TEST_EXCLUDES := cmd/ etcdserverpb rafttest gopath.proto v3lockpb v3electionpb \
			compactor etcdserver lease mvcc pkg proxy wal

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

override_dh_auto_test:
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
	DH_GOLANG_EXCLUDES="$(TEST_EXCLUDES)" dh_auto_test -- -run=Test
	find _build -type s -delete
endif

# Handle package name (etcd-server) != service name (etcd)
override_dh_installinit:
	dh_installinit -p etcd-server --name=etcd
override_dh_installsystemd:
	dh_installsystemd -p etcd-server --name=etcd

build:
	dh build --buildsystem=golang --with=golang --builddirectory=_build

autopkgtest:
	DH_GOLANG_EXCLUDES="$(INTEGRATION_TEST_EXCLUDES)" dh_auto_test -O--buildsystem=golang -O--builddirectory=_build -- -run=Test
	find _build -type s -delete

.PHONY: build
