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