]> git.notmuchmail.org Git - notmuch/blob - Makefile
889a78c9d1ed243c1019fcc35e272b92f6ec8e27
[notmuch] / Makefile
1 # Default FLAGS, (can be overridden by user such as "make CFLAGS=-g")
2 CFLAGS=-O2
3
4 WARN_CXXFLAGS=-Wall -Wextra -Wwrite-strings -Wswitch-enum
5 WARN_CFLAGS=$(WARN_CXXFLAGS) -Wmissing-declarations
6
7 # Additional programs that are used during the compilation process.
8 EMACS ?= emacs
9 # Lowercase to avoid clash with GZIP environment variable for passing
10 # arguments to gzip.
11 gzip = gzip
12
13 bash_completion_dir = /etc/bash_completion.d
14
15 all_deps = Makefile Makefile.local Makefile.config \
16                    lib/Makefile lib/Makefile.local
17
18 extra_cflags :=
19 extra_cxxflags :=
20
21 # Now smash together user's values with our extra values
22 FINAL_CFLAGS = $(CFLAGS) $(WARN_CFLAGS) $(CONFIGURE_CFLAGS) $(extra_cflags)
23 FINAL_CXXFLAGS = $(CXXFLAGS) $(WARN_CXXFLAGS) $(CONFIGURE_CXXFLAGS) $(extra_cflags) $(extra_cxxflags)
24 FINAL_LDFLAGS = $(LDFLAGS) $(CONFIGURE_LDFLAGS)
25
26 all: notmuch notmuch.1.gz
27
28 # Before including any other Makefile fragments, get settings from the
29 # output of configure
30 Makefile.config: configure
31         ./configure
32
33 include Makefile.config
34
35 include lib/Makefile.local
36 include compat/Makefile.local
37 include Makefile.local
38
39 # The user has not set any verbosity, default to quiet mode and inform the
40 # user how to enable verbose compiles.
41 ifeq ($(V),)
42 quiet_DOC := "Use \"$(MAKE) V=1\" to see the verbose compile lines.\n"
43 quiet = @printf $(quiet_DOC)$(eval quiet_DOC:=)"  $1 $2 $@\n"; $($1)
44 endif
45 # The user has explicitly enabled quiet compilation.
46 ifeq ($(V),0)
47 quiet = @printf "  $1   $@\n"; $($1)
48 endif
49 # Otherwise, print the full command line.
50 quiet ?= $($1)
51
52 %.o: %.cc $(all_deps)
53         $(call quiet,CXX,$(CXXFLAGS)) -c $(FINAL_CXXFLAGS) $< -o $@
54
55 %.o: %.c $(all_deps)
56         $(call quiet,CC,$(CFLAGS)) -c $(FINAL_CFLAGS) $< -o $@
57
58 %.elc: %.el
59         $(call quiet,EMACS) -batch -f batch-byte-compile $<
60
61 .deps/%.d: %.c $(all_deps)
62         @set -e; rm -f $@; mkdir -p $$(dirname $@) ; \
63         $(CC) -M $(CPPFLAGS) $(FINAL_CFLAGS) $< > $@.$$$$; \
64         sed 's,'$$(basename $*)'\.o[ :]*,$*.o $@ : ,g' < $@.$$$$ > $@; \
65         rm -f $@.$$$$
66
67 .deps/%.d: %.cc $(all_deps)
68         @set -e; rm -f $@; mkdir -p $$(dirname $@) ; \
69         $(CXX) -M $(CPPFLAGS) $(FINAL_CXXFLAGS) $< > $@.$$$$; \
70         sed 's,'$$(basename $*)'\.o[ :]*,$*.o $@ : ,g' < $@.$$$$ > $@; \
71         rm -f $@.$$$$
72
73 DEPS := $(SRCS:%.c=.deps/%.d)
74 DEPS := $(DEPS:%.cc=.deps/%.d)
75 -include $(DEPS)
76
77 .PHONY : clean
78 clean:
79         rm -f $(CLEAN); rm -rf .deps