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