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

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

include /usr/share/ocaml/ocamlvars.mk

export OCAMLFIND_DESTDIR := $(CURDIR)/debian/libcsv-ocaml-dev/$(OCAML_STDLIB_DIR)

OCAML_RUN := $(if $(OCAML_OPT_ARCH),ocaml-base-nox-$(OCAML_ABI))
OPTTARGET := $(if $(OCAML_OPT_ARCH),opt)

DB2MAN := /usr/share/xml/docbook/stylesheet/nwalsh/manpages/docbook.xsl
XP := xsltproc -''-nonet

%:
	dh --with ocaml $@

debian/csvtool.1: debian/csvtool.dbk
	$(XP) -o $@ $(DB2MAN) $<

.PHONY: override_dh_auto_build
override_dh_auto_build: debian/csvtool.1
	$(MAKE) byte $(OPTTARGET) 
	$(MAKE) tests
	$(MAKE) examples

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