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