#!/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) test
	./test
else
	$(MAKE) test.b
	CAML_LD_LIBRARY_PATH=$(CURDIR) ./test.b
endif
endif

override_dh_auto_configure:
	./configure --installdir $(Z_INSTALL_DIR) \
                    --host $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)

%:
	dh $@ --with ocaml
