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