]> git.notmuchmail.org Git - notmuch/blob - Makefile.local
Derive version numbers from git
[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 # Get settings from the output of configure by running it to generate
23 # Makefile.config if it doesn't exist yet. And add Makefile.config to
24 # our global dependency list.
25 include Makefile.config
26 global_deps += Makefile.config
27 Makefile.config: configure
28         @echo ""
29         @echo "Note: Calling ./configure with no command-line arguments. This is often fine,"
30         @echo "      but if you want to specify any arguments (such as an alternate prefix"
31         @echo "      into which to install), call ./configure explicitly and then make again."
32         @echo "      See \"./configure --help\" for more details."
33         @echo ""
34         ./configure
35
36 # Sub-directory Makefile.local fragments can append to these variables
37 # to have directory-specific cflags as necessary.
38 extra_cflags :=
39 extra_cxxflags :=
40
41 # Smash together user's values with our extra values
42 FINAL_CFLAGS = -DNOTMUCH_VERSION=$(VERSION) $(CFLAGS) $(WARN_CFLAGS) $(CONFIGURE_CFLAGS) $(extra_cflags)
43 FINAL_CXXFLAGS = $(CXXFLAGS) $(WARN_CXXFLAGS) $(CONFIGURE_CXXFLAGS) $(extra_cflags) $(extra_cxxflags)
44 FINAL_NOTMUCH_LDFLAGS = $(LDFLAGS) -Llib -lnotmuch
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),)
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
67         tar --append -f $(TAR_FILE).tmp --transform s_^_$(PACKAGE)-$(VERSION)/_ version
68         rm version
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 .PHONY: release
85 release: release-verify-newer
86         $(MAKE) release-upload
87         @echo "Please send a release announcement as follows:"
88         @echo ""
89         $(MAKE) release-message
90         $(MAKE) release-message > $(PACKAGE)-$(VERSION).announce
91         @echo "(This message is also available in $(PACKAGE)-$(VERSION).announce"
92
93 .PHONY: release-upload
94 release-upload: $(TAR_FILE) $(SHA1_FILE) $(GPG_FILE)
95         mkdir -p releases
96         scp $(TAR_FILE) $(SHA1_FILE) $(GPG_FILE) $(RELEASE_HOST):$(RELEASE_DIR)
97         mv $(TAR_FILE) $(SHA1_FILE) $(GPG_FILE) releases
98         ssh $(RELEASE_HOST) "rm -f $(RELEASE_DIR)/LATEST-$(PACKAGE)-[0-9]* && ln -s $(TAR_FILE) $(RELEASE_DIR)/LATEST-$(PACKAGE)-$(VERSION)"
99         git tag -s -m "$(PACKAGE) $(VERSION) release" $(VERSION)
100         git push origin $(VERSION)
101
102 .PHONY: release-message
103 release-message:
104         @echo "To: notmuch@notmuchmail.org"
105         @echo "Subject: $(PACKAGE) release $(VERSION) now available"
106         @echo ""
107         @echo "Where to obtain notmuch $(VERSION)"
108         @echo "==========================="
109         @echo "  $(RELEASE_URL)/$(TAR_FILE)"
110         @echo ""
111         @echo "Which can be verified with:"
112         @echo ""
113         @echo "  $(RELEASE_URL)/$(SHA1_FILE)"
114         @echo -n "  "
115         @cat releases/$(SHA1_FILE)
116         @echo ""
117         @echo "  $(RELEASE_URL)/$(GPG_FILE)"
118         @echo "  (signed by `getent passwd "$$USER" | cut -d: -f 5 | cut -d, -f 1`)"
119         @echo ""
120         @echo "What's new in notmuch $(VERSION)"
121         @echo "========================="
122         @sed -ne '/^[Nn]otmuch 0.1/{n;n;b NEWS}; d; :NEWS /^===/q; {p;n;b NEWS}' < NEWS | head -n -2
123         @echo ""
124         @echo "What is notmuch"
125         @echo "==============="
126         @echo "Notmuch is a system for indexing, searching, reading, and tagging"
127         @echo "large collections of email messages in maildir or mh format. It uses"
128         @echo "the Xapian library to provide fast, full-text search with a convenient"
129         @echo "search syntax."
130         @echo ""
131         @echo "For more about notmuch, see http://notmuchmail.org"
132
133
134 .PHONY: release-verify-version
135 release-verify-version:
136         @echo -n "Checking that $(VERSION) is a two-component version..."
137         @if echo $(VERSION) | grep -q -v -x '[0-9]*\.[0-9]*'; then \
138                 (echo "Ouch." && \
139                  echo "Before releasing the notmuch version should be a two-component value." && false);\
140          else :; fi
141         @echo "Good."
142
143 .PHONY: release-verify-newer
144 release-verify-newer: release-verify-version
145         @echo -n "Checking that no $(VERSION) release already exists..."
146         @ssh $(RELEASE_HOST) test ! -e $(RELEASE_DIR)/$(TAR_FILE) \
147                 || (echo "Ouch." && echo "Found: $(RELEASE_HOST):$(RELEASE_DIR)/$(TAR_FILE)" \
148                 && echo "Refusing to replace an existing release." && false)
149         @echo "Good."
150
151 # The user has not set any verbosity, default to quiet mode and inform the
152 # user how to enable verbose compiles.
153 ifeq ($(V),)
154 quiet_DOC := "Use \"$(MAKE) V=1\" to see the verbose compile lines.\n"
155 quiet = @printf $(quiet_DOC)$(eval quiet_DOC:=)"$1 $@\n"; $($(shell echo $1 | sed -e s'/ .*//'))
156 endif
157 # The user has explicitly enabled quiet compilation.
158 ifeq ($(V),0)
159 quiet = @printf "$1 $@\n"; $($(shell echo $1 | sed -e s'/ .*//'))
160 endif
161 # Otherwise, print the full command line.
162 quiet ?= $($(shell echo $1 | sed -e s'/ .*//'))
163
164 %.o: %.cc $(global_deps)
165         $(call quiet,CXX $(CXXFLAGS)) -c $(FINAL_CXXFLAGS) $< -o $@
166
167 %.o: %.c $(global_deps)
168         $(call quiet,CC $(CFLAGS)) -c $(FINAL_CFLAGS) $< -o $@
169
170 .deps/%.d: %.c $(global_deps)
171         @set -e; rm -f $@; mkdir -p $$(dirname $@) ; \
172         $(CC) -M $(CPPFLAGS) $(FINAL_CFLAGS) $< > $@.$$$$ 2>/dev/null ; \
173         sed 's,'$$(basename $*)'\.o[ :]*,$*.o $@ : ,g' < $@.$$$$ > $@; \
174         rm -f $@.$$$$
175
176 .deps/%.d: %.cc $(global_deps)
177         @set -e; rm -f $@; mkdir -p $$(dirname $@) ; \
178         $(CXX) -M $(CPPFLAGS) $(FINAL_CXXFLAGS) $< > $@.$$$$ 2>/dev/null ; \
179         sed 's,'$$(basename $*)'\.o[ :]*,$*.o $@ : ,g' < $@.$$$$ > $@; \
180         rm -f $@.$$$$
181
182 DEPS := $(SRCS:%.c=.deps/%.d)
183 DEPS := $(DEPS:%.cc=.deps/%.d)
184 -include $(DEPS)
185
186 .PHONY : clean
187 clean:
188         rm -f $(CLEAN); rm -rf .deps
189
190 # We don't (yet) have any distributed files not in the upstream repository.
191 # So distclean is currently identical to clean.
192 .PHONY: distclean
193 distclean: clean
194
195 notmuch_client_srcs =           \
196         $(notmuch_compat_srcs)  \
197         debugger.c              \
198         gmime-filter-reply.c    \
199         notmuch.c               \
200         notmuch-config.c        \
201         notmuch-count.c         \
202         notmuch-dump.c          \
203         notmuch-new.c           \
204         notmuch-reply.c         \
205         notmuch-restore.c       \
206         notmuch-search.c        \
207         notmuch-search-tags.c   \
208         notmuch-setup.c         \
209         notmuch-show.c          \
210         notmuch-tag.c           \
211         notmuch-time.c          \
212         query-string.c          \
213         show-message.c          \
214         json.c
215
216 notmuch_client_modules = $(notmuch_client_srcs:.c=.o)
217
218 notmuch: $(notmuch_client_modules) lib/libnotmuch.a
219         $(call quiet,CC $(CFLAGS)) $^ $(FINAL_LIBNOTMUCH_LDFLAGS) -o $@
220
221 notmuch-shared: $(notmuch_client_modules) lib/libnotmuch.so
222         $(call quiet,CC $(CFLAGS)) $(notmuch_client_modules) $(FINAL_NOTMUCH_LDFLAGS) -o $@
223
224 notmuch.1.gz: notmuch.1
225         gzip --stdout $^ > $@
226
227 .PHONY: install
228 install: all notmuch.1.gz
229         mkdir -p $(DESTDIR)$(mandir)/man1
230         install -m0644 notmuch.1.gz $(DESTDIR)$(mandir)/man1/
231         mkdir -p $(DESTDIR)$(prefix)/bin/
232         install notmuch-shared $(DESTDIR)$(prefix)/bin/notmuch
233 ifeq ($(MAKECMDGOALS), install)
234         @echo ""
235         @echo "Notmuch is now installed to $(DESTDIR)$(prefix)"
236         @echo ""
237         @echo "To run notmuch from emacs, each user should add the following line to ~/.emacs:"
238         @echo ""
239         @echo " (require 'notmuch)"
240         @echo ""
241         @echo "And should then run \"M-x notmuch\" from within emacs or run \"emacs -f notmuch\""
242 endif
243
244 .PHONY: install-desktop
245 install-desktop:
246         mkdir -p $(DESTDIR)$(desktop_dir)
247         desktop-file-install --mode 0644 --dir $(DESTDIR)$(desktop_dir) notmuch.desktop
248
249 SRCS  := $(SRCS) $(notmuch_client_srcs)
250 CLEAN := $(CLEAN) notmuch notmuch-shared $(notmuch_client_modules) notmuch.elc notmuch.1.gz