#!/usr/bin/make -f

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

%:
	dh $@ --with ocaml

override_dh_auto_configure:

override_dh_auto_install:
	mkdir -p '$(OCAMLFIND_DESTDIR)'
	dh_auto_install -- INSTALL_ARGS='--destdir=$(DESTDIR) --verbose'

override_dh_missing:
	dh_missing --fail-missing

# Preprocess migrate_parsetree_versions.mli, which contains OCaml_OCAML_VERSION..
debian/preprocess-ocamldoc.sh:
	echo '#!/bin/sh' > "$@"
	echo 'sed -e "s/OCaml_OCAML_VERSION/OCaml_$(shell echo $(OCAML_ABI) | cut -d. -f1-2 | tr -d .)/g" "$$@"' >> "$@"
	chmod +x "$@"

override_dh_ocamldoc: debian/preprocess-ocamldoc.sh
	dh_ocamldoc -u "-pp $<"
