#!/usr/bin/make -f
# debian/rules for ocaml-gettext package
# Copyright (C) 2008 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.
#
export DEB_BUILD_MAINT_OPTIONS = hardening=+all
DPKG_EXPORT_BUILDFLAGS = 1
include /usr/share/dpkg/buildflags.mk
include /usr/share/ocaml/ocamlvars.mk
DESTDIR := $(CURDIR)/debian/tmp

PACKAGE=libgettext-ocaml
PACKAGE_DEV=libgettext-ocaml-dev

export OCAMLFIND_DESTDIR=$(DESTDIR)$(OCAML_STDLIB_DIR)
export PKG_CONFIG_PATH=/usr/lib/$(DEB_BUILD_ARCH)/pkgconfig

%:
	dh $@ --with ocaml

override_dh_auto_clean:
	make clean

override_dh_auto_build:
	[ -f debian/autoreconf.before ] || dh_autoreconf
	$(MAKE) build

override_dh_auto_install:
	mkdir -p $(DESTDIR)/$(OCAML_STDLIB_DIR)
	$(MAKE) install DESTDIR=$(DESTDIR) \
		prefix=$(DESTDIR)/usr sysconfdir=$(DESTDIR)/etc \
		OCAMLFIND_LDCONF=ignore \
		DOCDIR='$(DESTDIR)/usr/share/doc/$(PACKAGE_DEV)'
	dh_install

# Tests are not compatible with bytecode architectures
override_dh_auto_test:
ifdef ($(OCAML_OPT_ARCH))
	dh_auto_test
endif
