#!/usr/bin/make -f
# debian/rules for ocaml-tools

include /usr/share/ocaml/ocamlvars.mk

DESTDIR := $(CURDIR)/debian/ocaml-tools

# top level dir for documentation
DOCDIR = /usr/share/doc/ocaml-tools

# share dir where files are to be installed
SHDIR = /usr/share/ocaml-tools

VIMDIR = /usr/share/vim/addons

# omlet source dir
OMLETSRC = $(shell echo omlet-*)

build-arch:

build-indep:
	$(MAKE) -C ocaml-autoconf/
	$(MAKE) -C ocamldot/ ocamldot
	cp ocaml-autoconf/README ocaml-autoconf/README.ocaml-autoconf
	cd omlet-* && (cp README README.omlet ; cp ChangeLog changelog.omlet)
	cp ocamldot/README README.ocamldot

build: build-arch build-indep

clean: 
	dh_testdir
	dh_testroot
	$(MAKE) -C ocaml-autoconf/ clean
	$(MAKE) -C ocamldot/ clean
	rm -f ocaml-autoconf/README.ocaml-autoconf
	rm -f omlet-*/README.omlet omlet-*/changelog.omlet
	rm -f README.ocamldot
	dh_clean

install:
	dh_testdir
	dh_testroot
	dh_clean -k
	dh_installdirs
	BASE=$(DESTDIR)/$(VIMDIR) make -C $(OMLETSRC) install-aux
	echo 'F:OCamlABI=$(OCAML_ABI)' >> debian/ocaml-tools.substvars

binary-arch: build-arch

binary-indep: build-indep install
	dh_testdir
	dh_testroot
	dh_install
	dh_installdocs
	dh_installchangelogs
	dh_installman
	dh_lintian
	dh_link
	dh_compress
	dh_fixperms
	dh_installdeb
	dh_gencontrol
	dh_md5sums
	dh_builddeb

binary: binary-arch binary-indep

.PHONY: build clean binary-indep binary-arch binary install