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