]> git.notmuchmail.org Git - notmuch/blob - Makefile
Clarify documentation of notmuch_database_add_message.
[notmuch] / Makefile
1 WARN_CXXFLAGS=-Wall -Wextra -Wwrite-strings -Wswitch-enum
2 WARN_CFLAGS=$(WARN_CXXFLAGS) -Wmissing-declarations
3
4 # Additional programs that are used during the compilation process.
5 EMACS ?= emacs --quick
6 # Lowercase to avoid clash with GZIP environment variable for passing
7 # arguments to gzip.
8 gzip = gzip
9
10 bash_completion_dir = /etc/bash_completion.d
11 zsh_completion_dir = /usr/share/zsh/functions/Completion/Unix
12
13 extra_cflags :=
14 extra_cxxflags :=
15
16 # Now smash together user's values with our extra values
17 FINAL_CFLAGS = $(CFLAGS) $(WARN_CFLAGS) $(CONFIGURE_CFLAGS) $(extra_cflags)
18 FINAL_CXXFLAGS = $(CXXFLAGS) $(WARN_CXXFLAGS) $(CONFIGURE_CXXFLAGS) $(extra_cflags) $(extra_cxxflags)
19 FINAL_LDFLAGS = $(LDFLAGS) $(CONFIGURE_LDFLAGS)
20
21 all: notmuch notmuch.1.gz
22 ifeq ($(MAKECMDGOALS),)
23         @echo ""
24         @echo "Compilation of notmuch is now complete. You can install notmuch with:"
25         @echo ""
26         @echo " make install"
27         @echo ""
28         @echo "Note that depending on the prefix to which you are installing"
29         @echo "you may need root permission (such as \"sudo make install\")."
30         @echo "See \"./configure --help\" for help on setting an alternate prefix."
31 endif
32
33 # Before including any other Makefile fragments, get settings from the
34 # output of configure
35 Makefile.config: configure
36         @echo ""
37         @echo "Note: Calling ./configure with no command-line arguments. This is often fine,"
38         @echo "      but if you want to specify any arguments (such as an alternate prefix"
39         @echo "      into which to install), call ./configure explicitly and then make again."
40         @echo "      See \"./configure --help\" for more details."
41         @echo ""
42         ./configure
43
44 subdirs = compat emacs lib
45
46 global_deps = Makefile Makefile.config Makefile.local \
47         $(subdirs:%=%/Makefile) $(subdirs:%=%/Makefile.local)
48
49 include Makefile.config Makefile.local $(subdirs:%=%/Makefile.local)
50
51 # The user has not set any verbosity, default to quiet mode and inform the
52 # user how to enable verbose compiles.
53 ifeq ($(V),)
54 quiet_DOC := "Use \"$(MAKE) V=1\" to see the verbose compile lines.\n"
55 quiet = @printf $(quiet_DOC)$(eval quiet_DOC:=)"  $1 $2 $@\n"; $($1)
56 endif
57 # The user has explicitly enabled quiet compilation.
58 ifeq ($(V),0)
59 quiet = @printf "  $1   $@\n"; $($1)
60 endif
61 # Otherwise, print the full command line.
62 quiet ?= $($1)
63
64 %.o: %.cc $(global_deps)
65         $(call quiet,CXX,$(CXXFLAGS)) -c $(FINAL_CXXFLAGS) $< -o $@
66
67 %.o: %.c $(global_deps)
68         $(call quiet,CC,$(CFLAGS)) -c $(FINAL_CFLAGS) $< -o $@
69
70 %.elc: %.el
71         $(call quiet,EMACS) -batch -f batch-byte-compile $<
72
73 .deps/%.d: %.c $(global_deps)
74         @set -e; rm -f $@; mkdir -p $$(dirname $@) ; \
75         $(CC) -M $(CPPFLAGS) $(FINAL_CFLAGS) $< > $@.$$$$ 2>/dev/null ; \
76         sed 's,'$$(basename $*)'\.o[ :]*,$*.o $@ : ,g' < $@.$$$$ > $@; \
77         rm -f $@.$$$$
78
79 .deps/%.d: %.cc $(global_deps)
80         @set -e; rm -f $@; mkdir -p $$(dirname $@) ; \
81         $(CXX) -M $(CPPFLAGS) $(FINAL_CXXFLAGS) $< > $@.$$$$ 2>/dev/null ; \
82         sed 's,'$$(basename $*)'\.o[ :]*,$*.o $@ : ,g' < $@.$$$$ > $@; \
83         rm -f $@.$$$$
84
85 DEPS := $(SRCS:%.c=.deps/%.d)
86 DEPS := $(DEPS:%.cc=.deps/%.d)
87 -include $(DEPS)
88
89 .PHONY : clean
90 clean:
91         rm -f $(CLEAN); rm -rf .deps