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