#!/usr/bin/make -f
# -*- makefile -*-

DH_VERBOSE=1
DEBVERS := $(shell dpkg-parsechangelog | sed -n -e 's/^Version: //p')
VERSION := $(shell echo '$(DEBVERS)' | sed -e 's/^[[:digit:]]*://' -e 's/[~-].*//')
OVERSION := $(shell echo '$(DEBVERS)' | sed -e 's/^[[:digit:]]*://' -e 's/[+].*//')
export DESTDIR=$(CURDIR)/debian/tmp
export LC_ALL=C.UTF-8

BITS:=$(shell dpkg-architecture | grep DEB_BUILD_ARCH_BITS | cut -f 2 -d'=')
ifeq ($(BITS),64)
  64BIT:=yes
else
  64BIT:=no
endif

%:
	dh $@

override_dh_auto_build:
	dh_auto_build -- prefix=$(DESTDIR) 64bit=$(64BIT) errorcheck=no

override_dh_auto_test:
	dh_auto_test -- useshared=yes 64bit=$(64BIT) testthreads=5

override_dh_auto_install:
	dh_auto_install -- 64bit=$(64BIT) prefix=$(DESTDIR)

override_dh_strip:
	dh_strip --dbg-package=aegean-dbg

override_dh_installdocs:
	cp $(CURDIR)/README.md $(CURDIR)/README
	dh_installdocs

get-orig-source:
	uscan --verbose --force-download --repack --compression xz --destdir=..
	mv ../aegean_$(OVERSION).orig.tar.xz ../aegean_$(VERSION).orig.tar.xz
