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