3 # Here's the (hopefully simple) versioning scheme.
5 # Releases of notmuch have a two-digit version (0.1, 0.2, etc.). We
6 # increment the second digit for each release and increment the first
7 # digit when we reach particularly major milestones of usability.
9 # Between releases, (such as when compiling notmuch from the git
10 # repository), we add a third digit, (0.1.1, 0.1.2, etc.), and
11 # increment it occasionally, (such as after a big batch of commits are
15 # Get settings from the output of configure by running it to generate
16 # Makefile.config if it doesn't exist yet. And add Makefile.config to
17 # our global dependency list.
18 include Makefile.config
19 global_deps += Makefile.config
20 Makefile.config: configure
22 @echo "Note: Calling ./configure with no command-line arguments. This is often fine,"
23 @echo " but if you want to specify any arguments (such as an alternate prefix"
24 @echo " into which to install), call ./configure explicitly and then make again."
25 @echo " See \"./configure --help\" for more details."
29 # Sub-directory Makefile.local fragments can append to these variables
30 # to have directory-specific cflags as necessary.
34 # Smash together user's values with our extra values
35 FINAL_CFLAGS = -DNOTMUCH_VERSION=$(NOTMUCH_VERSION) $(CFLAGS) $(WARN_CFLAGS) $(CONFIGURE_CFLAGS) $(extra_cflags)
36 FINAL_CXXFLAGS = $(CXXFLAGS) $(WARN_CXXFLAGS) $(CONFIGURE_CXXFLAGS) $(extra_cflags) $(extra_cxxflags)
37 FINAL_LDFLAGS = $(LDFLAGS) $(CONFIGURE_LDFLAGS)
40 all: notmuch notmuch-shared notmuch.1.gz
41 ifeq ($(MAKECMDGOALS),)
42 ifeq ($(shell cat .first-build-message),)
43 @NOTMUCH_FIRST_BUILD=1 $(MAKE) --no-print-directory all
45 @echo "Compilation of notmuch is now complete. You can install notmuch with:"
49 @echo "Note that depending on the prefix to which you are installing"
50 @echo "you may need root permission (such as \"sudo make install\")."
51 @echo "See \"./configure --help\" for help on setting an alternate prefix."
52 @echo Printed > .first-build-message
58 git archive --format=tar --prefix=notmuch-$(NOTMUCH_VERSION)/ HEAD | gzip > notmuch-$(NOTMUCH_VERSION).tar.gz
59 @echo "Source is ready for release in notmuch-$(NOTMUCH_VERSION).tar.gz"
61 # The user has not set any verbosity, default to quiet mode and inform the
62 # user how to enable verbose compiles.
64 quiet_DOC := "Use \"$(MAKE) V=1\" to see the verbose compile lines.\n"
65 quiet = @printf $(quiet_DOC)$(eval quiet_DOC:=)" %12s $@\n" "$1 $2"; $($1)
66 quiet_args = @printf $(quiet_DOC)$(eval quiet_DOC:=)" %12s$2\n" $1; $($1) $2
68 # The user has explicitly enabled quiet compilation.
70 quiet = @printf " %12s $@\n" "$1 $2"; $($1)
71 quiet_args = @printf " %12s$2\n" $1; $($1) $2
73 # Otherwise, print the full command line.
75 quiet_args ?= $($1) $2
77 quiet_mkdir = $(call quiet_args,MKDIR,$1)
78 quiet_install_bin = $(call quiet_args,INSTALL-BIN,$1)
79 quiet_install_data = $(call quiet_args,INSTALL-DATA,$1)
80 quiet_symlink = $(call quiet_args,SYMLINK,$1)
82 %.o: %.cc $(global_deps)
83 $(call quiet,CXX,$(CXXFLAGS)) -c $(FINAL_CXXFLAGS) $< -o $@
85 %.o: %.c $(global_deps)
86 $(call quiet,CC,$(CFLAGS)) -c $(FINAL_CFLAGS) $< -o $@
89 $(call quiet,EMACS) --directory emacs -batch -f batch-byte-compile $<
91 .deps/%.d: %.c $(global_deps)
92 @set -e; rm -f $@; mkdir -p $$(dirname $@) ; \
93 $(CC) -M $(CPPFLAGS) $(FINAL_CFLAGS) $< > $@.$$$$ 2>/dev/null ; \
94 sed 's,'$$(basename $*)'\.o[ :]*,$*.o $@ : ,g' < $@.$$$$ > $@; \
97 .deps/%.d: %.cc $(global_deps)
98 @set -e; rm -f $@; mkdir -p $$(dirname $@) ; \
99 $(CXX) -M $(CPPFLAGS) $(FINAL_CXXFLAGS) $< > $@.$$$$ 2>/dev/null ; \
100 sed 's,'$$(basename $*)'\.o[ :]*,$*.o $@ : ,g' < $@.$$$$ > $@; \
103 DEPS := $(SRCS:%.c=.deps/%.d)
104 DEPS := $(DEPS:%.cc=.deps/%.d)
109 rm -f $(CLEAN); rm -rf .deps
111 notmuch_client_srcs = \
112 $(notmuch_compat_srcs) \
114 gmime-filter-reply.c \
123 notmuch-search-tags.c \
132 notmuch_client_modules = $(notmuch_client_srcs:.c=.o)
134 notmuch: $(notmuch_client_modules) lib/libnotmuch.a
135 $(call quiet,CC,$(LDFLAGS)) $^ $(FINAL_LDFLAGS) -o $@
137 notmuch-shared: $(notmuch_client_modules) lib/libnotmuch.so
138 $(call quiet,CC,$(LDFLAGS)) -Llib -lnotmuch $(notmuch_client_modules) $(FINAL_LDFLAGS) -o $@
140 notmuch.1.gz: notmuch.1
141 $(call quiet,gzip) --stdout $^ > $@
144 install: all notmuch.1.gz
145 $(call quiet_mkdir, $(DESTDIR)$(prefix)/bin/)
146 $(call quiet_mkdir, $(DESTDIR)$(libdir)/)
147 $(call quiet_mkdir, $(DESTDIR)$(prefix)/include/)
148 $(call quiet_mkdir, $(DESTDIR)$(prefix)/share/man/man1)
149 $(call quiet_install_bin, notmuch-shared $(DESTDIR)$(prefix)/bin/notmuch)
150 $(call quiet_install_data, notmuch.1.gz $(DESTDIR)$(prefix)/share/man/man1/)
151 ifeq ($(MAKECMDGOALS), install)
153 @echo "Notmuch is now installed."
155 @echo "You may now want to install additional components to support using notmuch"
156 @echo "together with other software packages:"
158 @echo " make install-emacs"
159 @echo " make install-bash"
160 @echo " make install-zsh"
164 .PHONY: install-desktop
166 $(call quiet,MKDIR) $(DESTDIR)$(desktop_dir)
167 desktop-file-install --mode 0644 --dir $(DESTDIR)$(desktop_dir) notmuch.desktop
171 $(call quiet-mkdir, $(DESTDIR)$(bash_completion_dir))
172 $(call quiet_install_data, contrib/notmuch-completion.bash $(DESTDIR)$(bash_completion_dir)/notmuch)
176 $(call quiet_mkdir, $(DESTDIR)$(zsh_completion_dir))
177 $(call quiet_install_data, contrib/notmuch-completion.zsh $(DESTDIR)$(zsh_completion_dir)/notmuch)
179 SRCS := $(SRCS) $(notmuch_client_srcs)
180 CLEAN := $(CLEAN) notmuch notmuch-shared $(notmuch_client_modules) notmuch.elc notmuch.1.gz