#!/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:
	@( \
		autoreconf --force \
		           --install \
		           --symlink; \
		dh_auto_configure -- \
		                  --disable-silent-rules; \
	)

# Rebuild the series file by looking at the contents of the 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-series:
	@( \
		SERIES=debian/patches/series; \
		echo "# To rebuild this file, use \`debian/rules $@'" \
			> $${SERIES}; \
		for patch in debian/patches/U*.diff debian/patches/D*.diff; \
		do \
			test -f "$${patch}" || continue; \
			patch=$$(basename $${patch}); \
			echo $${patch} \
				>> $${SERIES}; \
		done; \
	)

.PHONY: rebuild-series
