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