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