]> git.notmuchmail.org Git - notmuch/blob - Makefile
Index content from citations and signatures.
[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
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
12 all_deps = Makefile Makefile.local Makefile.config \
13                    lib/Makefile lib/Makefile.local
14
15 extra_cflags :=
16 extra_cxxflags :=
17
18 # Now smash together user's values with our extra values
19 FINAL_CFLAGS = $(CFLAGS) $(WARN_CFLAGS) $(CONFIGURE_CFLAGS) $(extra_cflags)
20 FINAL_CXXFLAGS = $(CXXFLAGS) $(WARN_CXXFLAGS) $(CONFIGURE_CXXFLAGS) $(extra_cflags) $(extra_cxxflags)
21 FINAL_LDFLAGS = $(LDFLAGS) $(CONFIGURE_LDFLAGS)
22
23 all: notmuch notmuch.1.gz
24
25 # Before including any other Makefile fragments, get settings from the
26 # output of configure
27 Makefile.config: configure
28         @echo ""
29         @echo "Note: Calling ./configure with no command-line arguments. This is often fine,"
30         @echo "      but if you want to specify any arguments (such as an alternate prefix"
31         @echo "      into which to install), call ./configure explicitly and then make again."
32         @echo "      See \"./configure --help\" for more details."
33         @echo ""
34         ./configure
35
36 include Makefile.config
37
38 include lib/Makefile.local
39 include compat/Makefile.local
40 include Makefile.local
41
42 # The user has not set any verbosity, default to quiet mode and inform the
43 # user how to enable verbose compiles.
44 ifeq ($(V),)
45 quiet_DOC := "Use \"$(MAKE) V=1\" to see the verbose compile lines.\n"
46 quiet = @printf $(quiet_DOC)$(eval quiet_DOC:=)"  $1 $2 $@\n"; $($1)
47 endif
48 # The user has explicitly enabled quiet compilation.
49 ifeq ($(V),0)
50 quiet = @printf "  $1   $@\n"; $($1)
51 endif
52 # Otherwise, print the full command line.
53 quiet ?= $($1)
54
55 %.o: %.cc $(all_deps)
56         $(call quiet,CXX,$(CXXFLAGS)) -c $(FINAL_CXXFLAGS) $< -o $@
57
58 %.o: %.c $(all_deps)
59         $(call quiet,CC,$(CFLAGS)) -c $(FINAL_CFLAGS) $< -o $@
60
61 %.elc: %.el
62         $(call quiet,EMACS) -batch -f batch-byte-compile $<
63
64 .deps/%.d: %.c $(all_deps)
65         @set -e; rm -f $@; mkdir -p $$(dirname $@) ; \
66         $(CC) -M $(CPPFLAGS) $(FINAL_CFLAGS) $< > $@.$$$$ 2>/dev/null ; \
67         sed 's,'$$(basename $*)'\.o[ :]*,$*.o $@ : ,g' < $@.$$$$ > $@; \
68         rm -f $@.$$$$
69
70 .deps/%.d: %.cc $(all_deps)
71         @set -e; rm -f $@; mkdir -p $$(dirname $@) ; \
72         $(CXX) -M $(CPPFLAGS) $(FINAL_CXXFLAGS) $< > $@.$$$$ 2>/dev/null ; \
73         sed 's,'$$(basename $*)'\.o[ :]*,$*.o $@ : ,g' < $@.$$$$ > $@; \
74         rm -f $@.$$$$
75
76 DEPS := $(SRCS:%.c=.deps/%.d)
77 DEPS := $(DEPS:%.cc=.deps/%.d)
78 -include $(DEPS)
79
80 .PHONY : clean
81 clean:
82         rm -f $(CLEAN); rm -rf .deps