-PROGS=notmuch notmuch-index-message xapian-dump
+PROGS=notmuch
-MYCFLAGS=-Wall -O0 -g
-MYCXXFLAGS=-Wall -O0 -g
+WARN_FLAGS=-Wall -Wextra -Wmissing-declarations -Wwrite-strings -Wswitch-enum
+
+CDEPENDS_FLAGS=`pkg-config --cflags glib-2.0 gmime-2.4 talloc`
+CXXDEPENDS_FLAGS=$(CDEPENDS_FLAGS) `xapian-config --cxxflags`
+
+MYCFLAGS=$(WARN_FLAGS) -O0 -g $(CDEPENDS_FLAGS)
+MYCXXFLAGS=$(WARN_FLAGS) -O0 -g $(CXXDEPENDS_FLAGS)
+
+MYLDFLAGS=`pkg-config --libs glib-2.0 gmime-2.4 talloc` `xapian-config --libs`
+
+LIBRARY= \
+ database.o \
+ date.o \
+ index.o \
+ libsha1.o \
+ message.o \
+ message-file.o \
+ query.o \
+ sha1.o \
+ tags.o \
+ thread.o \
+ xutil.o
+
+MAIN= \
+ notmuch.o
all: $(PROGS)
-notmuch: notmuch.c
- $(CC) $(CFLAGS) $(MYCFLAGS) notmuch.c `pkg-config --cflags --libs glib-2.0` -o notmuch
+%.o: %.cc
+ $(CXX) -c $(CFLAGS) $(CXXFLAGS) $(MYCXXFLAGS) $< -o $@
+
+%.o: %.c
+ $(CC) -c $(CFLAGS) $(MYCFLAGS) $< -o $@
+
+notmuch: $(MAIN) $(LIBRARY)
+ $(CC) $(MYLDFLAGS) $^ -o $@
+
+Makefile.dep: *.c *.cc
+ $(CXX) -M $(CPPFLAGS) $(CDEPENDS_FLAGS) $(CXXDEPENDS_FLAGS) $^ > $@
+-include Makefile.dep
-notmuch-index-message: notmuch-index-message.cc
- $(CXX) $(CXXFLAGS) $(MYCXXFLAGS) notmuch-index-message.cc `pkg-config --cflags --libs gmime-2.4` `xapian-config --cxxflags --libs` -o notmuch-index-message
+notmuch.1.gz:
+ gzip --stdout notmuch.1 > notmuch.1.gz
-xapian-dump: xapian-dump.cc
- $(CXX) $(CXXFLAGS) $(MYCXXFLAGS) xapian-dump.cc `xapian-config --libs --cxxflags` -o xapian-dump
+install: notmuch.1.gz
+ install -C -D notmuch $(DESTDIR)/usr/bin/notmuch
+ install -C -D notmuch.1.gz $(DESTDIR)/usr/share/man/man1
+ install -C -D notmuch-completion.bash $(DESTDIR)/etc/bash_completion.d/notmuch
clean:
- rm -f $(PROGS)
+ rm -f $(PROGS) *.o Makefile.dep