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