#!/usr/bin/make -f

export DH_GOLANG_GO_GENERATE := 1
export DH_GOLANG_EXCLUDES := \
	tools \
	tests/functional/cmd \
	contrib \
	# EOL
export DH_GOLANG_INSTALL_EXTRA := \
	$(shell find . -name fixtures-expired) \
	$(shell find . -name fixtures) \
	$(shell find . -name go.mod) \
	tests/functional/functional.yaml \
	# EOL

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

execute_after_dh_auto_build:
	mv -v _build/bin/server _build/bin/etcd
    # remove dangling symlinks. They are pointing to the "tests" package that
    # we exclude further up
	rm -vf _build/src/go.etcd.io/etcd/client/*/example_*.go

override_dh_auto_test:
	GOLANG_TEST_SHORT=true dh_auto_test -O--no-parallel -- -run=Test -short

execute_after_dh_auto_test:
	find _build -type s -delete

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

# autopktest-pkg-go integration runs "debian/rules build", which is a no-op due
# to a script "build" present in the upstream source. This (PHONY) target
# overrides this.
build:
	dh build --buildsystem=golang --builddirectory=_build

.PHONY: build
