#!/usr/bin/make -f

# We want to ship only the library packages themselves in the go source, not
# the accompanying test scripts
export DH_GOLANG_EXCLUDES := tests/
export DH_GOLANG_EXCLUDES_ALL := 1

# remove this non-sense after ubuntu's docker.io ships the vendored
# libraries in the correct folders. This is to allow auto-syncing to ubuntu
ifeq ($(shell dpkg-vendor --derives-from Ubuntu && echo yes),yes)
override_dh_auto_configure:
	# force debhelper to symlink subdirs in docker, enables workarounds below
	mkdir -p _build/src/github.com/docker _build/src/github.com/seccomp
	dh_auto_configure
	# workaround some vendoring issues - in ubuntu all docker vendored libraries
	# are installed in the "vendor/" subdirectory
	test -d _build/src/github.com/docker/libnetwork || \
	  ln -s docker/vendor/github.com/docker/libnetwork \
	     _build/src/github.com/docker
	test -d _build/src/github.com/seccomp/libseccomp-golang || \
	  ln -s ../docker/docker/vendor/github.com/seccomp/libseccomp-golang \
	  _build/src/github.com/seccomp
endif

override_dh_auto_build: $(MANPAGES) $(MANPAGES5)
	dh_auto_build -- -tags "seccomp selinux apparmor"
	make -C docs docs GOMD2MAN=go-md2man
	make -C docs install PREFIX=/usr DESTDIR=$(CURDIR)/debian/tmp

override_dh_auto_test:
	DH_GOLANG_EXCLUDES="chroot cmd/buildah pkg/cli pkg/completion copier util conformance e2e" dh_auto_test

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