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

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

include /usr/share/ocaml/ocamlvars.mk

DESTDIR := $(CURDIR)/debian/tmp/$(OCAML_STDLIB_DIR)

%:
	dh $@ --with ocaml

.PHONY: override_dh_auto_configure
override_dh_auto_configure:
	dh_auto_configure -- LDFLAGS="-Wl,-z,defs"

.PHONY: override_dh_auto_build
override_dh_auto_build:
	$(MAKE) bytecode docs
ifneq ($(OCAML_OPT_ARCH),)
	$(MAKE) opt
	ocamlopt -I . -shared -linkall -o sqlite3.cmxs sqlite3.cmxa
endif

.PHONY: override_dh_auto_clean
override_dh_auto_clean:
	[ ! -f Makefile ] || $(MAKE) distclean

.PHONY: override_dh_auto_install
override_dh_auto_install:
	mkdir -p $(CURDIR)/debian/tmp$(OCAML_DLL_DIR)
	mkdir -p $(CURDIR)/debian/tmp/usr/bin
	$(MAKE) prefix=$(CURDIR)/debian/tmp/usr install OCAMLFIND_DESTDIR=$(DESTDIR) OCAMLFIND_LDCONF=ignore
