#!/usr/bin/make -f

%:
	dh $@

# Upstream's Makefile has no build step: its first target is install, which
# refuses to run as anything but root and runs grub-mkconfig on the build host,
# and its clean deletes the shipped temp/ directory. debian/install does the
# install instead.
override_dh_auto_build override_dh_auto_install override_dh_auto_clean:

# The config is sourced by the grub.d script and read by systemd as an
# EnvironmentFile, never executed.
execute_after_dh_install:
	sed -i '1{/^#!/d}' debian/grub-btrfs/etc/default/grub-btrfs/config

# Upstream's pages are org-mode exports: \fC names a font groff does not have,
# and the literal \${prefix} reads to troff as a macro argument.
execute_before_dh_installman:
	mkdir -p debian/man
	for page in grub-btrfs grub-btrfsd; do \
		sed -e 's/\\fC/\\f(CR/g' -e 's/\\\$$/\\e$$/g' manpages/$$page.8.man >debian/man/$$page.8 || exit 1; \
	done
