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