#!/usr/bin/make -f

export DEB_BUILD_MAINT_OPTIONS = hardening=+all

DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)
DEB_UPSTREAM_VERSION = $(shell dpkg-parsechangelog -S version | cut -d - -f 1 | cut -d : -f 2)

BUILD_ARGS = prefix=/usr libdir=/usr/lib/$(DEB_HOST_MULTIARCH) NORPATH=1 BUILD_EXAMPLES=n BUILD_BENCHMARKS=n

%:
	dh $@

override_dh_auto_build:
	+$(MAKE) doc
	dh_auto_build  -- $(BUILD_ARGS)

override_dh_auto_install:
	dh_auto_install -- $(BUILD_ARGS)

override_dh_installexamples:
	dh_installexamples --exclude=.gitignore --exclude=.vcxproj

override_dh_missing:
	dh_missing --list-missing --exclude=usr/share/man --exclude=usr/lib/$(DEB_HOST_MULTIARCH)/vmem_debug/

override_dh_auto_test:
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
	cp debian/testconfig.* src/test/
	+$(MAKE) check $(BUILD_ARGS)
endif
