#!/usr/bin/make -f

%:
	dh $@

# 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_auto_configure:
	@( \
		gtkdocize --flavour no-tmpl; \
		libtoolize -f; \
		aclocal; \
		autoheader -f; \
		autoconf -f; \
		automake -f -a --foreign; \
		dh_auto_configure -- \
		                  --disable-silent-rules \
		                  --enable-introspection=yes \
		                  --enable-gtk-doc; \
	)

# 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
