#!/usr/bin/make -f

#export DEB_BUILD_MAINT_OPTIONS = hardening=+all

include /usr/share/cdbs/1/rules/autoreconf.mk
include /usr/share/cdbs/1/rules/ocaml.mk
include /usr/share/cdbs/1/rules/debhelper.mk
include /usr/share/cdbs/1/class/autotools.mk

DESTDIR_DEV=$(CURDIR)/debian/libvirt-ocaml-dev
DESTDIR=$(CURDIR)/debian/libvirt-ocaml

DEB_MAKE_CLEAN_TARGET    := clean
DEB_MAKE_BUILD_TARGET    := all
ifeq ($(OCAML_HAVE_OCAMLOPT),yes)
DEB_MAKE_BUILD_TARGET    += opt
DEB_MAKE_INSTALL_TARGET  := install-opt
else
DEB_MAKE_INSTALL_TARGET  := install-byte
endif
DEB_MAKE_INSTALL_TARGET  += OCAMLFIND_DESTDIR="$(DESTDIR_DEV)/$(OCAML_STDLIB_DIR)" prefix="$(DESTDIR)/usr"

clean::
	-$(RM) '$(CURDIR)/Make.rules'
	-$(RM) '$(CURDIR)/Makefile'
	-$(RM) '$(CURDIR)/libvirt/Makefile'
	-$(RM) '$(CURDIR)/examples/Makefile'

install/libvirt-ocaml-dev::
	mv $(DESTDIR_DEV)/$(OCAML_STDLIB_DIR)/libvirt/*.so $(DESTDIR)/$(OCAML_DLL_DIR)/
	rm -rf $(CURDIR)/debian/libvirt-ocaml/usr/bin
