#!/usr/bin/make -f

DEB_BUILD_MAINT_OPTIONS=hardening=+bindnow
DPKG_EXPORT_BUILDFLAGS=1
include /usr/share/dpkg/buildflags.mk

%:
	dh $@ --with=gir

# Refresh the build system.
#
# The build system is completely regenerated to ensure the tools used to
# build the binary package are the ones shipped with Debian.
override_dh_autoreconf:
	gtkdocize --flavour no-tmpl
	libtoolize -f
	aclocal
	autoheader -f
	autoconf -f
	automake -f -a --foreign

# Call configure
#
# debhelper will take care of all the important stuff such as build
# architecture and installation paths, but we still need to explicitly
# pass a couple of parameters ourselves
override_dh_auto_configure:
	dh_auto_configure -- \
	                  --disable-silent-rules \
	                  --enable-introspection=yes \
	                  --enable-gtk-doc=yes

# Install changelogs.
#
# Upstream's NEWS.markdown is much more useful to end users than
# upstream's ChangeLog, so install that as changelog instead.
override_dh_installchangelogs:
	dh_installchangelogs NEWS.markdown

# Rebuild the patches series by looking at the contents of the
# debian/patches directory.
#
# Patches with names starting with D (Debian-specific) should be applied
# after those with names starting with U (to be forwarded upstream).
rebuild-patches-series:
	@( \
		SERIES=debian/patches/series; \
		{ \
			echo "# To rebuild this file, use \`debian/rules $@'"; \
			for patch in debian/patches/U*.diff debian/patches/D*.diff; \
			do \
				test -f "$${patch}" || continue; \
				patch=$$(basename "$${patch}"); \
				echo "$${patch}"; \
			done; \
		} >"$${SERIES}"; \
	)

.PHONY: rebuild-patches-series
