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
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."
15 SONAME = libnotmuch.so.1
16 WARN_CXXFLAGS=-Wall -Wextra -Wwrite-strings -Wswitch-enum
17 WARN_CFLAGS=$(WARN_CXXFLAGS) -Wmissing-declarations
19 # Sub-directory Makefile.local fragments can append to these variables
20 # to have directory-specific cflags as necessary.
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)
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
35 bash_completion_dir = /etc/bash_completion.d
36 zsh_completion_dir = /usr/share/zsh/functions/Completion/Unix
38 all: notmuch notmuch.1.gz
39 ifeq ($(MAKECMDGOALS),)
41 @echo "Compilation of notmuch is now complete. You can install notmuch with:"
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."
50 # The user has not set any verbosity, default to quiet mode and inform the
51 # user how to enable verbose compiles.
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)
56 # The user has explicitly enabled quiet compilation.
58 quiet = @printf " $1 $@\n"; $($1)
60 # Otherwise, print the full command line.
63 %.o: %.cc $(global_deps)
64 $(call quiet,CXX,$(CXXFLAGS)) -c $(FINAL_CXXFLAGS) $< -o $@
66 %.o: %.c $(global_deps)
67 $(call quiet,CC,$(CFLAGS)) -c $(FINAL_CFLAGS) $< -o $@
70 $(call quiet,EMACS) -batch -f batch-byte-compile $<
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' < $@.$$$$ > $@; \
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' < $@.$$$$ > $@; \
84 DEPS := $(SRCS:%.c=.deps/%.d)
85 DEPS := $(DEPS:%.cc=.deps/%.d)
90 rm -f $(CLEAN); rm -rf .deps
92 notmuch_client_srcs = \
93 $(notmuch_compat_srcs) \
95 gmime-filter-reply.c \
104 notmuch-search-tags.c \
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 $@
117 notmuch.1.gz: notmuch.1
118 $(call quiet,gzip) --stdout $^ > $@
120 install: all notmuch.1.gz
121 for d in $(DESTDIR)$(prefix)/bin/ $(DESTDIR)$(libdir)/ \
122 $(DESTDIR)$(prefix)/include/ $(DESTDIR)$(prefix)/share/man/man1 ; \
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)
133 @echo "Notmuch is now installed."
135 @echo "You may now want to install additional components to support using notmuch"
136 @echo "together with other software packages:"
138 @echo " make install-emacs"
139 @echo " make install-bash"
140 @echo " make install-zsh"
145 install -d $(DESTDIR)$(desktop_dir)
146 desktop-file-install --mode 0644 --dir $(DESTDIR)$(desktop_dir) notmuch.desktop
149 install -d $(DESTDIR)$(bash_completion_dir)
150 install -m0644 contrib/notmuch-completion.bash \
151 $(DESTDIR)$(bash_completion_dir)/notmuch
154 install -d $(DESTDIR)$(zsh_completion_dir)
155 install -m0644 contrib/notmuch-completion.zsh \
156 $(DESTDIR)$(zsh_completion_dir)/notmuch
158 SRCS := $(SRCS) $(notmuch_client_srcs)
159 CLEAN := $(CLEAN) notmuch $(notmuch_client_modules) notmuch.elc notmuch.1.gz