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