#!/usr/bin/make -f

export DEB_PKG_VERSION = $(shell dpkg-parsechangelog | sed -n -e '/^Version:/s/Version: //p')

DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)

export TOP_SRCDIR=$(CURDIR)

CMAKE ?= /usr/bin/cmake

default:
	@uscan --no-conf --dehs --report || true

%:
	dh $@  --sourcedirectory=source --builddirectory=_build --parallel

override_dh_auto_configure:
	dh_auto_configure -- -DLIB_SUFFIX="/$(DEB_HOST_MULTIARCH)"

override_dh_auto_build-indep:
	$(MAKE) -C doc pdf

override_dh_prep-arch:
	$(MAKE) -f debian/adhoc/Makefile manpages

override_dh_auto_install-indep:
	cd _build && DESTDIR=$(CURDIR)/debian/tmp $(CMAKE) -DCOMPONENT=headers -P cmake_install.cmake
	$(MAKE) -C doc install DESTDIR=$(CURDIR)/debian/tmp
	$(MAKE) -C example install DESTDIR=$(CURDIR)/debian/tmp

override_dh_compress-indep:
	dh_compress -X.pdf -Xexamples

override_dh_strip:
	dh_strip --dbg-package=libnormaliz0v5-dbg

override_dh_auto_clean-indep:
	[ ! -f doc/Makefile ] || $(MAKE) -C doc maintainer-clean

get-orig-source:
	uscan --no-conf --download-current-version --verbose
