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