]> git.notmuchmail.org Git - notmuch/blob - Makefile.local
d38c6733e08a0ea914e1814592a2d7d9ac9f2d3b
[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 # The user has not set any verbosity, default to quiet mode and inform the
57 # user how to enable verbose compiles.
58 ifeq ($(V),)
59 quiet_DOC := "Use \"$(MAKE) V=1\" to see the verbose compile lines.\n"
60 quiet = @printf $(quiet_DOC)$(eval quiet_DOC:=)"  %12s $@\n" "$1 $2"; $($1)
61 quiet_args = @printf $(quiet_DOC)$(eval quiet_DOC:=)"  %12s$2\n" $1; $($1) $2
62 endif
63 # The user has explicitly enabled quiet compilation.
64 ifeq ($(V),0)
65 quiet = @printf "  %12s $@\n" "$1 $2"; $($1)
66 quiet_args = @printf "  %12s$2\n" $1; $($1) $2
67 endif
68 # Otherwise, print the full command line.
69 quiet ?= $($1)
70 quiet_args ?= $($1) $2
71
72 quiet_mkdir = $(call quiet_args,MKDIR,$1)
73 quiet_install_bin = $(call quiet_args,INSTALL-BIN,$1)
74 quiet_install_data = $(call quiet_args,INSTALL-DATA,$1)
75 quiet_symlink = $(call quiet_args,SYMLINK,$1)
76
77 %.o: %.cc $(global_deps)
78         $(call quiet,CXX,$(CXXFLAGS)) -c $(FINAL_CXXFLAGS) $< -o $@
79
80 %.o: %.c $(global_deps)
81         $(call quiet,CC,$(CFLAGS)) -c $(FINAL_CFLAGS) $< -o $@
82
83 %.elc: %.el
84         $(call quiet,EMACS) --directory emacs -batch -f batch-byte-compile $<
85
86 .deps/%.d: %.c $(global_deps)
87         @set -e; rm -f $@; mkdir -p $$(dirname $@) ; \
88         $(CC) -M $(CPPFLAGS) $(FINAL_CFLAGS) $< > $@.$$$$ 2>/dev/null ; \
89         sed 's,'$$(basename $*)'\.o[ :]*,$*.o $@ : ,g' < $@.$$$$ > $@; \
90         rm -f $@.$$$$
91
92 .deps/%.d: %.cc $(global_deps)
93         @set -e; rm -f $@; mkdir -p $$(dirname $@) ; \
94         $(CXX) -M $(CPPFLAGS) $(FINAL_CXXFLAGS) $< > $@.$$$$ 2>/dev/null ; \
95         sed 's,'$$(basename $*)'\.o[ :]*,$*.o $@ : ,g' < $@.$$$$ > $@; \
96         rm -f $@.$$$$
97
98 DEPS := $(SRCS:%.c=.deps/%.d)
99 DEPS := $(DEPS:%.cc=.deps/%.d)
100 -include $(DEPS)
101
102 .PHONY : clean
103 clean:
104         rm -f $(CLEAN); rm -rf .deps
105
106 notmuch_client_srcs =           \
107         $(notmuch_compat_srcs)  \
108         debugger.c              \
109         gmime-filter-reply.c    \
110         notmuch.c               \
111         notmuch-config.c        \
112         notmuch-count.c         \
113         notmuch-dump.c          \
114         notmuch-new.c           \
115         notmuch-reply.c         \
116         notmuch-restore.c       \
117         notmuch-search.c        \
118         notmuch-search-tags.c   \
119         notmuch-setup.c         \
120         notmuch-show.c          \
121         notmuch-tag.c           \
122         notmuch-time.c          \
123         query-string.c          \
124         show-message.c          \
125         json.c
126
127 notmuch_client_modules = $(notmuch_client_srcs:.c=.o)
128
129 notmuch: $(notmuch_client_modules) lib/libnotmuch.a
130         $(call quiet,CC,$(LDFLAGS)) $^ $(FINAL_LDFLAGS) -o $@
131
132 notmuch-shared: $(notmuch_client_modules) lib/libnotmuch.so
133         $(call quiet,CC,$(LDFLAGS)) -Llib -lnotmuch $(notmuch_client_modules) $(FINAL_LDFLAGS) -o $@
134
135 notmuch.1.gz: notmuch.1
136         $(call quiet,gzip) --stdout $^ > $@
137
138 .PHONY: install
139 install: all notmuch.1.gz
140         $(call quiet_mkdir, $(DESTDIR)$(prefix)/bin/)
141         $(call quiet_mkdir, $(DESTDIR)$(libdir)/)
142         $(call quiet_mkdir, $(DESTDIR)$(prefix)/include/)
143         $(call quiet_mkdir, $(DESTDIR)$(prefix)/share/man/man1)
144         $(call quiet_install_bin, notmuch-shared $(DESTDIR)$(prefix)/bin/notmuch)
145         $(call quiet_install_data, notmuch.1.gz $(DESTDIR)$(prefix)/share/man/man1/)
146 ifeq ($(MAKECMDGOALS), install)
147         @echo ""
148         @echo "Notmuch is now installed."
149         @echo ""
150         @echo "You may now want to install additional components to support using notmuch"
151         @echo "together with other software packages:"
152         @echo ""
153         @echo " make install-emacs"
154         @echo " make install-bash"
155         @echo " make install-zsh"
156         @echo ""
157 endif
158
159 .PHONY: install-desktop
160 install-desktop:
161         $(call quiet,MKDIR) $(DESTDIR)$(desktop_dir)
162         desktop-file-install --mode 0644 --dir $(DESTDIR)$(desktop_dir) notmuch.desktop
163
164 .PHONY: install-bash
165 install-bash:
166         $(call quiet-mkdir, $(DESTDIR)$(bash_completion_dir))
167         $(call quiet_install_data, contrib/notmuch-completion.bash $(DESTDIR)$(bash_completion_dir)/notmuch)
168
169 .PHONY: install-zsh
170 install-zsh:
171         $(call quiet_mkdir, $(DESTDIR)$(zsh_completion_dir))
172         $(call quiet_install_data, contrib/notmuch-completion.zsh $(DESTDIR)$(zsh_completion_dir)/notmuch)
173
174 SRCS  := $(SRCS) $(notmuch_client_srcs)
175 CLEAN := $(CLEAN) notmuch notmuch-shared $(notmuch_client_modules) notmuch.elc notmuch.1.gz