#!/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
export DEB_BUILD_MAINT_OPTIONS = hardening=+all

BITS:=$(shell dpkg-architecture | fgrep DEB_TARGET_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_installdocs:
	cp $(CURDIR)/README.md $(CURDIR)/README
	dh_installdocs
