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