#!/usr/bin/make -f
include /usr/share/dpkg/pkg-info.mk

export DH_VERBOSE=1
export DH_GOLANG_INSTALL_EXTRA := collector/fixtures

BUILDDIR := build
DH_GOPKG := github.com/dcu/mongodb_exporter

BUILDFLAGS = -ldflags \
  " -X $(DH_GOPKG)/version.Version=$(DEB_VERSION_UPSTREAM)"

%:
	dh $@ --buildsystem=golang --with=golang \
            --builddirectory=$(BUILDDIR)

BINNAME := $(DEB_SOURCE)

override_dh_auto_build:
	dh_auto_build -- $(BUILDFLAGS)
	# Rename the binary to match the debian package.
	cp -v $(BUILDDIR)/bin/mongodb_exporter $(BUILDDIR)/bin/$(BINNAME)

override_dh_auto_install:
	dh_install $(BUILDDIR)/bin/$(BINNAME) usr/bin
	dh_installman debian/$(BINNAME).1