#!/usr/bin/make -f
include /usr/share/cdbs/1/rules/debhelper.mk
include /usr/share/cdbs/1/class/makefile.mk
include /usr/share/cdbs/1/rules/ocaml.mk

PKGNAME = libpostgresql-ocaml-dev

DEB_SRCDIR = $(CURDIR)/lib
DEB_MAKE_BUILD_TARGET = NO_CUSTOM=y byte-code-library
CFLAGS += -I$(shell pg_config --includedir) -fPIC
DEB_MAKE_INSTALL_TARGET = install DESTDIR=$(CURDIR)/debian/tmp$(OCAML_STDLIB_DIR)

ifeq ($(OCAML_HAVE_OCAMLOPT),yes)
build/$(PKGNAME)::
	$(MAKE) NO_CUSTOM=y -C $(DEB_SRCDIR)/ native-code-library
endif

ifeq ($(OCAML_NATDYNLINK),yes)
build/$(PKGNAME)::
	cd $(DEB_SRCDIR) && ocamlopt -shared -I . -o postgresql.cmxs -linkall postgresql.cmxa
endif

ifneq ($(OCAML_HAVE_OCAMLOPT),yes)
export LIBINSTALL_FILES = libpostgresql_stubs.a postgresql.cma postgresql.cmi postgresql.mli dllpostgresql_stubs.so
endif
