Makefile: Hide away auto-generated dependency file as .depends.
[notmuch] / Makefile
1 PROGS=notmuch
2
3 WARN_FLAGS=-Wall -Wextra -Wmissing-declarations -Wwrite-strings -Wswitch-enum
4
5 NOTMUCH_DEPENDS_FLAGS=-I./lib `pkg-config --cflags glib-2.0 gmime-2.4 talloc`
6 NOTMUCH_CXX_DEPENDS_FLAGS=$(NOTMUCH_DEPENDS_FLAGS) `xapian-config --cxxflags`
7
8 NOTMUCH_CFLAGS=$(WARN_FLAGS) -O0 -g $(NOTMUCH_DEPENDS_FLAGS)
9 NOTMUCH_CXXFLAGS=$(WARN_FLAGS) -O0 -g $(NOTMUCH_CXX_DEPENDS_FLAGS)
10
11 NOTMUCH_LDFLAGS=`pkg-config --libs glib-2.0 gmime-2.4 talloc` \
12                 `xapian-config --libs`
13
14 LIBRARY=                        \
15         lib/database.o          \
16         lib/index.o             \
17         lib/libsha1.o           \
18         lib/message.o           \
19         lib/message-file.o      \
20         lib/query.o             \
21         lib/sha1.o              \
22         lib/tags.o              \
23         lib/thread.o            \
24         lib/xutil.o
25
26 MAIN=                   \
27         notmuch.o
28
29 all: $(PROGS)
30
31 %.o: %.cc
32         $(CXX) -c $(CFLAGS) $(CXXFLAGS) $(NOTMUCH_CXXFLAGS) $< -o $@
33
34 %.o: %.c
35         $(CC) -c $(CFLAGS) $(NOTMUCH_CFLAGS) $< -o $@
36
37 notmuch: $(MAIN) $(LIBRARY)
38         $(CC) $(NOTMUCH_LDFLAGS) $^ -o $@
39
40 .depends: *.c lib/*.c lib/*.cc
41         $(CXX) -M $(CPPFLAGS) $(NOTMUCH_DEPENDS_FLAGS) \
42         $(NOTMUCH_CXX_DEPENDS_FLAGS) $^ > $@
43 -include .depends
44
45 notmuch.1.gz:
46         gzip --stdout notmuch.1 > notmuch.1.gz
47
48 install: all notmuch.1.gz
49         install -C -D notmuch $(DESTDIR)/usr/bin/notmuch
50         install -C -D notmuch.1.gz $(DESTDIR)/usr/share/man/man1
51         install -C -D notmuch-completion.bash \
52                 $(DESTDIR)/etc/bash_completion.d/notmuch
53
54 clean:
55         rm -f $(PROGS) lib/*.o *.o .depends