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