From c9c4108a7d7297fd3be2f3cb67913b318a7c498a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= <ludo@gnu.org>
Date: Wed, 20 Feb 2008 11:16:59 +0000
Subject: [PATCH] BBDB: Install Emacs Lisp code to
 `$out/share/emacs/site-lisp'; install documentation.

svn path=/nixpkgs/trunk/; revision=10769
---
 .../editors/emacs-modes/bbdb/builder.sh       |  9 ++++--
 .../editors/emacs-modes/bbdb/default.nix      |  3 +-
 .../emacs-modes/bbdb/install-infodir.patch    | 28 +++++++++++++++++++
 3 files changed, 37 insertions(+), 3 deletions(-)
 create mode 100644 pkgs/applications/editors/emacs-modes/bbdb/install-infodir.patch

diff --git a/pkgs/applications/editors/emacs-modes/bbdb/builder.sh b/pkgs/applications/editors/emacs-modes/bbdb/builder.sh
index 338beb8b91bb..b860adbb745f 100644
--- a/pkgs/applications/editors/emacs-modes/bbdb/builder.sh
+++ b/pkgs/applications/editors/emacs-modes/bbdb/builder.sh
@@ -1,7 +1,12 @@
 source "$stdenv/setup" || exit 1
 
 unpackPhase &&							\
-cd bbdb-*.* &&							\
+cd bbdb-*.* && patchPhase &&					\
 ./configure --prefix="$out"					\
             --with-package-dir="$out/share/emacs/site-lisp" &&	\
-make && make install-pkg
+make && make install-pkg &&					\
+mkdir -p "$out/info" &&						\
+make -C texinfo install-pkg &&					\
+mv "$out/share/emacs/site-lisp/lisp/bbdb/"*			\
+   "$out/share/emacs/site-lisp" &&				\
+rm -rf "$out/share/emacs/site-lisp/lisp"
diff --git a/pkgs/applications/editors/emacs-modes/bbdb/default.nix b/pkgs/applications/editors/emacs-modes/bbdb/default.nix
index 4b485d90e3f0..3799d0a0f1bd 100644
--- a/pkgs/applications/editors/emacs-modes/bbdb/default.nix
+++ b/pkgs/applications/editors/emacs-modes/bbdb/default.nix
@@ -8,8 +8,9 @@ stdenv.mkDerivation {
     sha256 = "3fb1316e2ed74d47ca61187fada550e58797467bd9e8ad67343ed16da769f916";
   };
 
-  buildInputs = [emacs texinfo ctags];
+  patches = [ ./install-infodir.patch ];
 
+  buildInputs = [emacs texinfo ctags];
   builder = ./builder.sh;
 
   meta = {
diff --git a/pkgs/applications/editors/emacs-modes/bbdb/install-infodir.patch b/pkgs/applications/editors/emacs-modes/bbdb/install-infodir.patch
new file mode 100644
index 000000000000..31ae6b266980
--- /dev/null
+++ b/pkgs/applications/editors/emacs-modes/bbdb/install-infodir.patch
@@ -0,0 +1,28 @@
+--- bbdb-2.35/texinfo/Makefile.in	2001-11-20 09:00:12.000000000 +0100
++++ bbdb-2.35/texinfo/Makefile.in	2008-02-20 12:07:36.000000000 +0100
+@@ -27,22 +27,22 @@ all: info bbdb.dvi
+ install-pkg: uninstall-pkg info
+ 	@if test "x$(SYMLINKS)" = "xno" ; then                         \
+           for i in `ls bbdb.info* ` ; do                               \
+-            $(INSTALL_DATA) $$i $(PACKAGEDIR)/info/ ;                  \
++            $(INSTALL_DATA) $$i $(infodir)/ ;                  \
+           done ;                                                       \
+         else                                                           \
+           if test "x$(LINKPATH)" = "x" ; then                          \
+             for i in `ls bbdb.info* ` ; do                             \
+-              $(LN_S) `pwd`/$$i $(PACKAGEDIR)/info/$$i ;               \
++              $(LN_S) `pwd`/$$i $(infodir)/$$i ;               \
+             done ;                                                     \
+           else                                                         \
+             for i in `ls bbdb.info* ` ; do                             \
+-              $(LN_S) $(LINKPATH)/texinfo/$$i $(PACKAGEDIR)/info/$$i ; \
++              $(LN_S) $(LINKPATH)/texinfo/$$i $(infodir)/$$i ; \
+             done ;                                                     \
+           fi ;                                                         \
+         fi
+ 
+ uninstall-pkg:
+-	-$(RM) $(PACKAGEDIR)/info/bbdb.info*
++	-$(RM) $(infodir)/bbdb.info*
+ 
+ info: bbdb.info