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

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

include /usr/share/ocaml/ocamlvars.mk

DESTDIR := $(CURDIR)/debian/tmp
export OCAMLFIND_DESTDIR=$(DESTDIR)/$(OCAML_STDLIB_DIR)/cppo_ocamlbuild
BUILD_PATH=_build/install/default/lib/cppo_ocamlbuild

%:
	dh $@ --with ocaml

.PHONY: override_dh_auto_install
override_dh_auto_install:
	for file in `find $(BUILD_PATH) -type l -printf "%P "`; do	\
	  mkdir -p $(OCAMLFIND_DESTDIR)/`dirname $$file`;		\
	  cp -L $(BUILD_PATH)/$$file $(OCAMLFIND_DESTDIR)/$$file;	\
	done
	mkdir -p $(DESTDIR)/usr/bin
	cp -L _build/install/default/bin/cppo $(DESTDIR)/usr/bin
	mkdir -p $(DESTDIR)/usr/share/doc/cppo
	cp -L README.md $(DESTDIR)/usr/share/doc/cppo/README.md

override_dh_missing:
	dh_missing --fail-missing
