#!/usr/bin/make -f
# See debhelper(7) (uncomment to enable)
# output every command that modifies files on the build system.
# export DH_VERBOSE = 1

# see EXAMPLES in dpkg-buildflags(1) and read /usr/share/dpkg/*
DPKG_EXPORT_BUILDFLAGS = 1
include /usr/share/dpkg/default.mk

# see FEATURE AREAS in dpkg-buildflags(1)
export DEB_BUILD_MAINT_OPTIONS = hardening=+all

export DH_OPTIONS

export DH_GOPKG := github.com/abh/geoip/

# main packaging script based on dh7 syntax
%:
	dh $@ --buildsystem=golang --with=golang

override_dh_auto_test:
	ln -s $(CURDIR)/test-db obj-$(DEB_HOST_GNU_TYPE)/src/github.com/abh/geoip/test-db
	dh_auto_test -O--buildsystem=golang

override_dh_auto_install:
	dh_auto_install -O--buildsystem=golang
	# remove the demo binary
	rm -r $(CURDIR)/debian/golang-github-abh-geoip-dev/usr/bin
	# remove the demo sources
	rm -r $(CURDIR)/debian/golang-github-abh-geoip-dev/usr/share/gocode/src/github.com/abh/geoip/ex
	# remove the broken test-db symlink
	rm $(CURDIR)/debian/golang-github-abh-geoip-dev/usr/share/gocode/src/github.com/abh/geoip/test-db
	# remove the geoip_test.go
	rm $(CURDIR)/debian/golang-github-abh-geoip-dev/usr/share/gocode/src/github.com/abh/geoip/geoip_test.go
