#!/usr/bin/make -f
# debian/rules for ocamlgraph package
# Copyright (C) 2006 Sylvain Le Gall <gildor@debian.org>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2, or (at
# your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
# MA 02110-1301, USA.

include /usr/share/cdbs/1/rules/ocaml.mk
include /usr/share/cdbs/1/class/autotools.mk
include /usr/share/cdbs/1/rules/debhelper.mk
include $(CURDIR)/debian/mk/docbook-manpage.mk

DEV_PKG = libocamlgraph-ocaml-dev
VIW_PKG = libocamlgraph-viewer-ocaml-dev
DEB_MAKE_CLEAN_TARGET = distclean
DEB_MAKE_BUILD_TARGET = all 
DEB_MAKE_INSTALL_TARGET = install \
			  BINDIR="$(CURDIR)/debian/ocamlgraph-editor/usr/bin" \
			  INSTALL_LIBDIR="$(CURDIR)/debian/$(DEV_PKG)/$(OCAML_STDLIB_DIR)/ocamlgraph/"

OCAML_DHOCAML_FLAGS += --nodefined-map $(DEV_PKG):Dgraph

install/libocamlgraph-ocaml-dev:: install/libocamlgraph-ocaml-doc
	find $(CURDIR)/debian -name '*.mli' -exec chmod 644 '{}' ';'
	mkdir -p $(CURDIR)/debian/$(VIW_PKG)/$(OCAML_STDLIB_DIR)/ocamlgraph/
	for file in dgraph.cmx viewGraph_select.mli dGraphRandModel.mli viewgraph.cmo \
		dGraphViewItem.mli dGraphModel.mli dgraph.cmo viewgraph.cmx viewgraph.cmi \
		dgraph.cmi viewgraph.o dgraph.o dGraphView.mli viewGraph_utils.mli viewGraph_core.mli; do \
		[ ! -f "$(CURDIR)/debian/$(DEV_PKG)$(OCAML_STDLIB_DIR)/ocamlgraph/$$file" ] || \
			mv "$(CURDIR)/debian/$(DEV_PKG)$(OCAML_STDLIB_DIR)/ocamlgraph/$$file" \
				"$(CURDIR)/debian/$(VIW_PKG)$(OCAML_STDLIB_DIR)/ocamlgraph/"; \
	done

DEB_STRIP_EXCLUDE += usr/bin/ocamlgraph-editor.byte usr/bin/ocamlgraph-viewer.byte
ifeq ($(OCAML_HAVE_OCAMLOPT),no)
DEB_STRIP_EXCLUDE += usr/bin/ocamlgraph-editor usr/bin/ocamlgraph-viewer
endif
DEB_DH_GENCONTROL_ARGS += -VF:OCamlInterp="ocaml-base-nox-$(OCAML_ABI), liblablgtk2-ocaml, liblablgtk2-gnome-ocaml"

PO4A_SOURCES := $(CURDIR)/debian/xml-man/po4a/po4a.cfg

DOCBOOK_MANPAGE_SOURCES := $(CURDIR)/debian/xml-man/en/ocamlgraph-editor.xml \
			   $(CURDIR)/debian/xml-man/en/ocamlgraph-viewer.xml

DOCBOOK_MANPAGE_EXTRA_SOURCES := $(CURDIR)/debian/xml-man/en/license.xml      \
                                 $(CURDIR)/debian/xml-man/en/refentryinfo.xml
