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

DESTDIR=$(CURDIR)/debian/tmp
include /usr/share/ocaml/ocamlvars.mk

OCAMLFIND_DESTDIR=$(DESTDIR)/$(OCAML_STDLIB_DIR)
export OCAMLFIND_DESTDIR

CONFIGURE_OPTS := -use-findlib -installbindir $(DESTDIR)/usr/bin

%:
	dh $@ --with ocaml

.PHONY: override_dh_auto_configure
override_dh_auto_configure:
	./configure $(CONFIGURE_OPTS)

.PHONY: override_dh_auto_build
override_dh_auto_build:
	$(MAKE) byte
ifeq ($(OCAML_HAVE_OCAMLOPT),yes)
	$(MAKE) opt
endif

.PHONY: override_dh_auto_install
override_dh_auto_install:
	mkdir -p $(OCAMLFIND_DESTDIR) $(OCAMLFIND_DESTDIR)/stublibs $(DESTDIR)/usr/bin
	dh_auto_install

.PHONY: override_dh_auto_clean
override_dh_auto_clean:
	./configure $(CONFIGURE_OPTS)
	dh_auto_clean
	rm -f config/Makefile config/auto-aux/tst

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