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