]> git.notmuchmail.org Git - notmuch/blob - Makefile.local
NEWS: set date for release
[notmuch] / Makefile.local
1 # -*- makefile -*-
2
3 # Here's the (hopefully simple) versioning scheme.
4 #
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.
8 #
9 # Between releases, (such as when compiling notmuch from the git
10 # repository), we let git append identification of the actual commit.
11 PACKAGE=notmuch
12
13 IS_GIT:=$(if $(wildcard ${srcdir}/.git),yes,no)
14
15 ifeq ($(IS_GIT),yes)
16 DATE:=$(shell git --git-dir=${srcdir}/.git log --date=short -1 --pretty=format:%cd)
17 else
18 DATE:=$(shell date +%F)
19 endif
20
21 VERSION:=$(shell cat ${srcdir}/version)
22 ELPA_VERSION:=$(subst ~,_,$(VERSION))
23 ifeq ($(filter release release-message pre-release update-versions,$(MAKECMDGOALS)),)
24 ifeq ($(IS_GIT),yes)
25 VERSION:=$(shell git --git-dir=${srcdir}/.git describe --abbrev=7 --match '[0-9.]*'|sed -e s/_/~/ -e s/-/+/ -e s/-/~/)
26 # drop the ~g$sha1 part
27 ELPA_VERSION:=$(word 1,$(subst ~, ,$(VERSION)))
28 # Write the file 'version.stamp' in case its contents differ from $(VERSION)
29 FILE_VERSION:=$(shell test -f version.stamp && read vs < version.stamp || vs=; echo $$vs)
30 ifneq ($(FILE_VERSION),$(VERSION))
31        $(shell echo "$(VERSION)" > version.stamp)
32 endif
33 endif
34 endif
35
36 UPSTREAM_TAG=$(subst ~,_,$(VERSION))
37 DEB_TAG=debian/$(UPSTREAM_TAG)-1
38
39 RELEASE_HOST=notmuchmail.org
40 RELEASE_DIR=/srv/notmuchmail.org/www/releases
41 RELEASE_URL=https://notmuchmail.org/releases
42 TAR_FILE=$(PACKAGE)-$(VERSION).tar.gz
43 DEB_TAR_FILE=$(PACKAGE)_$(VERSION).orig.tar.gz
44 SHA1_FILE=$(TAR_FILE).sha1
45 GPG_FILE=$(SHA1_FILE).asc
46
47 PV_FILE=bindings/python/notmuch/version.py
48
49 # Smash together user's values with our extra values
50 STD_CFLAGS := -std=gnu99
51 FINAL_CFLAGS = -DNOTMUCH_VERSION=$(VERSION) $(CPPFLAGS) $(STD_CFLAGS) $(CFLAGS) $(WARN_CFLAGS) $(extra_cflags) $(CONFIGURE_CFLAGS)
52 FINAL_CXXFLAGS = $(CPPFLAGS) $(CXXFLAGS) $(WARN_CXXFLAGS) $(extra_cflags) $(extra_cxxflags) $(CONFIGURE_CXXFLAGS)
53 FINAL_NOTMUCH_LDFLAGS = $(LDFLAGS) -Lutil -lutil -Llib -lnotmuch
54 ifeq ($(LIBDIR_IN_LDCONFIG),0)
55 FINAL_NOTMUCH_LDFLAGS += $(RPATH_LDFLAGS)
56 endif
57 FINAL_NOTMUCH_LDFLAGS += $(AS_NEEDED_LDFLAGS) $(GMIME_LDFLAGS) $(TALLOC_LDFLAGS) $(ZLIB_LDFLAGS)
58 FINAL_NOTMUCH_LINKER = CC
59 ifneq ($(LINKER_RESOLVES_LIBRARY_DEPENDENCIES),1)
60 FINAL_NOTMUCH_LDFLAGS += $(CONFIGURE_LDFLAGS)
61 FINAL_NOTMUCH_LINKER = CXX
62 endif
63 FINAL_LIBNOTMUCH_LDFLAGS = $(LDFLAGS) $(AS_NEEDED_LDFLAGS) $(CONFIGURE_LDFLAGS)
64
65 .PHONY: all
66 all: notmuch notmuch-shared build-man ruby-bindings
67 ifeq ($(MAKECMDGOALS),)
68 ifeq ($(shell cat .first-build-message 2>/dev/null),)
69         @NOTMUCH_FIRST_BUILD=1 $(MAKE) --no-print-directory all
70         @echo ""
71         @echo "Compilation of notmuch is now complete. You can install notmuch with:"
72         @echo ""
73         @echo " make install"
74         @echo ""
75         @echo "Note that depending on the prefix to which you are installing"
76         @echo "you may need root permission (such as \"sudo make install\")."
77         @echo "See \"./configure --help\" for help on setting an alternate prefix."
78         @echo Printed > .first-build-message
79 endif
80 endif
81
82 # Depend (also) on the file 'version'. In case of ifeq ($(IS_GIT),yes)
83 # this file may already have been updated.
84 version.stamp: $(srcdir)/version
85         echo $(VERSION) > $@
86
87 $(TAR_FILE):
88         if git tag -v $(UPSTREAM_TAG) >/dev/null 2>&1; then \
89            ref=$(UPSTREAM_TAG); \
90         else \
91            ref="HEAD" ; \
92            echo "Warning: No signed tag for $(VERSION)"; \
93         fi ; \
94         git archive --format=tar --prefix=$(PACKAGE)-$(VERSION)/ $$ref > $(TAR_FILE).tmp
95         echo $(VERSION) > version.tmp
96         tar --append -f $(TAR_FILE).tmp --transform s_^_$(PACKAGE)-$(VERSION)/_  --transform 's_.tmp$$__' version.tmp
97         rm version.tmp
98         gzip < $(TAR_FILE).tmp > $(TAR_FILE)
99         @echo "Source is ready for release in $(TAR_FILE)"
100
101 $(SHA1_FILE): $(TAR_FILE)
102         sha1sum $^ > $@
103
104 $(GPG_FILE): $(SHA1_FILE)
105         @echo "Please enter your GPG password to sign the checksum."
106         gpg --armor --sign $^ 
107
108 .PHONY: dist
109 dist: $(TAR_FILE)
110
111 .PHONY: update-versions
112
113 update-versions:
114         sed -i -e "s/^__VERSION__[[:blank:]]*=.*$$/__VERSION__ = \'${VERSION}\'/" \
115             -e "s/^SOVERSION[[:blank:]]*=.*$$/SOVERSION = \'${LIBNOTMUCH_VERSION_MAJOR}\'/" \
116             ${PV_FILE}
117
118 # We invoke make recursively only to force ordering of our phony
119 # targets in the case of parallel invocation of make (-j).
120 #
121 # We carefully ensure that our VERSION variable is passed down to any
122 # sub-ordinate make invocations (which won't otherwise know that they
123 # are part of the release and need to take the version from the
124 # version file).
125 .PHONY: release
126 release: verify-source-tree-and-version
127         $(MAKE) VERSION=$(VERSION) verify-newer
128         $(MAKE) VERSION=$(VERSION) clean
129         $(MAKE) VERSION=$(VERSION) test
130         git tag -s -m "$(PACKAGE) $(VERSION) release" $(UPSTREAM_TAG)
131         $(MAKE) VERSION=$(VERSION) $(GPG_FILE)
132         ln -sf $(TAR_FILE) $(DEB_TAR_FILE)
133         pristine-tar commit $(DEB_TAR_FILE) $(UPSTREAM_TAG)
134         git tag -s -m "$(PACKAGE) Debian $(VERSION)-1 upload (same as $(VERSION))" $(DEB_TAG)
135         mkdir -p releases
136         mv $(TAR_FILE) $(SHA1_FILE) $(GPG_FILE) releases
137         $(MAKE) VERSION=$(VERSION) release-message > $(PACKAGE)-$(VERSION).announce
138 ifeq ($(REALLY_UPLOAD),yes)
139         git push origin $(VERSION)
140         cd releases && scp $(TAR_FILE) $(SHA1_FILE) $(GPG_FILE) $(RELEASE_HOST):$(RELEASE_DIR)
141         ssh $(RELEASE_HOST) "rm -f $(RELEASE_DIR)/LATEST-$(PACKAGE)-* ; ln -s $(TAR_FILE) $(RELEASE_DIR)/LATEST-$(TAR_FILE)"
142 endif
143         @echo "Please send a release announcement using $(PACKAGE)-$(VERSION).announce as a template."
144
145 .PHONY: pre-release
146 pre-release:
147         $(MAKE) VERSION=$(VERSION) clean
148         $(MAKE) VERSION=$(VERSION) test
149         git tag -s -m "$(PACKAGE) $(VERSION) release" $(UPSTREAM_TAG)
150         git tag -s -m "$(PACKAGE) Debian $(VERSION)-1 upload (same as $(VERSION))" $(DEB_TAG)
151         $(MAKE) VERSION=$(VERSION) $(TAR_FILE)
152         ln -sf $(TAR_FILE) $(DEB_TAR_FILE)
153         pristine-tar commit $(DEB_TAR_FILE) $(UPSTREAM_TAG)
154         mkdir -p releases
155         mv $(TAR_FILE) $(DEB_TAR_FILE) releases
156
157 .PHONY: debian-snapshot
158 debian-snapshot:
159         make VERSION=$(VERSION) clean
160         TMPFILE=$$(mktemp /tmp/notmuch.XXXXXX);         \
161           cp debian/changelog $${TMPFILE};              \
162           EDITOR=/bin/true dch -b -v $(VERSION)+1       \
163             -D UNRELEASED 'test build, not for upload'; \
164           echo '3.0 (native)' > debian/source/format;   \
165           debuild -us -uc;                              \
166           mv -f $${TMPFILE} debian/changelog;           \
167           echo '3.0 (quilt)' > debian/source/format
168
169 .PHONY: release-message
170 release-message:
171         @echo "To: notmuch@notmuchmail.org"
172         @echo "Subject: $(PACKAGE) release $(VERSION) now available"
173         @echo ""
174         @echo "Where to obtain notmuch $(VERSION)"
175         @echo "==========================="
176         @echo "  $(RELEASE_URL)/$(TAR_FILE)"
177         @echo ""
178         @echo "Which can be verified with:"
179         @echo ""
180         @echo "  $(RELEASE_URL)/$(SHA1_FILE)"
181         @echo -n "  "
182         @cat releases/$(SHA1_FILE)
183         @echo ""
184         @echo "  $(RELEASE_URL)/$(GPG_FILE)"
185         @echo "  (signed by `getent passwd "$$USER" | cut -d: -f 5 | cut -d, -f 1`)"
186         @echo ""
187         @echo "What's new in notmuch $(VERSION)"
188         @echo "========================="
189         @sed -ne '/^[Nn]otmuch $(VERSION)/{n;n;b NEWS}; d; :NEWS /^===/q; {p;n;b NEWS}' < NEWS | head -n -2
190         @echo ""
191         @echo "What is notmuch"
192         @echo "==============="
193         @echo "Notmuch is a system for indexing, searching, reading, and tagging"
194         @echo "large collections of email messages in maildir or mh format. It uses"
195         @echo "the Xapian library to provide fast, full-text search with a convenient"
196         @echo "search syntax."
197         @echo ""
198         @echo "For more about notmuch, see https://notmuchmail.org"
199
200 # This is a chain of dependencies rather than a simple list simply to
201 # avoid the messages getting interleaved in the case of a parallel
202 # make invocation.
203 .PHONY: verify-source-tree-and-version
204 verify-source-tree-and-version: verify-no-dirty-code
205
206 .PHONY: verify-no-dirty-code
207 verify-no-dirty-code: release-checks
208 ifeq ($(IS_GIT),yes)
209         @printf "Checking that source tree is clean..."
210 ifneq ($(shell git --git-dir=${srcdir}/.git ls-files -m),)
211         @echo "No"
212         @echo "The following files have been modified since the most recent git commit:"
213         @echo ""
214         @git --git-dir=${srcdir}/.git ls-files -m
215         @echo ""
216         @echo "The release will be made from the committed state, but perhaps you meant"
217         @echo "to commit this code first? Please clean this up to make it more clear."
218         @false
219 else
220         @echo "Good"
221 endif
222 endif
223
224 .PHONY: release-checks
225 release-checks:
226         devel/release-checks.sh
227
228 .PHONY: verify-newer
229 verify-newer:
230         @echo -n "Checking that no $(VERSION) release already exists..."
231         @wget -q --no-check-certificate -O /dev/null $(RELEASE_URL)/$(TAR_FILE) ; \
232         case $$? in \
233           8) echo "Good." ;; \
234           0) echo "Ouch."; \
235              echo "Found: $(RELEASE_URL)/$(TAR_FILE)"; \
236              echo "Refusing to replace an existing release."; \
237              echo "Don't forget to update \"version\" as described in RELEASING before release." ; \
238              false ;; \
239           *) echo "An unexpected error occured"; \
240              false;; esac
241
242 # The user has not set any verbosity, default to quiet mode and inform the
243 # user how to enable verbose compiles.
244 ifeq ($(V),)
245 quiet_DOC := "Use \"$(MAKE) V=1\" to see the verbose compile lines.\n"
246 quiet = @printf $(quiet_DOC)$(eval quiet_DOC:=)"$1 $@\n"; $($(shell echo $1 | sed -e s'/ .*//'))
247 endif
248 # The user has explicitly enabled quiet compilation.
249 ifeq ($(V),0)
250 quiet = @printf "$1 $@\n"; $($(shell echo $1 | sed -e s'/ .*//'))
251 endif
252 # Otherwise, print the full command line.
253 quiet ?= $($(shell echo $1 | sed -e s'/ .*//'))
254
255 %.o: %.cc $(global_deps)
256         @mkdir -p $(patsubst %/.,%,.deps/$(@D))
257         $(call quiet,CXX $(CPPFLAGS) $(CXXFLAGS)) -c $(FINAL_CXXFLAGS) $< -o $@ -MD -MP -MF .deps/$*.d
258
259 %.o: %.c $(global_deps)
260         @mkdir -p $(patsubst %/.,%,.deps/$(@D))
261         $(call quiet,CC $(CPPFLAGS) $(CFLAGS)) -c $(FINAL_CFLAGS) $< -o $@ -MD -MP -MF .deps/$*.d
262
263 .PHONY : clean
264 clean:
265         rm -rf $(CLEAN); rm -rf .deps
266
267 .PHONY: distclean
268 distclean: clean
269         rm -rf $(DISTCLEAN)
270
271 .PHONY: dataclean
272 dataclean: distclean
273         rm -rf $(DATACLEAN)
274
275 notmuch_client_srcs =           \
276         command-line-arguments.c\
277         debugger.c              \
278         status.c                \
279         gmime-filter-reply.c    \
280         hooks.c                 \
281         notmuch.c               \
282         notmuch-compact.c       \
283         notmuch-config.c        \
284         notmuch-count.c         \
285         notmuch-dump.c          \
286         notmuch-insert.c        \
287         notmuch-new.c           \
288         notmuch-reply.c         \
289         notmuch-restore.c       \
290         notmuch-search.c        \
291         notmuch-setup.c         \
292         notmuch-show.c          \
293         notmuch-tag.c           \
294         notmuch-time.c          \
295         sprinter-json.c         \
296         sprinter-sexp.c         \
297         sprinter-text.c         \
298         query-string.c          \
299         mime-node.c             \
300         crypto.c                \
301         tag-util.c
302
303 notmuch_client_modules = $(notmuch_client_srcs:.c=.o)
304
305 notmuch.o: version.stamp
306
307 notmuch: $(notmuch_client_modules) lib/libnotmuch.a util/libutil.a parse-time-string/libparse-time-string.a
308         $(call quiet,CXX $(CFLAGS)) $^ $(FINAL_LIBNOTMUCH_LDFLAGS) -o $@
309
310 notmuch-shared: $(notmuch_client_modules) lib/$(LINKER_NAME)
311         $(call quiet,$(FINAL_NOTMUCH_LINKER) $(CFLAGS)) $(notmuch_client_modules) $(FINAL_NOTMUCH_LDFLAGS) -o $@
312
313 .PHONY: install
314 install: all install-man
315         mkdir -p "$(DESTDIR)$(prefix)/bin/"
316         install notmuch-shared "$(DESTDIR)$(prefix)/bin/notmuch"
317 ifeq ($(MAKECMDGOALS), install)
318         @echo ""
319         @echo "Notmuch is now installed to $(DESTDIR)$(prefix)"
320         @echo ""
321         @echo "New users should simply run \"notmuch\" to be guided"
322         @echo "through the process of configuring notmuch and creating"
323         @echo "a database of existing email messages. The \"notmuch\""
324         @echo "command will also offer some sample search commands."
325 ifeq ($(WITH_EMACS), 1)
326         @echo ""
327         @echo "Beyond the command-line interface, notmuch also offers"
328         @echo "a full-featured interface for reading and writing mail"
329         @echo "within emacs. To use this, each user should add the"
330         @echo "following line to the ~/.emacs file:"
331         @echo ""
332         @echo " (require 'notmuch)"
333         @echo ""
334         @echo "And then run emacs as \"emacs -f notmuch\" or invoke"
335         @echo "the command \"M-x notmuch\" from within emacs."
336 endif
337 endif
338
339 .PHONY: install-desktop
340 install-desktop:
341         mkdir -p "$(DESTDIR)$(desktop_dir)"
342         desktop-file-install --mode 0644 --dir "$(DESTDIR)$(desktop_dir)" notmuch.desktop
343
344 SRCS  := $(SRCS) $(notmuch_client_srcs)
345 CLEAN := $(CLEAN) notmuch notmuch-shared $(notmuch_client_modules)
346 CLEAN := $(CLEAN) version.stamp notmuch-*.tar.gz.tmp
347
348 DISTCLEAN := $(DISTCLEAN) .first-build-message Makefile.config sh.config
349
350 DEPS := $(SRCS:%.c=.deps/%.d)
351 DEPS := $(DEPS:%.cc=.deps/%.d)
352 -include $(DEPS)
353
354 .SUFFIXES: # Delete the default suffixes. Old-Fashioned Suffix Rules not used.