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

include /usr/share/ocaml/ocamlvars.mk

OMAKE=omake
DESTDIR=$(CURDIR)/debian/tmp
export OCAMLFIND_DESTDIR=$(DESTDIR)$(OCAML_STDLIB_DIR)
export OCAMLFIND_LDCONF=ignore
ifeq ($(OCAML_HAVE_OCAMLOPT),no)
export NATIVE_ENABLED=false
export OCAMLFIND_PREDICATES=byte
endif

ifeq (,$(filter terse,$(DEB_BUILD_OPTIONS)))
	OMAKE += --verbose
endif

%:
	dh $@ --with ocaml

.PHONY: override_dh_auto_build
override_dh_auto_build:
	$(OMAKE) --config

.PHONY: override_dh_auto_install
override_dh_auto_install:
	mkdir -p $(OCAMLFIND_DESTDIR)
	$(OMAKE) install

.PHONY: override_dh_auto_clean
override_dh_auto_clean:
	$(OMAKE) clean
	find -name '*.omc' -delete

.PHONY: override_dh_installexamples
override_dh_installexamples:
ifeq (,$(filter nodoc,$(DEB_BUILD_OPTIONS)))
	dh_installexamples -X'.cm*' -X.o -Xliv-furuse -X.cvsignore
endif

.PHONY: override_dh_strip
override_dh_strip:
	dh_strip --no-automatic-dbgsym
