[notmuch] [PATCH] notmuch: improve installation of emacs mode

Jeffrey C. Ollie jeff at ocjtech.us
Thu Nov 19 05:12:48 PST 2009


1) Add a separate install target to install emacs mode.

2) Don't hardcode the installation directory, instead use emacs'
   pkg-config module.

3) Install a byte compiled version of the emacs mode.

4) Install the emacs mode in emacs' site-start directory so that it
   gets loaded automatically.

Signed-off-by: Jeffrey C. Ollie <jeff at ocjtech.us>
---
 Makefile       |    6 ++++++
 Makefile.local |   13 ++++++++++---
 2 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/Makefile b/Makefile
index 023b2ec..17fa4a2 100644
--- a/Makefile
+++ b/Makefile
@@ -7,6 +7,9 @@ CFLAGS=-O2
 extra_cflags := $(shell pkg-config --cflags glib-2.0 gmime-2.4 talloc)
 extra_cxxflags := $(shell xapian-config --cxxflags)
 
+emacs_lispdir := $(shell pkg-config emacs --variable sitepkglispdir)
+emacs_startdir := $(shell pkg-config emacs --variable sitestartdir)
+
 # Now smash together user's values with our extra values
 override CFLAGS += $(WARN_FLAGS) $(extra_cflags)
 override CXXFLAGS += $(WARN_FLAGS) $(extra_cflags) $(extra_cxxflags)
@@ -28,6 +31,9 @@ include Makefile.config
 %.o: %.c
 	$(CC) -c $(CFLAGS) $< -o $@
 
+%.elc: %.el
+	emacs -batch -f batch-byte-compile $<
+
 .deps/%.d: %.c
 	@set -e; rm -f $@; mkdir -p $$(dirname $@) ; \
 	$(CC) -M $(CPPFLAGS) $(CFLAGS) $< > $@.$$$$; \
diff --git a/Makefile.local b/Makefile.local
index 6bc01a5..e4a27e5 100644
--- a/Makefile.local
+++ b/Makefile.local
@@ -1,4 +1,4 @@
-all: notmuch notmuch.1.gz
+all: notmuch notmuch.1.gz notmuch.elc
 
 notmuch_client_srcs =		\
 	notmuch.c		\
@@ -25,15 +25,22 @@ notmuch.1.gz: notmuch.1
 
 install: all notmuch.1.gz
 	for d in $(DESTDIR)$(prefix)/bin/ $(DESTDIR)$(prefix)/share/man/man1 \
-		$(DESTDIR)/$(prefix)/share/emacs/site-lisp/ $(DESTDIR)/etc/bash_completion.d/ ; \
+		$(DESTDIR)/etc/bash_completion.d/ ; \
 	do \
 		install -d $$d ; \
 	done ;
 	install notmuch $(DESTDIR)$(prefix)/bin/
 	install -m0644 notmuch.1.gz $(DESTDIR)$(prefix)/share/man/man1/
-	install -m0644 notmuch.el $(DESTDIR)$(prefix)/share/emacs/site-lisp/
 	install notmuch-completion.bash \
 		$(DESTDIR)/etc/bash_completion.d/notmuch
 
+install-emacs: install notmuch.elc
+	for d in $(DESTDIR)/$(emacs_startdir) ; \
+	do \
+		install -d $$d ; \
+	done ;
+	install -m0644 notmuch.el $(DESTDIR)$(emacs_startdir)
+	install -m0644 notmuch.elc $(DESTDIR)$(emacs_startdir)
+
 SRCS  := $(SRCS) $(notmuch_client_srcs)
 CLEAN := $(CLEAN) notmuch $(notmuch_client_modules)
-- 
1.6.5.2



More information about the notmuch mailing list