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