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