#!/usr/bin/make -f

include /usr/share/dpkg/pkg-info.mk

export DEB_BUILD_MAINT_OPTIONS = hardening=+all
DOPACKAGES = $(shell dh_listpackages)

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

%:
	dh $@ --builddirectory=build \
		-O--dbgsym-migration="shishi-dbg (<< 1.0.2-7~)"

override_dh_autoreconf:
	rm -fv lib/gl/m4/libgcrypt.m4
ifneq ($(filter shishi-doc,$(DOPACKAGES)),)
	AUTOPOINT=true dh_autoreconf
else
	AUTOPOINT=true GTKDOCIZE=true dh_autoreconf
endif

CONFIGURE_FLAGS = \
	--disable-rpath \
	--with-db-dir=/var/lib/shishi \
	--with-pam-dir=/usr/lib/$(DEB_HOST_MULTIARCH)/security \
	--with-packager=Debian \
	--with-packager-version=$(DEB_VERSION) \
	--with-packager-bug-reports=https://bugs.debian.org/
ifneq ($(filter shishi-doc,$(DOPACKAGES)),)
CONFIGURE_FLAGS += --enable-gtk-doc --enable-gtk-doc-pdf
else
CONFIGURE_FLAGS += --disable-gtk-doc --disable-gtk-doc-pdf
endif

override_dh_auto_configure:
	dh_auto_configure -- $(CONFIGURE_FLAGS)

override_dh_auto_build:
	dh_auto_build
ifneq ($(filter shishi-doc,$(DOPACKAGES)),)
	make -C build/doc shishi.html shishi.pdf AM_MAKEINFOHTMLFLAGS=--no-split
endif

override_dh_auto_install:
	dh_auto_install
	rm -f debian/tmp/etc/shishi/shishi.keys

override_dh_compress:
	dh_compress -Xshishi.pdf
