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 RELEASE_HOST=notmuchmail.org
16 RELEASE_DIR=/srv/notmuchmail.org/www/releases
17 VERSIONED_PACKAGE=notmuch-$(NOTMUCH_VERSION)
18 TAR_FILE=$(VERSIONED_PACKAGE).tar.gz
20 # Get settings from the output of configure by running it to generate
21 # Makefile.config if it doesn't exist yet. And add Makefile.config to
22 # our global dependency list.
23 include Makefile.config
24 global_deps += Makefile.config
25 Makefile.config: configure
27 @echo "Note: Calling ./configure with no command-line arguments. This is often fine,"
28 @echo " but if you want to specify any arguments (such as an alternate prefix"
29 @echo " into which to install), call ./configure explicitly and then make again."
30 @echo " See \"./configure --help\" for more details."
34 # Sub-directory Makefile.local fragments can append to these variables
35 # to have directory-specific cflags as necessary.
39 # Smash together user's values with our extra values
40 FINAL_CFLAGS = -DNOTMUCH_VERSION=$(NOTMUCH_VERSION) $(CFLAGS) $(WARN_CFLAGS) $(CONFIGURE_CFLAGS) $(extra_cflags)
41 FINAL_CXXFLAGS = $(CXXFLAGS) $(WARN_CXXFLAGS) $(CONFIGURE_CXXFLAGS) $(extra_cflags) $(extra_cxxflags)
42 FINAL_LDFLAGS = $(LDFLAGS) $(CONFIGURE_LDFLAGS)
45 all: notmuch notmuch-shared notmuch.1.gz
46 ifeq ($(MAKECMDGOALS),)
47 ifeq ($(shell cat .first-build-message),)
48 @NOTMUCH_FIRST_BUILD=1 $(MAKE) --no-print-directory all
50 @echo "Compilation of notmuch is now complete. You can install notmuch with:"
54 @echo "Note that depending on the prefix to which you are installing"
55 @echo "you may need root permission (such as \"sudo make install\")."
56 @echo "See \"./configure --help\" for help on setting an alternate prefix."
57 @echo Printed > .first-build-message
63 git archive --format=tar --prefix=$(VERSIONED_PACKAGE)/ HEAD | gzip > $(TAR_FILE)
64 @echo "Source is ready for release in $(TAR_FILE)"
67 release: release-verify-newer
69 .PHONY: release-verify-version
70 release-verify-version:
71 @echo -n "Checking that $(NOTMUCH_VERSION) is a two-component version..."
72 @if echo $(NOTMUCH_VERSION) | grep -q -v -x '[0-9]*\.[0-9]*'; then \
74 echo "Before releasing the notmuch version should be a two-component value." && false);\
78 .PHONY: release-verify-newer
79 release-verify-newer: release-verify-version
80 @echo -n "Checking that no $(NOTMUCH_VERSION) release already exists..."
81 @ssh $(RELEASE_HOST) test ! -e $(RELEASE_DIR)/$(TAR_FILE) \
82 || (echo "Ouch." && echo "Found: $(RELEASE_HOST):$(RELEASE_DIR)/$(TAR_FILE)" \
83 && echo "Refusing to replace an existing release." && false)
86 # The user has not set any verbosity, default to quiet mode and inform the
87 # user how to enable verbose compiles.
89 quiet_DOC := "Use \"$(MAKE) V=1\" to see the verbose compile lines.\n"
90 quiet = @printf $(quiet_DOC)$(eval quiet_DOC:=)" %12s $@\n" "$1 $2"; $($1)
91 quiet_args = @printf $(quiet_DOC)$(eval quiet_DOC:=)" %12s$2\n" $1; $($1) $2
93 # The user has explicitly enabled quiet compilation.
95 quiet = @printf " %12s $@\n" "$1 $2"; $($1)
96 quiet_args = @printf " %12s$2\n" $1; $($1) $2
98 # Otherwise, print the full command line.
100 quiet_args ?= $($1) $2
102 quiet_mkdir = $(call quiet_args,MKDIR,$1)
103 quiet_install_bin = $(call quiet_args,INSTALL-BIN,$1)
104 quiet_install_data = $(call quiet_args,INSTALL-DATA,$1)
105 quiet_symlink = $(call quiet_args,SYMLINK,$1)
107 %.o: %.cc $(global_deps)
108 $(call quiet,CXX,$(CXXFLAGS)) -c $(FINAL_CXXFLAGS) $< -o $@
110 %.o: %.c $(global_deps)
111 $(call quiet,CC,$(CFLAGS)) -c $(FINAL_CFLAGS) $< -o $@
114 $(call quiet,EMACS) --directory emacs -batch -f batch-byte-compile $<
116 .deps/%.d: %.c $(global_deps)
117 @set -e; rm -f $@; mkdir -p $$(dirname $@) ; \
118 $(CC) -M $(CPPFLAGS) $(FINAL_CFLAGS) $< > $@.$$$$ 2>/dev/null ; \
119 sed 's,'$$(basename $*)'\.o[ :]*,$*.o $@ : ,g' < $@.$$$$ > $@; \
122 .deps/%.d: %.cc $(global_deps)
123 @set -e; rm -f $@; mkdir -p $$(dirname $@) ; \
124 $(CXX) -M $(CPPFLAGS) $(FINAL_CXXFLAGS) $< > $@.$$$$ 2>/dev/null ; \
125 sed 's,'$$(basename $*)'\.o[ :]*,$*.o $@ : ,g' < $@.$$$$ > $@; \
128 DEPS := $(SRCS:%.c=.deps/%.d)
129 DEPS := $(DEPS:%.cc=.deps/%.d)
134 rm -f $(CLEAN); rm -rf .deps
136 notmuch_client_srcs = \
137 $(notmuch_compat_srcs) \
139 gmime-filter-reply.c \
148 notmuch-search-tags.c \
157 notmuch_client_modules = $(notmuch_client_srcs:.c=.o)
159 notmuch: $(notmuch_client_modules) lib/libnotmuch.a
160 $(call quiet,CC,$(LDFLAGS)) $^ $(FINAL_LDFLAGS) -o $@
162 notmuch-shared: $(notmuch_client_modules) lib/libnotmuch.so
163 $(call quiet,CC,$(LDFLAGS)) -Llib -lnotmuch $(notmuch_client_modules) $(FINAL_LDFLAGS) -o $@
165 notmuch.1.gz: notmuch.1
166 $(call quiet,gzip) --stdout $^ > $@
169 install: all notmuch.1.gz
170 $(call quiet_mkdir, $(DESTDIR)$(prefix)/bin/)
171 $(call quiet_mkdir, $(DESTDIR)$(libdir)/)
172 $(call quiet_mkdir, $(DESTDIR)$(prefix)/include/)
173 $(call quiet_mkdir, $(DESTDIR)$(prefix)/share/man/man1)
174 $(call quiet_install_bin, notmuch-shared $(DESTDIR)$(prefix)/bin/notmuch)
175 $(call quiet_install_data, notmuch.1.gz $(DESTDIR)$(prefix)/share/man/man1/)
176 ifeq ($(MAKECMDGOALS), install)
178 @echo "Notmuch is now installed."
180 @echo "You may now want to install additional components to support using notmuch"
181 @echo "together with other software packages:"
183 @echo " make install-emacs"
184 @echo " make install-bash"
185 @echo " make install-zsh"
189 .PHONY: install-desktop
191 $(call quiet,MKDIR) $(DESTDIR)$(desktop_dir)
192 desktop-file-install --mode 0644 --dir $(DESTDIR)$(desktop_dir) notmuch.desktop
196 $(call quiet-mkdir, $(DESTDIR)$(bash_completion_dir))
197 $(call quiet_install_data, contrib/notmuch-completion.bash $(DESTDIR)$(bash_completion_dir)/notmuch)
201 $(call quiet_mkdir, $(DESTDIR)$(zsh_completion_dir))
202 $(call quiet_install_data, contrib/notmuch-completion.zsh $(DESTDIR)$(zsh_completion_dir)/notmuch)
204 SRCS := $(SRCS) $(notmuch_client_srcs)
205 CLEAN := $(CLEAN) notmuch notmuch-shared $(notmuch_client_modules) notmuch.elc notmuch.1.gz