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