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 IS_GIT=$(shell if [ -d ${srcdir}/.git ] ; then echo yes ; else echo no; fi)
16 DATE:=$(shell git --git-dir=${srcdir}/.git log --date=short -1 --pretty=format:%cd)
18 DATE:=$(shell date +%F)
21 VERSION:=$(shell cat ${srcdir}/version)
22 ifeq ($(filter release release-message pre-release update-versions,$(MAKECMDGOALS)),)
24 VERSION:=$(shell git --git-dir=${srcdir}/.git describe --abbrev=7 --match '[0-9.]*'|sed -e s/_/~/ -e s/-/+/ -e s/-/~/)
25 # Write the file 'version.stamp' in case its contents differ from $(VERSION)
26 FILE_VERSION:=$(shell test -f version.stamp && read vs < version.stamp || vs=; echo $$vs)
27 ifneq ($(FILE_VERSION),$(VERSION))
28 $(shell echo "$(VERSION)" > version.stamp)
33 UPSTREAM_TAG=$(subst ~,_,$(VERSION))
34 DEB_TAG=debian/$(UPSTREAM_TAG)-1
36 RELEASE_HOST=notmuchmail.org
37 RELEASE_DIR=/srv/notmuchmail.org/www/releases
38 RELEASE_URL=http://notmuchmail.org/releases
39 TAR_FILE=$(PACKAGE)-$(VERSION).tar.gz
40 DEB_TAR_FILE=$(PACKAGE)_$(VERSION).orig.tar.gz
41 SHA1_FILE=$(TAR_FILE).sha1
42 GPG_FILE=$(SHA1_FILE).asc
44 PV_FILE=bindings/python/notmuch/version.py
46 # Smash together user's values with our extra values
47 FINAL_CFLAGS = -DNOTMUCH_VERSION=$(VERSION) $(CPPFLAGS) $(CFLAGS) $(WARN_CFLAGS) $(extra_cflags) $(CONFIGURE_CFLAGS)
48 FINAL_CXXFLAGS = $(CPPFLAGS) $(CXXFLAGS) $(WARN_CXXFLAGS) $(extra_cflags) $(extra_cxxflags) $(CONFIGURE_CXXFLAGS)
49 FINAL_NOTMUCH_LDFLAGS = $(LDFLAGS) -Lutil -lutil -Llib -lnotmuch
50 ifeq ($(LIBDIR_IN_LDCONFIG),0)
51 FINAL_NOTMUCH_LDFLAGS += $(RPATH_LDFLAGS)
53 FINAL_NOTMUCH_LDFLAGS += $(AS_NEEDED_LDFLAGS) $(GMIME_LDFLAGS) $(TALLOC_LDFLAGS) $(ZLIB_LDFLAGS)
54 FINAL_NOTMUCH_LINKER = CC
55 ifneq ($(LINKER_RESOLVES_LIBRARY_DEPENDENCIES),1)
56 FINAL_NOTMUCH_LDFLAGS += $(CONFIGURE_LDFLAGS)
57 FINAL_NOTMUCH_LINKER = CXX
59 FINAL_LIBNOTMUCH_LDFLAGS = $(LDFLAGS) $(AS_NEEDED_LDFLAGS) $(CONFIGURE_LDFLAGS)
62 all: notmuch notmuch-shared build-man
63 ifeq ($(MAKECMDGOALS),)
64 ifeq ($(shell cat .first-build-message 2>/dev/null),)
65 @NOTMUCH_FIRST_BUILD=1 $(MAKE) --no-print-directory all
67 @echo "Compilation of notmuch is now complete. You can install notmuch with:"
71 @echo "Note that depending on the prefix to which you are installing"
72 @echo "you may need root permission (such as \"sudo make install\")."
73 @echo "See \"./configure --help\" for help on setting an alternate prefix."
74 @echo Printed > .first-build-message
78 # Depend (also) on the file 'version'. In case of ifeq ($(IS_GIT),yes)
79 # this file may already have been updated.
80 version.stamp: $(srcdir)/version
84 if git tag -v $(UPSTREAM_TAG) >/dev/null 2>&1; then \
85 ref=$(UPSTREAM_TAG); \
88 echo "Warning: No signed tag for $(VERSION)"; \
90 git archive --format=tar --prefix=$(PACKAGE)-$(VERSION)/ $$ref > $(TAR_FILE).tmp
91 echo $(VERSION) > version.tmp
92 tar --append -f $(TAR_FILE).tmp --transform s_^_$(PACKAGE)-$(VERSION)/_ --transform 's_.tmp$$__' version.tmp
94 gzip < $(TAR_FILE).tmp > $(TAR_FILE)
95 @echo "Source is ready for release in $(TAR_FILE)"
97 $(SHA1_FILE): $(TAR_FILE)
100 $(GPG_FILE): $(SHA1_FILE)
101 @echo "Please enter your GPG password to sign the checksum."
102 gpg --armor --sign $^
107 .PHONY: update-versions
110 sed -i "s/^__VERSION__[[:blank:]]*=.*$$/__VERSION__ = \'${VERSION}\'/" $(PV_FILE)
112 # We invoke make recursively only to force ordering of our phony
113 # targets in the case of parallel invocation of make (-j).
115 # We carefully ensure that our VERSION variable is passed down to any
116 # sub-ordinate make invocations (which won't otherwise know that they
117 # are part of the release and need to take the version from the
120 release: verify-source-tree-and-version
121 $(MAKE) VERSION=$(VERSION) verify-newer
122 $(MAKE) VERSION=$(VERSION) clean
123 $(MAKE) VERSION=$(VERSION) test
124 git tag -s -m "$(PACKAGE) $(VERSION) release" $(UPSTREAM_TAG)
125 $(MAKE) VERSION=$(VERSION) $(GPG_FILE)
126 ln -sf $(TAR_FILE) $(DEB_TAR_FILE)
127 pristine-tar commit $(DEB_TAR_FILE) $(UPSTREAM_TAG)
128 git tag -s -m "$(PACKAGE) Debian $(VERSION)-1 upload (same as $(VERSION))" $(DEB_TAG)
130 mv $(TAR_FILE) $(SHA1_FILE) $(GPG_FILE) releases
131 $(MAKE) VERSION=$(VERSION) release-message > $(PACKAGE)-$(VERSION).announce
132 ifeq ($(REALLY_UPLOAD),yes)
133 git push origin $(VERSION)
134 cd releases && scp $(TAR_FILE) $(SHA1_FILE) $(GPG_FILE) $(RELEASE_HOST):$(RELEASE_DIR)
135 ssh $(RELEASE_HOST) "rm -f $(RELEASE_DIR)/LATEST-$(PACKAGE)-* ; ln -s $(TAR_FILE) $(RELEASE_DIR)/LATEST-$(TAR_FILE)"
137 @echo "Please send a release announcement using $(PACKAGE)-$(VERSION).announce as a template."
141 $(MAKE) VERSION=$(VERSION) clean
142 $(MAKE) VERSION=$(VERSION) test
143 git tag -s -m "$(PACKAGE) $(VERSION) release" $(UPSTREAM_TAG)
144 git tag -s -m "$(PACKAGE) Debian $(VERSION)-1 upload (same as $(VERSION))" $(DEB_TAG)
145 $(MAKE) VERSION=$(VERSION) $(TAR_FILE)
146 ln -sf $(TAR_FILE) $(DEB_TAR_FILE)
147 pristine-tar commit $(DEB_TAR_FILE) $(UPSTREAM_TAG)
149 mv $(TAR_FILE) $(DEB_TAR_FILE) releases
151 .PHONY: debian-snapshot
153 make VERSION=$(VERSION) clean
154 TMPFILE=$$(mktemp /tmp/notmuch.XXXXXX); \
155 cp debian/changelog $${TMPFILE}; \
156 EDITOR=/bin/true dch -b -v $(VERSION)+1 \
157 -D UNRELEASED 'test build, not for upload'; \
158 echo '3.0 (native)' > debian/source/format; \
160 mv -f $${TMPFILE} debian/changelog; \
161 echo '3.0 (quilt)' > debian/source/format
163 .PHONY: release-message
165 @echo "To: notmuch@notmuchmail.org"
166 @echo "Subject: $(PACKAGE) release $(VERSION) now available"
168 @echo "Where to obtain notmuch $(VERSION)"
169 @echo "==========================="
170 @echo " $(RELEASE_URL)/$(TAR_FILE)"
172 @echo "Which can be verified with:"
174 @echo " $(RELEASE_URL)/$(SHA1_FILE)"
176 @cat releases/$(SHA1_FILE)
178 @echo " $(RELEASE_URL)/$(GPG_FILE)"
179 @echo " (signed by `getent passwd "$$USER" | cut -d: -f 5 | cut -d, -f 1`)"
181 @echo "What's new in notmuch $(VERSION)"
182 @echo "========================="
183 @sed -ne '/^[Nn]otmuch $(VERSION)/{n;n;b NEWS}; d; :NEWS /^===/q; {p;n;b NEWS}' < NEWS | head -n -2
185 @echo "What is notmuch"
186 @echo "==============="
187 @echo "Notmuch is a system for indexing, searching, reading, and tagging"
188 @echo "large collections of email messages in maildir or mh format. It uses"
189 @echo "the Xapian library to provide fast, full-text search with a convenient"
190 @echo "search syntax."
192 @echo "For more about notmuch, see http://notmuchmail.org"
194 # This is a chain of dependencies rather than a simple list simply to
195 # avoid the messages getting interleaved in the case of a parallel
197 .PHONY: verify-source-tree-and-version
198 verify-source-tree-and-version: verify-no-dirty-code
200 .PHONY: verify-no-dirty-code
201 verify-no-dirty-code: release-checks
203 @printf "Checking that source tree is clean..."
204 ifneq ($(shell git --git-dir=${srcdir}/.git ls-files -m),)
206 @echo "The following files have been modified since the most recent git commit:"
208 @git --git-dir=${srcdir}/.git ls-files -m
210 @echo "The release will be made from the committed state, but perhaps you meant"
211 @echo "to commit this code first? Please clean this up to make it more clear."
218 .PHONY: release-checks
220 devel/release-checks.sh
224 @echo -n "Checking that no $(VERSION) release already exists..."
225 @wget -q -O /dev/null $(RELEASE_URL)/$(TAR_FILE) ; \
229 echo "Found: $(RELEASE_URL)/$(TAR_FILE)"; \
230 echo "Refusing to replace an existing release."; \
231 echo "Don't forget to update \"version\" as described in RELEASING before release." ; \
233 *) echo "An unexpected error occured"; \
236 # The user has not set any verbosity, default to quiet mode and inform the
237 # user how to enable verbose compiles.
239 quiet_DOC := "Use \"$(MAKE) V=1\" to see the verbose compile lines.\n"
240 quiet = @printf $(quiet_DOC)$(eval quiet_DOC:=)"$1 $@\n"; $($(shell echo $1 | sed -e s'/ .*//'))
242 # The user has explicitly enabled quiet compilation.
244 quiet = @printf "$1 $@\n"; $($(shell echo $1 | sed -e s'/ .*//'))
246 # Otherwise, print the full command line.
247 quiet ?= $($(shell echo $1 | sed -e s'/ .*//'))
249 %.o: %.cc $(global_deps)
250 @mkdir -p $(patsubst %/.,%,.deps/$(@D))
251 $(call quiet,CXX $(CPPFLAGS) $(CXXFLAGS)) -c $(FINAL_CXXFLAGS) $< -o $@ -MD -MP -MF .deps/$*.d
253 %.o: %.c $(global_deps)
254 @mkdir -p $(patsubst %/.,%,.deps/$(@D))
255 $(call quiet,CC $(CPPFLAGS) $(CFLAGS)) -c $(FINAL_CFLAGS) $< -o $@ -MD -MP -MF .deps/$*.d
259 rm -rf $(CLEAN); rm -rf .deps
269 notmuch_client_srcs = \
270 command-line-arguments.c\
272 gmime-filter-reply.c \
296 notmuch_client_modules = $(notmuch_client_srcs:.c=.o)
298 notmuch.o: version.stamp
300 notmuch: $(notmuch_client_modules) lib/libnotmuch.a util/libutil.a parse-time-string/libparse-time-string.a
301 $(call quiet,CXX $(CFLAGS)) $^ $(FINAL_LIBNOTMUCH_LDFLAGS) -o $@
303 notmuch-shared: $(notmuch_client_modules) lib/$(LINKER_NAME)
304 $(call quiet,$(FINAL_NOTMUCH_LINKER) $(CFLAGS)) $(notmuch_client_modules) $(FINAL_NOTMUCH_LDFLAGS) -o $@
307 install: all install-man
308 mkdir -p "$(DESTDIR)$(prefix)/bin/"
309 install notmuch-shared "$(DESTDIR)$(prefix)/bin/notmuch"
310 ifeq ($(MAKECMDGOALS), install)
312 @echo "Notmuch is now installed to $(DESTDIR)$(prefix)"
314 @echo "New users should simply run \"notmuch\" to be guided"
315 @echo "through the process of configuring notmuch and creating"
316 @echo "a database of existing email messages. The \"notmuch\""
317 @echo "command will also offer some sample search commands."
318 ifeq ($(WITH_EMACS), 1)
320 @echo "Beyond the command-line interface, notmuch also offers"
321 @echo "a full-featured interface for reading and writing mail"
322 @echo "within emacs. To use this, each user should add the"
323 @echo "following line to the ~/.emacs file:"
325 @echo " (require 'notmuch)"
327 @echo "And then run emacs as \"emacs -f notmuch\" or invoke"
328 @echo "the command \"M-x notmuch\" from within emacs."
332 .PHONY: install-desktop
334 mkdir -p "$(DESTDIR)$(desktop_dir)"
335 desktop-file-install --mode 0644 --dir "$(DESTDIR)$(desktop_dir)" notmuch.desktop
337 SRCS := $(SRCS) $(notmuch_client_srcs)
338 CLEAN := $(CLEAN) notmuch notmuch-shared $(notmuch_client_modules)
339 CLEAN := $(CLEAN) version.stamp notmuch-*.tar.gz.tmp
341 DISTCLEAN := $(DISTCLEAN) .first-build-message Makefile.config sh.config
343 DEPS := $(SRCS:%.c=.deps/%.d)
344 DEPS := $(DEPS:%.cc=.deps/%.d)
347 .SUFFIXES: # Delete the default suffixes. Old-Fashioned Suffix Rules not used.