#!/usr/bin/make -f
# -*- makefile -*-

include /usr/share/ocaml/ocamlvars.mk

PO4A_SOURCES := $(CURDIR)/debian/xml-man/po4a/po4a.cfg

PO4A_BUILD_FLAGS:= --rm-backups

DOCBOOK_MANPAGE_XSLTPROC_FLAGS := --nonet --xinclude --param man.charmap.use.subset 0
DOCBOOK_MANPAGE_XSLTPROC_XSL := /usr/share/xml/docbook/stylesheet/nwalsh/manpages/docbook.xsl

DOCBOOK_MANPAGE_SOURCES := $(CURDIR)/debian/xml-man/en/camomilecharmap.xml  \
                           $(CURDIR)/debian/xml-man/en/camomilelocaledef.xml \
			   $(CURDIR)/debian/xml-man/de/camomilecharmap.xml  \
                           $(CURDIR)/debian/xml-man/de/camomilelocaledef.xml \
			   $(CURDIR)/debian/xml-man/pt/camomilecharmap.xml  \
                           $(CURDIR)/debian/xml-man/pt/camomilelocaledef.xml

%:
	dh $@ --with ocaml --buildsystem ocaml_dune

override_dh_ocamldoc:
	po4a $(PO4A_BUILD_FLAGS) $(PO4A_SOURCES)
	xsltproc $(DOCBOOK_MANPAGE_XSLTPROC_FLAGS) -o $(CURDIR)/debian/manpages/ \
		$(DOCBOOK_MANPAGE_XSLTPROC_XSL) $(DOCBOOK_MANPAGE_SOURCES)

override_dh_auto_test:
# Needs stdlib-random

execute_after_dh_clean:
	rm -f debian/camomilecharmap*1 debian/camomilelocaledef*1
	rm -rf debian/xml-man/pt
	rm -rf debian/xml-man/de
