#!/usr/bin/make -f

export DEB_BUILD_MAINT_OPTIONS=hardening=+all

DEB_PKG_DIR = $(abspath $(dir $(filter %rules, $(MAKEFILE_LIST))))
export DEB_PKG_VERSION = $(shell dpkg-parsechangelog -l$(DEB_PKG_DIR)/changelog -S Version)

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

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

%:
	dh $@ --with autoreconf --parallel

override_dh_auto_build-indep:
	dh_auto_build -i
	$(MAKE) -C dox html

override_dh_auto_test-arch:
	chmod a+x omalloc/getlucky-omtTest-X.sh
	dh_auto_test -a

override_dh_auto_test-indep:

DEB_AUTO_INSTALL_MAKEFLAGS = TOPSRCDIR=$(CURDIR) DESTDIR=$(CURDIR)/debian/tmp
override_dh_auto_install-indep:
	dh_auto_install -i
	$(MAKE) -C dox install-html $(DEB_AUTO_INSTALL_MAKEFLAGS)

## WARNING: documentation might not be clean
override_dh_compress-indep:
	dh_compress -X.hlp

override_dh_link-arch:
	dh_link -p libsingular4-dev \
		/usr/lib/$(DEB_HOST_MULTIARCH)/pkgconfig/Singular.pc /usr/lib/$(DEB_HOST_MULTIARCH)/pkgconfig/singular.pc

##override_dh_link-indep:
##	dh_link -p singular-doc \
##		/usr/share/info/singular.hlp.gz /usr/share/info/singular.info.gz

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