]> git.notmuchmail.org Git - notmuch/blob - Makefile.local
Move bulk of rules from Makefile to Makefile.local.
[notmuch] / Makefile.local
1 # Get settings from the output of configure by running it to generate
2 # Makefile.config if it doesn't exist yet. And add Makefile.config to
3 # our global dependency list.
4 include Makefile.config
5 global_deps += Makefile.config
6 Makefile.config: configure
7         @echo ""
8         @echo "Note: Calling ./configure with no command-line arguments. This is often fine,"
9         @echo "      but if you want to specify any arguments (such as an alternate prefix"
10         @echo "      into which to install), call ./configure explicitly and then make again."
11         @echo "      See \"./configure --help\" for more details."
12         @echo ""
13         ./configure
14
15 SONAME = libnotmuch.so.1
16 WARN_CXXFLAGS=-Wall -Wextra -Wwrite-strings -Wswitch-enum
17 WARN_CFLAGS=$(WARN_CXXFLAGS) -Wmissing-declarations
18
19 # Sub-directory Makefile.local fragments can append to these variables
20 # to have directory-specific cflags as necessary.
21 extra_cflags :=
22 extra_cxxflags :=
23
24 # Smash together user's values with our extra values
25 FINAL_CFLAGS = $(CFLAGS) $(WARN_CFLAGS) $(CONFIGURE_CFLAGS) $(extra_cflags)
26 FINAL_CXXFLAGS = $(CXXFLAGS) $(WARN_CXXFLAGS) $(CONFIGURE_CXXFLAGS) $(extra_cflags) $(extra_cxxflags)
27 FINAL_LDFLAGS = $(LDFLAGS) $(CONFIGURE_LDFLAGS)
28
29 # Additional programs that are used during the compilation process.
30 EMACS ?= emacs --quick
31 # Lowercase to avoid clash with GZIP environment variable for passing
32 # arguments to gzip.
33 gzip = gzip
34
35 bash_completion_dir = /etc/bash_completion.d
36 zsh_completion_dir = /usr/share/zsh/functions/Completion/Unix
37
38 all: notmuch notmuch.1.gz
39 ifeq ($(MAKECMDGOALS),)
40         @echo ""
41         @echo "Compilation of notmuch is now complete. You can install notmuch with:"
42         @echo ""
43         @echo " make install"
44         @echo ""
45         @echo "Note that depending on the prefix to which you are installing"
46         @echo "you may need root permission (such as \"sudo make install\")."
47         @echo "See \"./configure --help\" for help on setting an alternate prefix."
48 endif
49
50 # The user has not set any verbosity, default to quiet mode and inform the
51 # user how to enable verbose compiles.
52 ifeq ($(V),)
53 quiet_DOC := "Use \"$(MAKE) V=1\" to see the verbose compile lines.\n"
54 quiet = @printf $(quiet_DOC)$(eval quiet_DOC:=)"  $1 $2 $@\n"; $($1)
55 endif
56 # The user has explicitly enabled quiet compilation.
57 ifeq ($(V),0)
58 quiet = @printf "  $1   $@\n"; $($1)
59 endif
60 # Otherwise, print the full command line.
61 quiet ?= $($1)
62
63 %.o: %.cc $(global_deps)
64         $(call quiet,CXX,$(CXXFLAGS)) -c $(FINAL_CXXFLAGS) $< -o $@
65
66 %.o: %.c $(global_deps)
67         $(call quiet,CC,$(CFLAGS)) -c $(FINAL_CFLAGS) $< -o $@
68
69 %.elc: %.el
70         $(call quiet,EMACS) -batch -f batch-byte-compile $<
71
72 .deps/%.d: %.c $(global_deps)
73         @set -e; rm -f $@; mkdir -p $$(dirname $@) ; \
74         $(CC) -M $(CPPFLAGS) $(FINAL_CFLAGS) $< > $@.$$$$ 2>/dev/null ; \
75         sed 's,'$$(basename $*)'\.o[ :]*,$*.o $@ : ,g' < $@.$$$$ > $@; \
76         rm -f $@.$$$$
77
78 .deps/%.d: %.cc $(global_deps)
79         @set -e; rm -f $@; mkdir -p $$(dirname $@) ; \
80         $(CXX) -M $(CPPFLAGS) $(FINAL_CXXFLAGS) $< > $@.$$$$ 2>/dev/null ; \
81         sed 's,'$$(basename $*)'\.o[ :]*,$*.o $@ : ,g' < $@.$$$$ > $@; \
82         rm -f $@.$$$$
83
84 DEPS := $(SRCS:%.c=.deps/%.d)
85 DEPS := $(DEPS:%.cc=.deps/%.d)
86 -include $(DEPS)
87
88 .PHONY : clean
89 clean:
90         rm -f $(CLEAN); rm -rf .deps
91
92 notmuch_client_srcs =           \
93         $(notmuch_compat_srcs)  \
94         debugger.c              \
95         gmime-filter-reply.c    \
96         notmuch.c               \
97         notmuch-config.c        \
98         notmuch-count.c         \
99         notmuch-dump.c          \
100         notmuch-new.c           \
101         notmuch-reply.c         \
102         notmuch-restore.c       \
103         notmuch-search.c        \
104         notmuch-search-tags.c   \
105         notmuch-setup.c         \
106         notmuch-show.c          \
107         notmuch-tag.c           \
108         notmuch-time.c          \
109         query-string.c          \
110         show-message.c          \
111         json.c
112
113 notmuch_client_modules = $(notmuch_client_srcs:.c=.o)
114 notmuch: $(notmuch_client_modules) lib/libnotmuch.so
115         $(call quiet,CC,$(LDFLAGS)) -Llib -lnotmuch $(filter-out lib/libnotmuch.so,$^) $(FINAL_LDFLAGS) -o $@
116
117 notmuch.1.gz: notmuch.1
118         $(call quiet,gzip) --stdout $^ > $@
119
120 install: all notmuch.1.gz
121         for d in $(DESTDIR)$(prefix)/bin/ $(DESTDIR)$(libdir)/ \
122                 $(DESTDIR)$(prefix)/include/ $(DESTDIR)$(prefix)/share/man/man1 ; \
123         do \
124                 install -d $$d ; \
125         done ;
126         install notmuch $(DESTDIR)$(prefix)/bin/
127         install lib/$(SONAME) $(DESTDIR)$(libdir)/
128         install lib/notmuch.h $(DESTDIR)$(prefix)/include/
129         ln -sf $(SONAME) $(DESTDIR)$(libdir)/libnotmuch.so
130         install -m0644 notmuch.1.gz $(DESTDIR)$(prefix)/share/man/man1/
131 ifeq ($(MAKECMDGOALS), install)
132         @echo ""
133         @echo "Notmuch is now installed."
134         @echo ""
135         @echo "You may now want to install additional components to support using notmuch"
136         @echo "together with other software packages:"
137         @echo ""
138         @echo " make install-emacs"
139         @echo " make install-bash"
140         @echo " make install-zsh"
141         @echo ""
142 endif
143
144 install-desktop:
145         install -d $(DESTDIR)$(desktop_dir)
146         desktop-file-install --mode 0644 --dir $(DESTDIR)$(desktop_dir) notmuch.desktop
147
148 install-bash:
149         install -d $(DESTDIR)$(bash_completion_dir)
150         install -m0644 contrib/notmuch-completion.bash \
151                 $(DESTDIR)$(bash_completion_dir)/notmuch
152
153 install-zsh:
154         install -d $(DESTDIR)$(zsh_completion_dir)
155         install -m0644 contrib/notmuch-completion.zsh \
156                 $(DESTDIR)$(zsh_completion_dir)/notmuch
157
158 SRCS  := $(SRCS) $(notmuch_client_srcs)
159 CLEAN := $(CLEAN) notmuch $(notmuch_client_modules) notmuch.elc notmuch.1.gz