#!/usr/bin/make -f

export DH_VERBOSE = 1
export DH_GOPKG = github.com/prometheus/procfs

DEBVERS    ?= $(shell dpkg-parsechangelog | sed -n -e 's/^Version: //p')
VERSION    ?= $(shell echo '$(DEBVERS)' | sed 's/^[[:digit:]]*://; s/[-].*//')
DEBPKGNAME ?= $(shell dpkg-parsechangelog | sed -n -e 's/^Source: //p')
BUILDDIR := $(shell perl -w -MDebian::Debhelper::Buildsystem::golang -e \
        'print Debian::Debhelper::Buildsystem::golang->new()->get_builddir()')

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

override_dh_auto_configure:
	dh_auto_configure -O--buildsystem=golang
	# Include test fixtures.
	cp -av fixtures $(BUILDDIR)/src/$(DH_GOPKG)

override_dh_link:
	# Do nothing, the symlinks in the fixtures directory are just test
	# cases that simulate files in /proc.

gen-orig-tgz:
	if [ ! -f ../$(DEBPKGNAME)_$(VERSION).orig.tar.gz ] ; then \
	    git archive --format=tar.gz --prefix=$(DEBPKGNAME)-$(VERSION)/ \
                upstream/$(VERSION) >../$(DEBPKGNAME)_$(VERSION).orig.tar.gz ; \
	fi
