#!/usr/bin/make -f

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

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

%:
	dh $@ --builddirectory=build \
		-O--dbgsym-migration="gss-dbg (<< 1.0.3-4~)"

override_dh_autoreconf:
ifneq ($(filter gss-doc,$(DOPACKAGES)),)
	dh_autoreconf
else
	GTKDOCIZE=true dh_autoreconf
endif

CONFIGURE_FLAGS = \
	--with-po-suffix \
	--disable-rpath \
	--with-packager=Debian \
	--with-packager-version=$(DEB_VERSION) \
	--with-packager-bug-reports=https://bugs.debian.org/
ifneq ($(filter gss-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)

ifneq ($(filter gss-doc,$(DOPACKAGES)),)
execute_after_dh_auto_build:
	rm -f doc/gss.html doc/gss.pdf
	make -C build/doc gss.html gss.pdf
endif

override_dh_auto_test:
	datefudge "2020-01-01" dh_auto_test $(DH_BUILD_OPTS)

override_dh_compress:
	dh_compress -Xgss.pdf
