#!/usr/bin/make -f

include /usr/share/dpkg/pkg-info.mk

export DH_GOLANG_GO_GENERATE   := 1
export DH_GOLANG_EXCLUDES      := libcontainer/integration contrib/cmd
export DH_GOLANG_INSTALL_EXTRA := libcontainer/seccomp/fixtures

TAGS    := apparmor seccomp selinux ambient
LDFLAGS := -X main.version=$(DEB_VERSION_UPSTREAM) -X main.gitCommit=$(DEB_VERSION)

%:
	dh $@ --buildsystem=golang --with=golang --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`

override_dh_auto_configure:
	cd man && ./md2man-all.sh
	dh_auto_configure

override_dh_auto_build:
	dh_auto_build -- -tags "$(TAGS)" -ldflags "$(LDFLAGS)"

override_dh_auto_test:
	dh_auto_test -- -tags "$(TAGS)"
