]> git.notmuchmail.org Git - notmuch/blob - Makefile.local
Makefile: Make the "make release" target push the new tag.
[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 add a third digit, (0.1.1, 0.1.2, etc.), and
11 # increment it occasionally, (such as after a big batch of commits are
12 # merged.
13 PACKAGE=notmuch
14 VERSION=0.1.1
15
16 RELEASE_HOST=notmuchmail.org
17 RELEASE_DIR=/srv/notmuchmail.org/www/releases
18 TAR_FILE=$(PACKAGE)-$(VERSION).tar.gz
19 SHA1_FILE=$(TAR_FILE).sha1
20 GPG_FILE=$(SHA1_FILE).asc
21
22 # Get settings from the output of configure by running it to generate
23 # Makefile.config if it doesn't exist yet. And add Makefile.config to
24 # our global dependency list.
25 include Makefile.config
26 global_deps += Makefile.config
27 Makefile.config: configure
28         @echo ""
29         @echo "Note: Calling ./configure with no command-line arguments. This is often fine,"
30         @echo "      but if you want to specify any arguments (such as an alternate prefix"
31         @echo "      into which to install), call ./configure explicitly and then make again."
32         @echo "      See \"./configure --help\" for more details."
33         @echo ""
34         ./configure
35
36 # Sub-directory Makefile.local fragments can append to these variables
37 # to have directory-specific cflags as necessary.
38 extra_cflags :=
39 extra_cxxflags :=
40
41 # Smash together user's values with our extra values
42 FINAL_CFLAGS = -DNOTMUCH_VERSION=$(VERSION) $(CFLAGS) $(WARN_CFLAGS) $(CONFIGURE_CFLAGS) $(extra_cflags)
43 FINAL_CXXFLAGS = $(CXXFLAGS) $(WARN_CXXFLAGS) $(CONFIGURE_CXXFLAGS) $(extra_cflags) $(extra_cxxflags)
44 FINAL_LDFLAGS = $(LDFLAGS) $(CONFIGURE_LDFLAGS)
45
46 .PHONY: all
47 all: notmuch notmuch-shared notmuch.1.gz
48 ifeq ($(MAKECMDGOALS),)
49 ifeq ($(shell cat .first-build-message),)
50         @NOTMUCH_FIRST_BUILD=1 $(MAKE) --no-print-directory all
51         @echo ""
52         @echo "Compilation of notmuch is now complete. You can install notmuch with:"
53         @echo ""
54         @echo " make install"
55         @echo ""
56         @echo "Note that depending on the prefix to which you are installing"
57         @echo "you may need root permission (such as \"sudo make install\")."
58         @echo "See \"./configure --help\" for help on setting an alternate prefix."
59         @echo Printed > .first-build-message
60 endif
61 endif
62
63 $(TAR_FILE):
64         git archive --format=tar --prefix=$(PACKAGE)-$(VERSION)/ HEAD | gzip > $(TAR_FILE)
65         @echo "Source is ready for release in $(TAR_FILE)"
66
67 $(SHA1_FILE): $(TAR_FILE)
68         sha1sum $^ > $@
69
70 $(GPG_FILE): $(SHA1_FILE)
71         @echo "Please enter your GPG password to sign the checksum."
72         gpg --armor --sign $^ 
73
74 .PHONY: dist
75 dist: $(TAR_FILE)
76
77 .PHONY: release
78 release: release-verify-newer $(TAR_FILE) $(SHA1_FILE) $(GPG_FILE)
79         mkdir -p releases
80         scp $(TAR_FILE) $(SHA1_FILE) $(GPG_FILE) $(RELEASE_HOST):$(RELEASE_DIR)
81         mv $(TAR_FILE) $(SHA1_FILE) $(GPG_FILE) releases
82         ssh $(RELEASE_HOST) "rm -f $(RELEASE_DIR)/LATEST-$(PACKAGE)-[0-9]* && ln -s $(TAR_FILE) $(RELEASE_DIR)/LATEST-$(PACKAGE)-$(VERSION)"
83         git tag -s -m "$(PACKAGE) $(VERSION) release" $(VERSION)
84         git push origin $(VERSION)
85
86 .PHONY: release-verify-version
87 release-verify-version:
88         @echo -n "Checking that $(VERSION) is a two-component version..."
89         @if echo $(VERSION) | grep -q -v -x '[0-9]*\.[0-9]*'; then \
90                 (echo "Ouch." && \
91                  echo "Before releasing the notmuch version should be a two-component value." && false);\
92          else :; fi
93         @echo "Good."
94
95 .PHONY: release-verify-newer
96 release-verify-newer: release-verify-version
97         @echo -n "Checking that no $(VERSION) release already exists..."
98         @ssh $(RELEASE_HOST) test ! -e $(RELEASE_DIR)/$(TAR_FILE) \
99                 || (echo "Ouch." && echo "Found: $(RELEASE_HOST):$(RELEASE_DIR)/$(TAR_FILE)" \
100                 && echo "Refusing to replace an existing release." && false)
101         @echo "Good."
102
103 # The user has not set any verbosity, default to quiet mode and inform the
104 # user how to enable verbose compiles.
105 ifeq ($(V),)
106 quiet_DOC := "Use \"$(MAKE) V=1\" to see the verbose compile lines.\n"
107 quiet = @printf $(quiet_DOC)$(eval quiet_DOC:=)"  %12s $@\n" "$1 $2"; $($1)
108 quiet_args = @printf $(quiet_DOC)$(eval quiet_DOC:=)"  %12s$2\n" $1; $($1) $2
109 endif
110 # The user has explicitly enabled quiet compilation.
111 ifeq ($(V),0)
112 quiet = @printf "  %12s $@\n" "$1 $2"; $($1)
113 quiet_args = @printf "  %12s$2\n" $1; $($1) $2
114 endif
115 # Otherwise, print the full command line.
116 quiet ?= $($1)
117 quiet_args ?= $($1) $2
118
119 quiet_mkdir = $(call quiet_args,MKDIR,$1)
120 quiet_install_bin = $(call quiet_args,INSTALL-BIN,$1)
121 quiet_install_data = $(call quiet_args,INSTALL-DATA,$1)
122 quiet_symlink = $(call quiet_args,SYMLINK,$1)
123
124 %.o: %.cc $(global_deps)
125         $(call quiet,CXX,$(CXXFLAGS)) -c $(FINAL_CXXFLAGS) $< -o $@
126
127 %.o: %.c $(global_deps)
128         $(call quiet,CC,$(CFLAGS)) -c $(FINAL_CFLAGS) $< -o $@
129
130 %.elc: %.el
131         $(call quiet,EMACS) --directory emacs -batch -f batch-byte-compile $<
132
133 .deps/%.d: %.c $(global_deps)
134         @set -e; rm -f $@; mkdir -p $$(dirname $@) ; \
135         $(CC) -M $(CPPFLAGS) $(FINAL_CFLAGS) $< > $@.$$$$ 2>/dev/null ; \
136         sed 's,'$$(basename $*)'\.o[ :]*,$*.o $@ : ,g' < $@.$$$$ > $@; \
137         rm -f $@.$$$$
138
139 .deps/%.d: %.cc $(global_deps)
140         @set -e; rm -f $@; mkdir -p $$(dirname $@) ; \
141         $(CXX) -M $(CPPFLAGS) $(FINAL_CXXFLAGS) $< > $@.$$$$ 2>/dev/null ; \
142         sed 's,'$$(basename $*)'\.o[ :]*,$*.o $@ : ,g' < $@.$$$$ > $@; \
143         rm -f $@.$$$$
144
145 DEPS := $(SRCS:%.c=.deps/%.d)
146 DEPS := $(DEPS:%.cc=.deps/%.d)
147 -include $(DEPS)
148
149 .PHONY : clean
150 clean:
151         rm -f $(CLEAN); rm -rf .deps
152
153 notmuch_client_srcs =           \
154         $(notmuch_compat_srcs)  \
155         debugger.c              \
156         gmime-filter-reply.c    \
157         notmuch.c               \
158         notmuch-config.c        \
159         notmuch-count.c         \
160         notmuch-dump.c          \
161         notmuch-new.c           \
162         notmuch-reply.c         \
163         notmuch-restore.c       \
164         notmuch-search.c        \
165         notmuch-search-tags.c   \
166         notmuch-setup.c         \
167         notmuch-show.c          \
168         notmuch-tag.c           \
169         notmuch-time.c          \
170         query-string.c          \
171         show-message.c          \
172         json.c
173
174 notmuch_client_modules = $(notmuch_client_srcs:.c=.o)
175
176 notmuch: $(notmuch_client_modules) lib/libnotmuch.a
177         $(call quiet,CC,$(LDFLAGS)) $^ $(FINAL_LDFLAGS) -o $@
178
179 notmuch-shared: $(notmuch_client_modules) lib/libnotmuch.so
180         $(call quiet,CC,$(LDFLAGS)) -Llib -lnotmuch $(notmuch_client_modules) $(FINAL_LDFLAGS) -o $@
181
182 notmuch.1.gz: notmuch.1
183         $(call quiet,gzip) --stdout $^ > $@
184
185 .PHONY: install
186 install: all notmuch.1.gz
187         $(call quiet_mkdir, $(DESTDIR)$(prefix)/bin/)
188         $(call quiet_mkdir, $(DESTDIR)$(libdir)/)
189         $(call quiet_mkdir, $(DESTDIR)$(prefix)/include/)
190         $(call quiet_mkdir, $(DESTDIR)$(prefix)/share/man/man1)
191         $(call quiet_install_bin, notmuch-shared $(DESTDIR)$(prefix)/bin/notmuch)
192         $(call quiet_install_data, notmuch.1.gz $(DESTDIR)$(prefix)/share/man/man1/)
193 ifeq ($(MAKECMDGOALS), install)
194         @echo ""
195         @echo "Notmuch is now installed."
196         @echo ""
197         @echo "You may now want to install additional components to support using notmuch"
198         @echo "together with other software packages:"
199         @echo ""
200         @echo " make install-emacs"
201         @echo " make install-bash"
202         @echo " make install-zsh"
203         @echo ""
204 endif
205
206 .PHONY: install-desktop
207 install-desktop:
208         $(call quiet,MKDIR) $(DESTDIR)$(desktop_dir)
209         desktop-file-install --mode 0644 --dir $(DESTDIR)$(desktop_dir) notmuch.desktop
210
211 .PHONY: install-bash
212 install-bash:
213         $(call quiet-mkdir, $(DESTDIR)$(bash_completion_dir))
214         $(call quiet_install_data, contrib/notmuch-completion.bash $(DESTDIR)$(bash_completion_dir)/notmuch)
215
216 .PHONY: install-zsh
217 install-zsh:
218         $(call quiet_mkdir, $(DESTDIR)$(zsh_completion_dir))
219         $(call quiet_install_data, contrib/notmuch-completion.zsh $(DESTDIR)$(zsh_completion_dir)/notmuch)
220
221 SRCS  := $(SRCS) $(notmuch_client_srcs)
222 CLEAN := $(CLEAN) notmuch notmuch-shared $(notmuch_client_modules) notmuch.elc notmuch.1.gz