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

include /usr/share/ocaml/ocamlvars.mk
PREFIX = $(CURDIR)/debian/tmp
OCAMLFIND_DESTDIR = $(PREFIX)$(OCAML_STDLIB_DIR)

EXAMPLES_TARBALL = debian/examples.tar.gz

%:
	dh --with autoreconf,ocaml $@

$(EXAMPLES_TARBALL):
	tar -czf $(EXAMPLES_TARBALL) --exclude=parse.ml examples

.PHONY: override_dh_auto_configure
override_dh_auto_configure: $(EXAMPLES_TARBALL)
	OCAMLFIND_DESTDIR=$(OCAML_STDLIB_DIR) ./configure --prefix=$(PREFIX)/usr

.PHONY: override_dh_auto_install
override_dh_auto_install:
ifneq (,$(findstring libmlpost-ocaml-doc,$(shell dh_listpackages)))
	$(MAKE) doc
endif
	mkdir -p $(OCAMLFIND_DESTDIR)
	$(MAKE) DESTDIR="-destdir $(OCAMLFIND_DESTDIR)" install

.PHONY: override_dh_auto_test
override_dh_auto_test:
