#!/usr/bin/make -f

include /usr/share/ocaml/ocamlvars.mk

PKGDIR = $(CURDIR)/debian/tmp
export OCAMLFIND_DESTDIR = $(PKGDIR)$(OCAML_STDLIB_DIR)

%:
	dh $@ --with ocaml

override_dh_auto_install:
	# if we do not create this directory manually beforehand, `ocamlfind install` will exit with:
	# ocamlfind: Bad configuration: Cannot mkdir [...] because a path component does not exist or is not a directory
	mkdir -p $(OCAMLFIND_DESTDIR)
	dh_auto_install -- minimal=1

override_dh_installchangelogs:
	dh_installchangelogs CHANGES

# do not require ocamlopt during building or testing
ifneq ($(OCAML_HAVE_OCAMLOPT),yes)

override_dh_auto_build:
	make minimal=1 -C src all

override_dh_auto_test:
	make minimal=1 -C test all run

else

override_dh_auto_build:
	dh_auto_build -- minimal=1

override_dh_auto_test:
	dh_auto_test -- minimal=1

endif
