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