#!/usr/bin/make -f

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

export DH_GOPKG := github.com/opencontainers/runc
export DH_GOLANG_INSTALL_EXTRA := libcontainer/seccomp/fixtures libcontainer/criurpc
TAGS=apparmor seccomp selinux ambient
VERSION=$(shell dpkg-parsechangelog -SVersion)

# Build with Go 1.13, it FTBFS with Go 1.10 which is the default in Bionic.
export PATH := /usr/lib/go-1.13/bin:$(PATH)

# Set GOCACHE to a temp directory, dh-golang sets it to "off" but this is not
# accepted by Go >= 1.12
export GOCACHE := $(shell mktemp -d)

# GO111MODULE needs to be set to "off" to avoid checking modules information online
export GO111MODULE := off

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

override_dh_auto_configure:
	cd man && ./md2man-all.sh
	dh_auto_configure
	## Remove extra license files:
	$(RM) -v \
            _build/src/$(DH_GOPKG)/vendor/github.com/docker/docker/*/*/LICENSE* \
        ;

override_dh_auto_build:
	dh_auto_build -- -tags "$(TAGS)" -ldflags "-X main.version=$(VERSION)"

override_dh_auto_test:
	DH_GOLANG_EXCLUDES="libcontainer/integration" \
        dh_auto_test -- -tags "$(TAGS)"
