#!/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
export OCAMLFIND_DESTDIR=$(OCAML_STDLIB_DIR)
export OCAMLFIND_LDCONF=ignore

%:
	dh $@ --with ocaml

.PHONY: override_dh_auto_configure
override_dh_auto_configure:
	cp  src/.depend debian/src.depend.backup
	dh_auto_configure -- --with-gl --with-glade --with-rsvg		\
	--without-gnomecanvas --with-gtkspell --without-gnomeui \
	--with-gtksourceview2

.PHONY: override_dh_auto_build
override_dh_auto_build:
	$(MAKE)
ifneq ($(OCAML_OPT_ARCH),)
	$(MAKE) opt
endif

.PHONY: override_dh_auto_clean
override_dh_auto_clean:
	[ ! -f config.make ] || $(MAKE) clean
	if [ -f debian/src.depend.backup ]; then \
	  mv debian/src.depend.backup src/.depend; \
	fi
	$(RM) config.log config.make config.status test_dynlink.*

.PHONY: override_dh_auto_install
override_dh_auto_install:
	mkdir -p '$(OCAMLFIND_DESTDIR)'
	$(MAKE) install DESTDIR=$(DESTDIR)
# remove files related to gtksourceview1 (uncompiled anyway... and
# make dh_ocamldoc fail)
	rm \
	  debian/tmp/usr/lib/ocaml/lablgtk2/gtkSourceView_types.mli \
	  debian/tmp/usr/lib/ocaml/lablgtk2/gSourceView.mli
# remove files related to uncompiled gnome-panel (see #638133)
	rm debian/tmp/usr/lib/ocaml/lablgtk2/panel.mli
# remove files related to libgnomeui (see #868392)
	rm debian/tmp/usr/lib/ocaml/lablgtk2/gnoDruid.mli
# remove files related to libgnomecanvas (see #885677)
	rm debian/tmp/usr/lib/ocaml/lablgtk2/gnoCanvas.mli
# FIXME: we should use upstream META file
	rm debian/tmp/usr/lib/ocaml/lablgtk2/META

.PHONY: override_dh_installexamples
override_dh_installexamples:
	dh_installexamples --exclude='.cvsignore'

.PHONY: override_dh_missing
override_dh_missing:
	dh_missing --fail-missing -Xbuild.ml
