]> git.notmuchmail.org Git - notmuch/blob - Makefile.local
dump: support gzipped and atomic output
[notmuch] / Makefile.local
1 # -*- makefile -*-
2
3 # Here's the (hopefully simple) versioning scheme.
4 #
5 # Releases of notmuch have a two-digit version (0.1, 0.2, etc.). We
6 # increment the second digit for each release and increment the first
7 # digit when we reach particularly major milestones of usability.
8 #
9 # Between releases, (such as when compiling notmuch from the git
10 # repository), we let git append identification of the actual commit.
11 PACKAGE=notmuch
12
13 IS_GIT=$(shell if [ -d .git ] ; then echo yes ; else echo no; fi)
14
15 ifeq ($(IS_GIT),yes)
16 DATE:=$(shell git log --date=short -1 --pretty=format:%cd)
17 else
18 DATE:=$(shell date +%F)
19 endif
20
21 VERSION:=$(shell cat ${srcdir}/version)
22 ifeq ($(filter release release-message pre-release update-versions,$(MAKECMDGOALS)),)
23 ifeq ($(IS_GIT),yes)
24 VERSION:=$(shell git describe --match '[0-9.]*'|sed -e s/_/~/ -e s/-/+/ -e s/-/~/)
25 # Write the file 'version.stamp' in case its contents differ from $(VERSION)
26 FILE_VERSION:=$(shell test -f version.stamp && read vs < version.stamp || vs=; echo $$vs)
27 ifneq ($(FILE_VERSION),$(VERSION))
28        $(shell echo "$(VERSION)" > version.stamp)
29 endif
30 endif
31 endif
32
33 UPSTREAM_TAG=$(subst ~,_,$(VERSION))
34 DEB_TAG=debian/$(UPSTREAM_TAG)-1
35
36 RELEASE_HOST=notmuchmail.org
37 RELEASE_DIR=/srv/notmuchmail.org/www/releases
38 RELEASE_URL=http://notmuchmail.org/releases
39 TAR_FILE=$(PACKAGE)-$(VERSION).tar.gz
40 DEB_TAR_FILE=$(PACKAGE)_$(VERSION).orig.tar.gz
41 SHA1_FILE=$(TAR_FILE).sha1
42 GPG_FILE=$(SHA1_FILE).asc
43
44 PV_FILE=bindings/python/notmuch/version.py
45
46 # Smash together user's values with our extra values
47 FINAL_CFLAGS = -DNOTMUCH_VERSION=$(VERSION) $(CPPFLAGS) $(CFLAGS) $(WARN_CFLAGS) $(extra_cflags) $(CONFIGURE_CFLAGS)
48 FINAL_CXXFLAGS = $(CPPFLAGS) $(CXXFLAGS) $(WARN_CXXFLAGS) $(extra_cflags) $(extra_cxxflags) $(CONFIGURE_CXXFLAGS)
49 FINAL_NOTMUCH_LDFLAGS = $(LDFLAGS) -Lutil -lutil -Llib -lnotmuch $(AS_NEEDED_LDFLAGS) $(GMIME_LDFLAGS) $(TALLOC_LDFLAGS) $(ZLIB_LDFLAGS)
50 FINAL_NOTMUCH_LINKER = CC
51 ifneq ($(LINKER_RESOLVES_LIBRARY_DEPENDENCIES),1)
52 FINAL_NOTMUCH_LDFLAGS += $(CONFIGURE_LDFLAGS)
53 FINAL_NOTMUCH_LINKER = CXX
54 endif
55 ifeq ($(LIBDIR_IN_LDCONFIG),0)
56 FINAL_NOTMUCH_LDFLAGS += $(RPATH_LDFLAGS)
57 endif
58 FINAL_LIBNOTMUCH_LDFLAGS = $(LDFLAGS) $(AS_NEEDED_LDFLAGS) $(CONFIGURE_LDFLAGS)
59
60 .PHONY: all
61 all: notmuch notmuch-shared build-man
62 ifeq ($(MAKECMDGOALS),)
63 ifeq ($(shell cat .first-build-message 2>/dev/null),)
64         @NOTMUCH_FIRST_BUILD=1 $(MAKE) --no-print-directory all
65         @echo ""
66         @echo "Compilation of notmuch is now complete. You can install notmuch with:"
67         @echo ""
68         @echo " make install"
69         @echo ""
70         @echo "Note that depending on the prefix to which you are installing"
71         @echo "you may need root permission (such as \"sudo make install\")."
72         @echo "See \"./configure --help\" for help on setting an alternate prefix."
73         @echo Printed > .first-build-message
74 endif
75 endif
76
77 # Depend (also) on the file 'version'. In case of ifeq ($(IS_GIT),yes)
78 # this file may already have been updated.
79 version.stamp: $(srcdir)/version
80         echo $(VERSION) > $@
81
82 $(TAR_FILE):
83         if git tag -v $(VERSION) >/dev/null 2>&1; then \
84            ref=$(VERSION); \
85         else \
86            ref="HEAD" ; \
87            echo "Warning: No signed tag for $(VERSION)"; \
88         fi ; \
89         git archive --format=tar --prefix=$(PACKAGE)-$(VERSION)/ $$ref > $(TAR_FILE).tmp
90         echo $(VERSION) > version.tmp
91         tar --append -f $(TAR_FILE).tmp --transform s_^_$(PACKAGE)-$(VERSION)/_  --transform 's_.tmp$$__' version.tmp
92         rm version.tmp
93         gzip < $(TAR_FILE).tmp > $(TAR_FILE)
94         @echo "Source is ready for release in $(TAR_FILE)"
95
96 $(SHA1_FILE): $(TAR_FILE)
97         sha1sum $^ > $@
98
99 $(GPG_FILE): $(SHA1_FILE)
100         @echo "Please enter your GPG password to sign the checksum."
101         gpg --armor --sign $^ 
102
103 .PHONY: dist
104 dist: $(TAR_FILE)
105
106 .PHONY: update-versions
107
108 update-versions:
109         sed -i "s/^__VERSION__[[:blank:]]*=.*$$/__VERSION__ = \'${VERSION}\'/" $(PV_FILE)
110
111 # We invoke make recursively only to force ordering of our phony
112 # targets in the case of parallel invocation of make (-j).
113 #
114 # We carefully ensure that our VERSION variable is passed down to any
115 # sub-ordinate make invocations (which won't otherwise know that they
116 # are part of the release and need to take the version from the
117 # version file).
118 .PHONY: release
119 release: verify-source-tree-and-version
120         $(MAKE) VERSION=$(VERSION) verify-newer
121         $(MAKE) VERSION=$(VERSION) clean
122         $(MAKE) VERSION=$(VERSION) test
123         git tag -s -m "$(PACKAGE) $(VERSION) release" $(UPSTREAM_TAG)
124         $(MAKE) VERSION=$(VERSION) $(GPG_FILE)
125         ln -sf $(TAR_FILE) $(DEB_TAR_FILE)
126         pristine-tar commit $(DEB_TAR_FILE) $(UPSTREAM_TAG)
127         git tag -s -m "$(PACKAGE) Debian $(VERSION)-1 upload (same as $(VERSION))" $(DEB_TAG)
128         mkdir -p releases
129         mv $(TAR_FILE) $(SHA1_FILE) $(GPG_FILE) releases
130         $(MAKE) VERSION=$(VERSION) release-message > $(PACKAGE)-$(VERSION).announce
131 ifeq ($(REALLY_UPLOAD),yes)
132         git push origin $(VERSION)
133         cd releases && scp $(TAR_FILE) $(SHA1_FILE) $(GPG_FILE) $(RELEASE_HOST):$(RELEASE_DIR)
134         ssh $(RELEASE_HOST) "rm -f $(RELEASE_DIR)/LATEST-$(PACKAGE)-* ; ln -s $(TAR_FILE) $(RELEASE_DIR)/LATEST-$(TAR_FILE)"
135 endif
136         @echo "Please send a release announcement using $(PACKAGE)-$(VERSION).announce as a template."
137
138 .PHONY: pre-release
139 pre-release:
140         $(MAKE) VERSION=$(VERSION) clean
141         $(MAKE) VERSION=$(VERSION) test
142         git tag -s -m "$(PACKAGE) $(VERSION) release" $(UPSTREAM_TAG)
143         git tag -s -m "$(PACKAGE) Debian $(VERSION)-1 upload (same as $(VERSION))" $(DEB_TAG)
144         $(MAKE) VERSION=$(VERSION) $(TAR_FILE)
145         ln -sf $(TAR_FILE) $(DEB_TAR_FILE)
146         pristine-tar commit $(DEB_TAR_FILE) $(UPSTREAM_TAG)
147         mkdir -p releases
148         mv $(TAR_FILE) $(DEB_TAR_FILE) releases
149
150 .PHONY: debian-snapshot
151 debian-snapshot:
152         make VERSION=$(VERSION) clean
153         TMPFILE=$$(mktemp /tmp/notmuch.XXXXXX);         \
154           cp debian/changelog $${TMPFILE};              \
155           EDITOR=/bin/true dch -b -v $(VERSION)+1       \
156             -D UNRELEASED 'test build, not for upload'; \
157           echo '3.0 (native)' > debian/source/format;   \
158           debuild -us -uc;                              \
159           mv -f $${TMPFILE} debian/changelog;           \
160           echo '3.0 (quilt)' > debian/source/format
161
162 .PHONY: release-message
163 release-message:
164         @echo "To: notmuch@notmuchmail.org"
165         @echo "Subject: $(PACKAGE) release $(VERSION) now available"
166         @echo ""
167         @echo "Where to obtain notmuch $(VERSION)"
168         @echo "==========================="
169         @echo "  $(RELEASE_URL)/$(TAR_FILE)"
170         @echo ""
171         @echo "Which can be verified with:"
172         @echo ""
173         @echo "  $(RELEASE_URL)/$(SHA1_FILE)"
174         @echo -n "  "
175         @cat releases/$(SHA1_FILE)
176         @echo ""
177         @echo "  $(RELEASE_URL)/$(GPG_FILE)"
178         @echo "  (signed by `getent passwd "$$USER" | cut -d: -f 5 | cut -d, -f 1`)"
179         @echo ""
180         @echo "What's new in notmuch $(VERSION)"
181         @echo "========================="
182         @sed -ne '/^[Nn]otmuch $(VERSION)/{n;n;b NEWS}; d; :NEWS /^===/q; {p;n;b NEWS}' < NEWS | head -n -2
183         @echo ""
184         @echo "What is notmuch"
185         @echo "==============="
186         @echo "Notmuch is a system for indexing, searching, reading, and tagging"
187         @echo "large collections of email messages in maildir or mh format. It uses"
188         @echo "the Xapian library to provide fast, full-text search with a convenient"
189         @echo "search syntax."
190         @echo ""
191         @echo "For more about notmuch, see http://notmuchmail.org"
192
193 # This is a chain of dependencies rather than a simple list simply to
194 # avoid the messages getting interleaved in the case of a parallel
195 # make invocation.
196 .PHONY: verify-source-tree-and-version
197 verify-source-tree-and-version: verify-no-dirty-code
198
199 .PHONY: verify-no-dirty-code
200 verify-no-dirty-code: release-checks
201 ifeq ($(IS_GIT),yes)
202         @printf "Checking that source tree is clean..."
203 ifneq ($(shell git ls-files -m),)
204         @echo "No"
205         @echo "The following files have been modified since the most recent git commit:"
206         @echo ""
207         @git ls-files -m
208         @echo ""
209         @echo "The release will be made from the committed state, but perhaps you meant"
210         @echo "to commit this code first? Please clean this up to make it more clear."
211         @false
212 else
213         @echo "Good"
214 endif
215 endif
216
217 .PHONY: release-checks
218 release-checks:
219         devel/release-checks.sh
220
221 .PHONY: verify-newer
222 verify-newer:
223         @echo -n "Checking that no $(VERSION) release already exists..."
224         @wget -q -O /dev/null $(RELEASE_URL)/$(TAR_FILE) ; \
225         case $$? in \
226           8) echo "Good." ;; \
227           0) echo "Ouch."; \
228              echo "Found: $(RELEASE_URL)/$(TAR_FILE)"; \
229              echo "Refusing to replace an existing release."; \
230              echo "Don't forget to update \"version\" as described in RELEASING before release." ; \
231              false ;; \
232           *) echo "An unexpected error occured"; \
233              false;; esac
234
235 # The user has not set any verbosity, default to quiet mode and inform the
236 # user how to enable verbose compiles.
237 ifeq ($(V),)
238 quiet_DOC := "Use \"$(MAKE) V=1\" to see the verbose compile lines.\n"
239 quiet = @printf $(quiet_DOC)$(eval quiet_DOC:=)"$1 $@\n"; $($(shell echo $1 | sed -e s'/ .*//'))
240 endif
241 # The user has explicitly enabled quiet compilation.
242 ifeq ($(V),0)
243 quiet = @printf "$1 $@\n"; $($(shell echo $1 | sed -e s'/ .*//'))
244 endif
245 # Otherwise, print the full command line.
246 quiet ?= $($(shell echo $1 | sed -e s'/ .*//'))
247
248 %.o: %.cc $(global_deps)
249         @mkdir -p $(patsubst %/.,%,.deps/$(@D))
250         $(call quiet,CXX $(CPPFLAGS) $(CXXFLAGS)) -c $(FINAL_CXXFLAGS) $< -o $@ -MD -MP -MF .deps/$*.d
251
252 %.o: %.c $(global_deps)
253         @mkdir -p $(patsubst %/.,%,.deps/$(@D))
254         $(call quiet,CC $(CPPFLAGS) $(CFLAGS)) -c $(FINAL_CFLAGS) $< -o $@ -MD -MP -MF .deps/$*.d
255
256 .PHONY : clean
257 clean:
258         rm -rf $(CLEAN); rm -rf .deps
259
260 .PHONY: distclean
261 distclean: clean
262         rm -rf $(DISTCLEAN)
263
264 notmuch_client_srcs =           \
265         command-line-arguments.c\
266         debugger.c              \
267         gmime-filter-reply.c    \
268         hooks.c                 \
269         notmuch.c               \
270         notmuch-compact.c       \
271         notmuch-config.c        \
272         notmuch-count.c         \
273         notmuch-dump.c          \
274         notmuch-insert.c        \
275         notmuch-new.c           \
276         notmuch-reply.c         \
277         notmuch-restore.c       \
278         notmuch-search.c        \
279         notmuch-setup.c         \
280         notmuch-show.c          \
281         notmuch-tag.c           \
282         notmuch-time.c          \
283         sprinter-json.c         \
284         sprinter-sexp.c         \
285         sprinter-text.c         \
286         query-string.c          \
287         mime-node.c             \
288         crypto.c                \
289         tag-util.c
290
291 notmuch_client_modules = $(notmuch_client_srcs:.c=.o)
292
293 notmuch.o: version.stamp
294
295 notmuch: $(notmuch_client_modules) lib/libnotmuch.a util/libutil.a parse-time-string/libparse-time-string.a
296         $(call quiet,CXX $(CFLAGS)) $^ $(FINAL_LIBNOTMUCH_LDFLAGS) -o $@
297
298 notmuch-shared: $(notmuch_client_modules) lib/$(LINKER_NAME)
299         $(call quiet,$(FINAL_NOTMUCH_LINKER) $(CFLAGS)) $(notmuch_client_modules) $(FINAL_NOTMUCH_LDFLAGS) -o $@
300
301 .PHONY: install
302 install: all install-man
303         mkdir -p "$(DESTDIR)$(prefix)/bin/"
304         install notmuch-shared "$(DESTDIR)$(prefix)/bin/notmuch"
305 ifeq ($(MAKECMDGOALS), install)
306         @echo ""
307         @echo "Notmuch is now installed to $(DESTDIR)$(prefix)"
308         @echo ""
309         @echo "New users should simply run \"notmuch\" to be guided"
310         @echo "through the process of configuring notmuch and creating"
311         @echo "a database of existing email messages. The \"notmuch\""
312         @echo "command will also offer some sample search commands."
313 ifeq ($(WITH_EMACS), 1)
314         @echo ""
315         @echo "Beyond the command-line interface, notmuch also offers"
316         @echo "a full-featured interface for reading and writing mail"
317         @echo "within emacs. To use this, each user should add the"
318         @echo "following line to the ~/.emacs file:"
319         @echo ""
320         @echo " (require 'notmuch)"
321         @echo ""
322         @echo "And then run emacs as \"emacs -f notmuch\" or invoke"
323         @echo "the command \"M-x notmuch\" from within emacs."
324 endif
325 endif
326
327 .PHONY: install-desktop
328 install-desktop:
329         mkdir -p "$(DESTDIR)$(desktop_dir)"
330         desktop-file-install --mode 0644 --dir "$(DESTDIR)$(desktop_dir)" notmuch.desktop
331
332 SRCS  := $(SRCS) $(notmuch_client_srcs)
333 CLEAN := $(CLEAN) notmuch notmuch-shared $(notmuch_client_modules) version.stamp
334
335 DISTCLEAN := $(DISTCLEAN) .first-build-message Makefile.config
336
337 DEPS := $(SRCS:%.c=.deps/%.d)
338 DEPS := $(DEPS:%.cc=.deps/%.d)
339 -include $(DEPS)
340
341 .SUFFIXES: # Delete the default suffixes. Old-Fashioned Suffix Rules not used.