TOP_BUILDDIR ?= _BUILD

default:

doc: html


ABS_DOCDIR=$(abspath $(TOP_BUILDDIR))/DEBIAN/doc
html: README.toc.md
	mkdir -p $(ABS_DOCDIR)/html
	sed \
			-n \
			-e 's@.*(\([a-zA-Z-]*\)\.md)@--output $(ABS_DOCDIR)/html/\1.html doc/\1.md@p' \
		$< | \
		xargs --verbose --max-args=3 pandoc
	sed \
			-e 's@\[\([a-zA-Z-]*\)\.md\]@[\1]@g' \
			-e 's@(\([a-zA-Z-]*\)\.md)@(\1.html)@g' \
		$< | \
		pandoc --verbose --output $(ABS_DOCDIR)/html/index.html
