3 # Here's the (hopefully simple) versioning scheme.
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.
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
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
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
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."
36 # Sub-directory Makefile.local fragments can append to these variables
37 # to have directory-specific cflags as necessary.
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_NOTMUCH_LDFLAGS = $(LDFLAGS) -Llib -lnotmuch
45 FINAL_LIBNOTMUCH_LDFLAGS = $(LDFLAGS) $(CONFIGURE_LDFLAGS)
48 all: notmuch notmuch-shared notmuch.1.gz
49 ifeq ($(MAKECMDGOALS),)
50 ifeq ($(shell cat .first-build-message),)
51 @NOTMUCH_FIRST_BUILD=1 $(MAKE) --no-print-directory all
53 @echo "Compilation of notmuch is now complete. You can install notmuch with:"
57 @echo "Note that depending on the prefix to which you are installing"
58 @echo "you may need root permission (such as \"sudo make install\")."
59 @echo "See \"./configure --help\" for help on setting an alternate prefix."
60 @echo Printed > .first-build-message
65 git archive --format=tar --prefix=$(PACKAGE)-$(VERSION)/ HEAD | gzip > $(TAR_FILE)
66 @echo "Source is ready for release in $(TAR_FILE)"
68 $(SHA1_FILE): $(TAR_FILE)
71 $(GPG_FILE): $(SHA1_FILE)
72 @echo "Please enter your GPG password to sign the checksum."
79 release: release-verify-newer $(TAR_FILE) $(SHA1_FILE) $(GPG_FILE)
81 scp $(TAR_FILE) $(SHA1_FILE) $(GPG_FILE) $(RELEASE_HOST):$(RELEASE_DIR)
82 mv $(TAR_FILE) $(SHA1_FILE) $(GPG_FILE) releases
83 ssh $(RELEASE_HOST) "rm -f $(RELEASE_DIR)/LATEST-$(PACKAGE)-[0-9]* && ln -s $(TAR_FILE) $(RELEASE_DIR)/LATEST-$(PACKAGE)-$(VERSION)"
84 git tag -s -m "$(PACKAGE) $(VERSION) release" $(VERSION)
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 \
91 echo "Before releasing the notmuch version should be a two-component value." && false);\
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)
103 # The user has not set any verbosity, default to quiet mode and inform the
104 # user how to enable verbose compiles.
106 quiet_DOC := "Use \"$(MAKE) V=1\" to see the verbose compile lines.\n"
107 quiet = @printf $(quiet_DOC)$(eval quiet_DOC:=)"$1 $@\n"; $($(shell echo $1 | sed -e s'/ .*//'))
109 # The user has explicitly enabled quiet compilation.
111 quiet = @printf "$1 $@\n"; $($(shell echo $1 | sed -e s'/ .*//'))
113 # Otherwise, print the full command line.
114 quiet ?= $($(shell echo $1 | sed -e s'/ .*//'))
116 %.o: %.cc $(global_deps)
117 $(call quiet,CXX $(CXXFLAGS)) -c $(FINAL_CXXFLAGS) $< -o $@
119 %.o: %.c $(global_deps)
120 $(call quiet,CC $(CFLAGS)) -c $(FINAL_CFLAGS) $< -o $@
122 .deps/%.d: %.c $(global_deps)
123 @set -e; rm -f $@; mkdir -p $$(dirname $@) ; \
124 $(CC) -M $(CPPFLAGS) $(FINAL_CFLAGS) $< > $@.$$$$ 2>/dev/null ; \
125 sed 's,'$$(basename $*)'\.o[ :]*,$*.o $@ : ,g' < $@.$$$$ > $@; \
128 .deps/%.d: %.cc $(global_deps)
129 @set -e; rm -f $@; mkdir -p $$(dirname $@) ; \
130 $(CXX) -M $(CPPFLAGS) $(FINAL_CXXFLAGS) $< > $@.$$$$ 2>/dev/null ; \
131 sed 's,'$$(basename $*)'\.o[ :]*,$*.o $@ : ,g' < $@.$$$$ > $@; \
134 DEPS := $(SRCS:%.c=.deps/%.d)
135 DEPS := $(DEPS:%.cc=.deps/%.d)
140 rm -f $(CLEAN); rm -rf .deps
142 # We don't (yet) have any distributed files not in the upstream repository.
143 # So distclean is currently identical to clean.
147 notmuch_client_srcs = \
148 $(notmuch_compat_srcs) \
150 gmime-filter-reply.c \
159 notmuch-search-tags.c \
168 notmuch_client_modules = $(notmuch_client_srcs:.c=.o)
170 notmuch: $(notmuch_client_modules) lib/libnotmuch.a
171 $(call quiet,CC $(CFLAGS)) $^ $(FINAL_LIBNOTMUCH_LDFLAGS) -o $@
173 notmuch-shared: $(notmuch_client_modules) lib/libnotmuch.so
174 $(call quiet,CC $(CFLAGS)) $(notmuch_client_modules) $(FINAL_NOTMUCH_LDFLAGS) -o $@
176 notmuch.1.gz: notmuch.1
177 gzip --stdout $^ > $@
180 install: all notmuch.1.gz
181 mkdir -p $(DESTDIR)$(mandir)/man1
182 install -m0644 notmuch.1.gz $(DESTDIR)$(mandir)/man1/
183 mkdir -p $(DESTDIR)$(prefix)/bin/
184 install notmuch-shared $(DESTDIR)$(prefix)/bin/notmuch
185 ifeq ($(MAKECMDGOALS), install)
187 @echo "Notmuch is now installed to $(DESTDIR)$(prefix)"
189 @echo "To run notmuch from emacs, each user should add the following line to ~/.emacs:"
191 @echo " (require 'notmuch)"
193 @echo "And should then run \"M-x notmuch\" from within emacs or run \"emacs -f notmuch\""
196 .PHONY: install-desktop
198 mkdir -p $(DESTDIR)$(desktop_dir)
199 desktop-file-install --mode 0644 --dir $(DESTDIR)$(desktop_dir) notmuch.desktop
201 SRCS := $(SRCS) $(notmuch_client_srcs)
202 CLEAN := $(CLEAN) notmuch notmuch-shared $(notmuch_client_modules) notmuch.elc notmuch.1.gz