#!/usr/bin/make -f
#DH_VERBOSE = 1

export MAKEDOC=$(CURDIR)/makedoc

%:
	dh $@ --with autoreconf

override_dh_auto_configure:
	./configure \
		--with-asciidoc-doctype=book \
		--enable-html-chunking \
		--enable-section-numbers \
		--enable-asciidoc-docinfo \
		--with-stylesheets=/usr/share/xml/docbook/stylesheet/docbook-xsl

override_dh_auto_build:
	cp drbd-howto-collection.css default.css
	$(MAKE) -C users-guide all

# make install does nothing useful
override_dh_auto_install:

override_dh_auto_clean:
	# Upstream/makedoc doesn't offer a clean target, so we have to
	# implement things ourselves.
	rm -f default.css
	rm -f users-guide/*.html users-guide/*.pdf
	for file in images/*.svg users-guide/*.svg; do rm -f "$${file%.svg}.png"; done
	for file in users-guide/*.mml; do rm -f "$${file%.mml}.svg"; done
	find "$(CURDIR)" -name Makefile -delete
	find "$(CURDIR)/makedoc" -type f -name '*.xsl' -delete

override_dh_autoreconf:
	dh_autoreconf debian/autogen.sh

override_dh_autoreconf_clean:
	dh_autoreconf_clean
	rm -f Makefile.am autogen.sh configure.ac.stub config.log config.status

.PHONY: override_dh_auto_configure override_dh_auto_build \
	override_dh_auto_install override_dh_auto_clean \
	override_dh_autoreconf override_dh_autoreconf_clean
