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