]> git.notmuchmail.org Git - notmuch/blob - Makefile
getdelim: Silence a (bogus) compiler warning.
[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 # Additional flags that we will append to whatever the user set.
14 # These aren't intended for the user to manipulate.
15 extra_cflags := $(shell pkg-config --cflags glib-2.0 gmime-2.4 talloc)
16 extra_cxxflags := $(shell xapian-config --cxxflags)
17
18 emacs_lispdir := $(shell pkg-config emacs --variable sitepkglispdir)
19 # Hard-code if this system doesn't have an emacs.pc file
20 ifeq ($(emacs_lispdir),)
21         emacs_lispdir = $(prefix)/share/emacs/site-lisp
22 endif
23
24 bash_completion_dir = /etc/bash_completion.d
25
26 all_deps = Makefile Makefile.local Makefile.config \
27                    lib/Makefile lib/Makefile.local
28
29 # Now smash together user's values with our extra values
30 override CFLAGS += $(WARN_CFLAGS) $(extra_cflags)
31 override CXXFLAGS += $(WARN_CXXFLAGS) $(extra_cflags) $(extra_cxxflags)
32
33 override LDFLAGS += \
34         $(shell pkg-config --libs glib-2.0 gmime-2.4 talloc) \
35         $(shell xapian-config --libs)
36
37 all: notmuch notmuch.1.gz
38
39 # Before including any other Makefile fragments, get settings from the
40 # output of configure
41 Makefile.config: configure
42         ./configure
43
44 include Makefile.config
45
46 include lib/Makefile.local
47 include compat/Makefile.local
48 include Makefile.local
49
50 # The user has not set any verbosity, default to quiet mode and inform the
51 # user how to enable verbose compiles.
52 ifeq ($(V),)
53 quiet_DOC := "Use \"$(MAKE) V=1\" to see the verbose compile lines.\n"
54 quiet = @printf $(quiet_DOC)$(eval quiet_DOC:=)"  $1    $@\n"; $($1)
55 endif
56 # The user has explicitly enabled quiet compilation.
57 ifeq ($(V),0)
58 quiet = @printf "  $1   $@\n"; $($1)
59 endif
60 # Otherwise, print the full command line.
61 quiet ?= $($1)
62
63 %.o: %.cc $(all_deps)
64         $(call quiet,CXX) -c $(CXXFLAGS) $< -o $@
65
66 %.o: %.c $(all_deps)
67         $(call quiet,CC) -c $(CFLAGS) $< -o $@
68
69 %.elc: %.el
70         $(call quiet,EMACS) -batch -f batch-byte-compile $<
71
72 .deps/%.d: %.c $(all_deps)
73         @set -e; rm -f $@; mkdir -p $$(dirname $@) ; \
74         $(CC) -M $(CPPFLAGS) $(CFLAGS) $< > $@.$$$$; \
75         sed 's,'$$(basename $*)'\.o[ :]*,$*.o $@ : ,g' < $@.$$$$ > $@; \
76         rm -f $@.$$$$
77
78 .deps/%.d: %.cc $(all_deps)
79         @set -e; rm -f $@; mkdir -p $$(dirname $@) ; \
80         $(CXX) -M $(CPPFLAGS) $(CXXFLAGS) $< > $@.$$$$; \
81         sed 's,'$$(basename $*)'\.o[ :]*,$*.o $@ : ,g' < $@.$$$$ > $@; \
82         rm -f $@.$$$$
83
84 DEPS := $(SRCS:%.c=.deps/%.d)
85 DEPS := $(DEPS:%.cc=.deps/%.d)
86 -include $(DEPS)
87
88 .PHONY : clean
89 clean:
90         rm -f $(CLEAN); rm -rf .deps