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