#!/usr/bin/make -f

include /usr/share/ocaml/ocamlvars.mk

Z_INSTALL_DIR=$(CURDIR)/debian/tmp$(OCAML_STDLIB_DIR)

override_dh_auto_install:
ifneq (,$(findstring libzarith-ocaml-doc,$(shell dh_listpackages)))
	$(MAKE) doc
endif
	mkdir -p $(CURDIR)/debian/tmp/$(OCAML_STDLIB_DIR)/stublibs
	$(MAKE) install

override_dh_auto_test:
ifeq (,$(findstring nocheck,$(DEB_BUILD_OPTIONS)))
ifeq ($(OCAML_HAVE_OCAMLOPT),yes)
	$(MAKE) tests
endif
endif

override_dh_auto_configure:
	for ext in guess; do \
		if [ -f /usr/share/misc/config.$$ext ]; then \
			cp -f /usr/share/misc/config.$$ext $(CURDIR)/config.$$ext; \
		fi; \
	done
	./configure --installdir $(Z_INSTALL_DIR)

%:
	dh $@ --with ocaml --no-parallel
