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