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

include /usr/share/ocaml/ocamlvars.mk

OMAKE=omake --verbose
DESTDIR=$(CURDIR)/debian/tmp
OCAMLFIND_DESTDIR=$(DESTDIR)$(OCAML_STDLIB_DIR)
export OCAMLFIND_DESTDIR

%:
	dh $@ --with ocaml

.PHONY: override_dh_auto_configure
override_dh_auto_configure:
ifeq ($(OCAML_HAVE_OCAMLOPT),no)
	sed -i 's/NATIVE_ENABLED=./NATIVE_ENABLED=0/' OMakefile
endif

.PHONY: override_dh_auto_build
override_dh_auto_build:
	$(OMAKE)

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

.PHONY: override_dh_auto_clean
override_dh_auto_clean:
	$(OMAKE) clean
	find -name '*.omc' -delete
	sed -i 's/NATIVE_ENABLED=./NATIVE_ENABLED=1/' OMakefile

.PHONY: override_dh_install
override_dh_install:
	dh_install --fail-missing -X.so.owner

.PHONY: override_dh_installexamples
override_dh_installexamples:
	dh_installexamples -X'.cm*' -X.o -Xliv-furuse -X.cvsignore

.PHONY: override_dh_compress
override_dh_compress:
	dh_compress -Xexamples
