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