#!/usr/bin/make -f

include /usr/share/dpkg/default.mk

BITS:=$(shell dpkg-architecture | fgrep DEB_TARGET_ARCH_BITS= | cut -f 2 -d'=')

ifeq ($(BITS),64)
  VSTREE_ARCH:=linux-gcc-64
else
  VSTREE_ARCH:=linux-gcc
endif

DH_VERBOSE := 1
export LC_ALL=C.UTF-8
export DEB_BUILD_MAINT_OPTIONS=hardening=+all
export PATH:=$(PATH):$(CURDIR)/src/bin
export WORKVSTREESRC=$(CURDIR)/src

%:
	dh $@

override_dh_auto_clean:
	rm -rf debian/man

override_dh_auto_build:
	cd src && mklink.sh $(VSTREE_ARCH)
	cd src && make licensemanager=no $*

override_dh_auto_install:
	cd src && make licensemanager=no dist
	dh_auto_install

override_dh_installman:
	mkdir -p $(CURDIR)/debian/man
	asciidoctor -a docdate='' -b manpage $(CURDIR)/debian/mansrc/*.adoc
	mv $(CURDIR)/debian/mansrc/*.? $(CURDIR)/debian/man
	dh_installman --
