]> git.notmuchmail.org Git - notmuch/blob - Makefile.local
24612c1d09681c0cbf606244112b0f8df86c1a5b
[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         @echo "Source is ready for release in $(TAR_FILE)"
64
65 $(SHA1_FILE): $(TAR_FILE)
66         sha1sum $^ > $@
67
68 $(GPG_FILE): $(SHA1_FILE)
69         @echo "Please enter your GPG password to sign the checksum."
70         gpg --armor --sign $^ 
71
72 .PHONY: dist
73 dist: $(TAR_FILE)
74
75 # We invoke make recursively only to force ordering of our phony
76 # targets in the case of parallel invocation of make (-j).
77 #
78 # We carefully ensure that our VERSION variable is passed down to any
79 # sub-ordinate make invocations (which won't otherwhise know that they
80 # are part of the release and need to take the version from the
81 # version file).
82 .PHONY: release
83 release: verify-no-dirty-code
84         $(MAKE) VERSION=$(VERSION) test
85         $(MAKE) VERSION=$(VERSION) $(GPG_FILE)
86         $(MAKE) VERSION=$(VERSION) verify-newer
87         scp $(TAR_FILE) $(SHA1_FILE) $(GPG_FILE) $(RELEASE_HOST):$(RELEASE_DIR)
88         ssh $(RELEASE_HOST) "rm -f $(RELEASE_DIR)/LATEST-$(PACKAGE)-[0-9]* && ln -s $(TAR_FILE) $(RELEASE_DIR)/LATEST-$(PACKAGE)-$(VERSION)"
89         mkdir -p releases
90         mv $(TAR_FILE) $(SHA1_FILE) $(GPG_FILE) releases
91         git tag -s -m "$(PACKAGE) $(VERSION) release" $(VERSION)
92         git push origin $(VERSION)
93         $(MAKE) VERSION=$(VERSION) release-message > $(PACKAGE)-$(VERSION).announce
94         @echo "Please send a release announcement using $(PACKAGE)-$(VERSION).announce as a template."
95
96 .PHONY: release-message
97 release-message:
98         @echo "To: notmuch@notmuchmail.org"
99         @echo "Subject: $(PACKAGE) release $(VERSION) now available"
100         @echo ""
101         @echo "Where to obtain notmuch $(VERSION)"
102         @echo "==========================="
103         @echo "  $(RELEASE_URL)/$(TAR_FILE)"
104         @echo ""
105         @echo "Which can be verified with:"
106         @echo ""
107         @echo "  $(RELEASE_URL)/$(SHA1_FILE)"
108         @echo -n "  "
109         @cat releases/$(SHA1_FILE)
110         @echo ""
111         @echo "  $(RELEASE_URL)/$(GPG_FILE)"
112         @echo "  (signed by `getent passwd "$$USER" | cut -d: -f 5 | cut -d, -f 1`)"
113         @echo ""
114         @echo "What's new in notmuch $(VERSION)"
115         @echo "========================="
116         @sed -ne '/^[Nn]otmuch $(VERSION)/{n;n;b NEWS}; d; :NEWS /^===/q; {p;n;b NEWS}' < NEWS | head -n -2
117         @echo ""
118         @echo "What is notmuch"
119         @echo "==============="
120         @echo "Notmuch is a system for indexing, searching, reading, and tagging"
121         @echo "large collections of email messages in maildir or mh format. It uses"
122         @echo "the Xapian library to provide fast, full-text search with a convenient"
123         @echo "search syntax."
124         @echo ""
125         @echo "For more about notmuch, see http://notmuchmail.org"
126
127 .PHONY: verify-no-dirty-code
128 verify-no-dirty-code: verify-version
129         @printf "Checking that source tree is clean..."
130 ifneq ($(shell git ls-files -m),)
131         @echo "No"
132         @echo "The following files have been modified since the most recent git commit:"
133         @echo ""
134         @git ls-files -m
135         @echo ""
136         @echo "The release will be made from the committed state, but perhaps you meant"
137         @echo "to commit this code first? Please clean this up to make it more clear."
138         @false
139 else
140         @echo "Good"
141 endif
142
143 .PHONY: verify-version
144 verify-version:
145         @echo -n "Checking that $(VERSION) consists only of digits and periods..."
146         @if echo $(VERSION) | grep -q -v -x '[0-9.]*'; then \
147                 (echo "No." && \
148                  echo "Remember: You need to use:" && \
149                  echo "" && \
150                  echo " make VERSION=X.Y release" && \
151                  echo "" && \
152                  echo "to release notmuch." && false); \
153          else :; fi
154         @echo "Good."
155
156 .PHONY: verify-newer
157 verify-newer:
158         @echo -n "Checking that no $(VERSION) release already exists..."
159         @ssh $(RELEASE_HOST) test ! -e $(RELEASE_DIR)/$(TAR_FILE) \
160                 || (echo "Ouch." && echo "Found: $(RELEASE_HOST):$(RELEASE_DIR)/$(TAR_FILE)" \
161                 && echo "Refusing to replace an existing 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