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