#!/usr/bin/make -f
# -*- makefile -*-
# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

export DEB_BUILD_MAINT_OPTIONS = hardening=+all
export DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)
DPKG_EXPORT_BUILDFLAGS = 1
include /usr/share/dpkg/buildflags.mk

export INSTALL_LIB := lib/$(DEB_HOST_MULTIARCH)

%:
	dh  $@

DEBNAME=neartree
DEBVERSION=5.1.1+dfsg1
UPSTREAMTAR=NearTree-5.1.1.tar.gz
UPSTREAMURL=https://github.com/yayahjb/neartree/archive/$(UPSTREAMTAR)
TDIR=$(DEBNAME)-$(DEBVERSION)
get-orig-source:
	[ ! -e $(TDIR) ] || (echo "Unpack dir $(TDIR) exists, exiting." ; false)
	mkdir -p $(TDIR)
	[ -f $(UPSTREAMTAR) ] || wget $(UPSTREAMURL)
	tar -C $(TDIR) --strip-components=1 -zxf $(UPSTREAMTAR)
	# Remove unnecessary Datagen
	rm -r $(TDIR)/DataGen
	# PDF paper has unknown copyright status
	rm $(TDIR)/NearTree/Andrews_2001_TNEAR.pdf
	# Move to lower dir
	mv $(TDIR)/NearTree/* $(TDIR)/
	rmdir $(TDIR)/NearTree
	tar -zcf $(DEBNAME)_$(DEBVERSION).orig.tar.gz $(TDIR)
