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