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