From: Stephane Glondu <steph@glondu.net>
Date: Mon, 7 Sep 2009 09:47:23 +0200
Subject: DESTDIR in Makefiles

Enable passing target installation directory from debian/rules.

Signed-off-by: Stefano Zacchiroli <zack@debian.org>
Signed-off-by: Stephane Glondu <steph@glondu.net>
---
 OCamlMakefile |    3 +++
 lib/Makefile  |    2 ++
 2 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/OCamlMakefile b/OCamlMakefile
index b8898ad..2ba893d 100644
--- a/OCamlMakefile
+++ b/OCamlMakefile
@@ -1211,12 +1211,14 @@ subprojs: $(SUBPROJS:%=subproj_%)
 .PHONY: libinstall
 libinstall:	all
 	$(QUIET)printf "\nInstalling library with ocamlfind\n"
+	test -d $(DESTDIR) || mkdir -p $(DESTDIR)
 	$(OCAMLFIND) install $(OCAMLFIND_INSTFLAGS) $(RESULT) META $(LIBINSTALL_FILES)
 	$(QUIET)printf "\nInstallation successful.\n"
 
 .PHONY: libinstall-byte-code
 libinstall-byte-code:	all
 	$(QUIET)printf "\nInstalling byte-code library with ocamlfind\n"
+	test -d $(DESTDIR) || mkdir -p $(DESTDIR)
 	$(OCAMLFIND) install $(OCAMLFIND_INSTFLAGS) $(RESULT) META \
 	  $(filter-out $(RESULT).$(EXT_LIB) $(RESULT).cmxa, $(LIBINSTALL_FILES))
 	$(QUIET)printf "\nInstallation successful.\n"
@@ -1224,6 +1226,7 @@ libinstall-byte-code:	all
 .PHONY: libinstall-native-code
 libinstall-native-code:	all
 	$(QUIET)printf "\nInstalling native-code library with ocamlfind\n"
+	test -d $(DESTDIR) || mkdir -p $(DESTDIR)
 	$(OCAMLFIND) install $(OCAMLFIND_INSTFLAGS) $(RESULT) META \
 	  $(filter-out $(DLLSONAME) $(RESULT).cma, $(LIBINSTALL_FILES))
 	$(QUIET)printf "\nInstallation successful.\n"
diff --git a/lib/Makefile b/lib/Makefile
index 008e028..c458f4e 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -10,6 +10,8 @@ CLIBS   = pq
 LIBS    = threads
 RESULT  = postgresql
 THREADS = yes
+DESTDIR =
+OCAMLFIND_INSTFLAGS = -ldconf /dev/null -destdir $(DESTDIR)
 
 all:
 
-- 
