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