#!/usr/bin/make -f
# debian/rules for pgocaml package
# Copyright (C) 2009 Guillaume Yziquel <guillaume.yziquel@citycable.ch>
#
# 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/patchsys-quilt.mk
include /usr/share/cdbs/1/rules/ocaml.mk
include /usr/share/cdbs/1/rules/debhelper.mk
include /usr/share/cdbs/1/class/makefile.mk

DEB_MAKE_CLEAN_TARGET   := clean
ifeq ($(OCAML_HAVE_OCAMLOPT),yes)
DEB_MAKE_BUILD_TARGET   := all USE_BATTERIES=yes
DEB_MAKE_INSTALL_TARGET := install DESTDIR=debian/libpgocaml-ocaml-dev/
else
DEB_MAKE_BUILD_TARGET   := all_byte USE_BATTERIES=yes
DEB_MAKE_INSTALL_TARGET := install_byte DESTDIR=debian/libpgocaml-ocaml-dev/
endif

binary-install/libpgocaml-ocaml-dev::
	rm -f debian/libpgocaml-ocaml-dev/$(OCAML_STDLIB_DIR)/pgocaml/META
	rm -f debian/libpgocaml-ocaml-dev/$(OCAML_STDLIB_DIR)/pgocaml/pgocaml.cma
	rm -f debian/libpgocaml-ocaml-dev/$(OCAML_STDLIB_DIR)/pgocaml/pgocaml_prof.cmi
	rm -f debian/libpgocaml-ocaml-dev/$(OCAML_STDLIB_DIR)/pgocaml/pgocaml_prof.cmx

pre-build::
	make depend
	if ! test -f pGOCaml_config.ml.orig; then \
	  cp -f pGOCaml_config.ml pGOCaml_config.ml.orig; \
	fi

clean::
	-$(RM) pgocaml.cmxs
	-mv pGOCaml_config.ml.orig pGOCaml_config.ml
