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 let git append identification of the actual commit.
13 VERSION:=$(shell cat version)
14 ifneq ($(MAKECMDGOALS),release)
15 ifneq ($(MAKECMDGOALS),release-message)
16 VERSION:=$(shell if git describe > /dev/null 2>&1; then git describe --match '[0-9.]*'; else cat version; fi)
20 RELEASE_HOST=notmuchmail.org
21 RELEASE_DIR=/srv/notmuchmail.org/www/releases
22 RELEASE_URL=http://notmuchmail.org/releases
23 TAR_FILE=$(PACKAGE)-$(VERSION).tar.gz
24 SHA1_FILE=$(TAR_FILE).sha1
25 GPG_FILE=$(SHA1_FILE).asc
27 # Smash together user's values with our extra values
28 FINAL_CFLAGS = -DNOTMUCH_VERSION=$(VERSION) $(CFLAGS) $(WARN_CFLAGS) $(CONFIGURE_CFLAGS) $(extra_cflags)
29 FINAL_CXXFLAGS = $(CXXFLAGS) $(WARN_CXXFLAGS) $(CONFIGURE_CXXFLAGS) $(extra_cflags) $(extra_cxxflags)
30 FINAL_NOTMUCH_LDFLAGS = $(LDFLAGS) -Llib -lnotmuch
31 ifneq ($(LINKER_RESOLVES_LIBRARY_DEPENDENCIES),1)
32 FINAL_NOTMUCH_LDFLAGS += $(CONFIGURE_LDFLAGS)
34 FINAL_LIBNOTMUCH_LDFLAGS = $(LDFLAGS) $(CONFIGURE_LDFLAGS)
37 all: notmuch notmuch-shared notmuch.1.gz
38 ifeq ($(MAKECMDGOALS),)
39 ifeq ($(shell cat .first-build-message),)
40 @NOTMUCH_FIRST_BUILD=1 $(MAKE) --no-print-directory all
42 @echo "Compilation of notmuch is now complete. You can install notmuch with:"
46 @echo "Note that depending on the prefix to which you are installing"
47 @echo "you may need root permission (such as \"sudo make install\")."
48 @echo "See \"./configure --help\" for help on setting an alternate prefix."
49 @echo Printed > .first-build-message
58 git archive --format=tar --prefix=$(PACKAGE)-$(VERSION)/ HEAD > $(TAR_FILE).tmp
59 echo $(VERSION) > version.tmp
60 tar --append -f $(TAR_FILE).tmp --transform s_^_$(PACKAGE)-$(VERSION)/_ --transform 's_.tmp$$__' version.tmp
62 gzip < $(TAR_FILE).tmp > $(TAR_FILE)
63 @echo "Source is ready for release in $(TAR_FILE)"
65 $(SHA1_FILE): $(TAR_FILE)
68 $(GPG_FILE): $(SHA1_FILE)
69 @echo "Please enter your GPG password to sign the checksum."
75 # We invoke make recursively only to force ordering of our phony
76 # targets in the case of parallel invocation of make (-j).
78 # We carefully ensure that our VERSION variable is passed down to any
79 # sub-ordinate make invocations (which won't otherwhise know that they
80 # are part of the release and need to take the version from the
83 release: verify-no-dirty-code
84 $(MAKE) VERSION=$(VERSION) verify-newer
85 $(MAKE) VERSION=$(VERSION) test
86 $(MAKE) VERSION=$(VERSION) $(GPG_FILE)
87 scp $(TAR_FILE) $(SHA1_FILE) $(GPG_FILE) $(RELEASE_HOST):$(RELEASE_DIR)
88 ssh $(RELEASE_HOST) "rm -f $(RELEASE_DIR)/LATEST-$(PACKAGE)-[0-9]* && ln -s $(TAR_FILE) $(RELEASE_DIR)/LATEST-$(PACKAGE)-$(VERSION)"
90 mv $(TAR_FILE) $(SHA1_FILE) $(GPG_FILE) releases
91 git tag -s -m "$(PACKAGE) $(VERSION) release" $(VERSION)
92 git push origin $(VERSION)
93 $(MAKE) VERSION=$(VERSION) release-message > $(PACKAGE)-$(VERSION).announce
94 @echo "Please send a release announcement using $(PACKAGE)-$(VERSION).announce as a template."
96 .PHONY: release-message
98 @echo "To: notmuch@notmuchmail.org"
99 @echo "Subject: $(PACKAGE) release $(VERSION) now available"
101 @echo "Where to obtain notmuch $(VERSION)"
102 @echo "==========================="
103 @echo " $(RELEASE_URL)/$(TAR_FILE)"
105 @echo "Which can be verified with:"
107 @echo " $(RELEASE_URL)/$(SHA1_FILE)"
109 @cat releases/$(SHA1_FILE)
111 @echo " $(RELEASE_URL)/$(GPG_FILE)"
112 @echo " (signed by `getent passwd "$$USER" | cut -d: -f 5 | cut -d, -f 1`)"
114 @echo "What's new in notmuch $(VERSION)"
115 @echo "========================="
116 @sed -ne '/^[Nn]otmuch $(VERSION)/{n;n;b NEWS}; d; :NEWS /^===/q; {p;n;b NEWS}' < NEWS | head -n -2
118 @echo "What is notmuch"
119 @echo "==============="
120 @echo "Notmuch is a system for indexing, searching, reading, and tagging"
121 @echo "large collections of email messages in maildir or mh format. It uses"
122 @echo "the Xapian library to provide fast, full-text search with a convenient"
123 @echo "search syntax."
125 @echo "For more about notmuch, see http://notmuchmail.org"
127 .PHONY: verify-no-dirty-code
128 verify-no-dirty-code: verify-version
129 @printf "Checking that source tree is clean..."
130 ifneq ($(shell git ls-files -m),)
132 @echo "The following files have been modified since the most recent git commit:"
136 @echo "The release will be made from the committed state, but perhaps you meant"
137 @echo "to commit this code first? Please clean this up to make it more clear."
143 .PHONY: verify-version
145 @echo -n "Checking that $(VERSION) consists only of digits and periods..."
146 @if echo $(VERSION) | grep -q -v -x '[0-9.]*'; then \
148 echo "Please follow the instructions in RELEASING to choose a version" && false) \
154 @echo -n "Checking that no $(VERSION) release already exists..."
155 @ssh $(RELEASE_HOST) test ! -e $(RELEASE_DIR)/$(TAR_FILE) \
156 || (echo "Ouch." && echo "Found: $(RELEASE_HOST):$(RELEASE_DIR)/$(TAR_FILE)" \
157 && echo "Refusing to replace an existing release." \
158 && echo "Don't forget to update \"version\" as described in RELEASING before release." && false)
161 # The user has not set any verbosity, default to quiet mode and inform the
162 # user how to enable verbose compiles.
164 quiet_DOC := "Use \"$(MAKE) V=1\" to see the verbose compile lines.\n"
165 quiet = @printf $(quiet_DOC)$(eval quiet_DOC:=)"$1 $@\n"; $($(shell echo $1 | sed -e s'/ .*//'))
167 # The user has explicitly enabled quiet compilation.
169 quiet = @printf "$1 $@\n"; $($(shell echo $1 | sed -e s'/ .*//'))
171 # Otherwise, print the full command line.
172 quiet ?= $($(shell echo $1 | sed -e s'/ .*//'))
174 %.o: %.cc $(global_deps)
175 $(call quiet,CXX $(CXXFLAGS)) -c $(FINAL_CXXFLAGS) $< -o $@
177 %.o: %.c $(global_deps)
178 $(call quiet,CC $(CFLAGS)) -c $(FINAL_CFLAGS) $< -o $@
180 .deps/%.d: %.c $(global_deps)
181 @set -e; rm -f $@; mkdir -p $$(dirname $@) ; \
182 $(CC) -M $(CPPFLAGS) $(FINAL_CFLAGS) $< > $@.$$$$ 2>/dev/null ; \
183 sed 's,'$$(basename $*)'\.o[ :]*,$*.o $@ : ,g' < $@.$$$$ > $@; \
186 .deps/%.d: %.cc $(global_deps)
187 @set -e; rm -f $@; mkdir -p $$(dirname $@) ; \
188 $(CXX) -M $(CPPFLAGS) $(FINAL_CXXFLAGS) $< > $@.$$$$ 2>/dev/null ; \
189 sed 's,'$$(basename $*)'\.o[ :]*,$*.o $@ : ,g' < $@.$$$$ > $@; \
192 DEPS := $(SRCS:%.c=.deps/%.d)
193 DEPS := $(DEPS:%.cc=.deps/%.d)
198 rm -f $(CLEAN); rm -rf .deps
200 # We don't (yet) have any distributed files not in the upstream repository.
201 # So distclean is currently identical to clean.
205 notmuch_client_srcs = \
207 gmime-filter-reply.c \
208 gmime-filter-headers.c \
217 notmuch-search-tags.c \
226 notmuch_client_modules = $(notmuch_client_srcs:.c=.o)
228 notmuch: $(notmuch_client_modules) lib/libnotmuch.a
229 $(call quiet,CXX $(CFLAGS)) $^ $(FINAL_LIBNOTMUCH_LDFLAGS) -o $@
231 notmuch-shared: $(notmuch_client_modules) lib/$(LINKER_NAME)
232 $(call quiet,CXX $(CFLAGS)) $(notmuch_client_modules) $(FINAL_NOTMUCH_LDFLAGS) -o $@
234 notmuch.1.gz: notmuch.1
235 gzip --stdout $^ > $@
238 install: all notmuch.1.gz
239 mkdir -p $(DESTDIR)$(mandir)/man1
240 install -m0644 notmuch.1.gz $(DESTDIR)$(mandir)/man1/
241 mkdir -p $(DESTDIR)$(prefix)/bin/
242 install notmuch-shared $(DESTDIR)$(prefix)/bin/notmuch
243 ifeq ($(MAKECMDGOALS), install)
245 @echo "Notmuch is now installed to $(DESTDIR)$(prefix)"
247 @echo "To run notmuch from emacs, each user should add the following line to ~/.emacs:"
249 @echo " (require 'notmuch)"
251 @echo "And should then run \"M-x notmuch\" from within emacs or run \"emacs -f notmuch\""
254 .PHONY: install-desktop
256 mkdir -p $(DESTDIR)$(desktop_dir)
257 desktop-file-install --mode 0644 --dir $(DESTDIR)$(desktop_dir) notmuch.desktop
259 SRCS := $(SRCS) $(notmuch_client_srcs)
260 CLEAN := $(CLEAN) notmuch notmuch-shared $(notmuch_client_modules) notmuch.elc notmuch.1.gz