]> git.notmuchmail.org Git - notmuch/blob - Makefile
c0b1b3fa60057cdc50b8188cdcaad5b39c7c7368
[notmuch] / Makefile
1 # Default FLAGS, (can be overridden by user such as "make CFLAGS=-O2")
2 WARN_FLAGS=-Wall -Wextra -Wmissing-declarations -Wwrite-strings -Wswitch-enum
3 CFLAGS=-O2
4
5 # Additional programs that are used during the compilation process.
6 EMACS ?= emacs
7 # Lowercase to avoid clash with GZIP environment variable for passing
8 # arguments to gzip.
9 gzip = gzip
10
11 # Additional flags that we will append to whatever the user set.
12 # These aren't intended for the user to manipulate.
13 extra_cflags := $(shell pkg-config --cflags glib-2.0 gmime-2.4 talloc)
14 extra_cxxflags := $(shell xapian-config --cxxflags)
15
16 emacs_lispdir := $(shell pkg-config emacs --variable sitepkglispdir)
17 # Hard-code if this system doesn't have an emacs.pc file
18 ifeq ($(emacs_lispdir),)
19         emacs_lispdir = $(prefix)/share/emacs/site-lisp
20 endif
21
22 bash_completion_dir = /etc/bash_completion.d
23
24 all_deps = Makefile Makefile.local Makefile.config \
25                    lib/Makefile lib/Makefile.local
26
27 # Now smash together user's values with our extra values
28 override CFLAGS += $(WARN_FLAGS) $(extra_cflags)
29 override CXXFLAGS += $(WARN_FLAGS) $(extra_cflags) $(extra_cxxflags)
30
31 override LDFLAGS += \
32         $(shell pkg-config --libs glib-2.0 gmime-2.4 talloc) \
33         $(shell xapian-config --libs)
34
35 all: notmuch notmuch.1.gz
36
37 include lib/Makefile.local
38 include compat/Makefile.local
39 include Makefile.local
40
41 # And get user settings from the output of configure
42 Makefile.config: configure
43         ./configure
44
45 include Makefile.config
46
47 # The user has not set any verbosity, default to quiet mode and inform the
48 # user how to enable verbose compiles.
49 ifeq ($(V),)
50 quiet_DOC := "Use \"$(MAKE) V=1\" to see the verbose compile lines.\n"
51 quiet = @echo $(quiet_DOC)$(eval quiet_DOC:=)"  $1      $@"; $($1)
52 endif
53 # The user has explicitly enabled quiet compilation.
54 ifeq ($(V),0)
55 quiet = @echo "  $1     $@"; $($1)
56 endif
57 # Otherwise, print the full command line.
58 quiet ?= $($1)
59
60 %.o: %.cc $(all_deps)
61         $(call quiet,CXX) -c $(CXXFLAGS) $< -o $@
62
63 %.o: %.c $(all_deps)
64         $(call quiet,CC) -c $(CFLAGS) $< -o $@
65
66 %.elc: %.el
67         $(call quiet,EMACS) -batch -f batch-byte-compile $<
68
69 .deps/%.d: %.c $(all_deps)
70         @set -e; rm -f $@; mkdir -p $$(dirname $@) ; \
71         $(CC) -M $(CPPFLAGS) $(CFLAGS) $< > $@.$$$$; \
72         sed 's,'$$(basename $*)'\.o[ :]*,$*.o $@ : ,g' < $@.$$$$ > $@; \
73         rm -f $@.$$$$
74
75 .deps/%.d: %.cc $(all_deps)
76         @set -e; rm -f $@; mkdir -p $$(dirname $@) ; \
77         $(CXX) -M $(CPPFLAGS) $(CXXFLAGS) $< > $@.$$$$; \
78         sed 's,'$$(basename $*)'\.o[ :]*,$*.o $@ : ,g' < $@.$$$$ > $@; \
79         rm -f $@.$$$$
80
81 DEPS := $(SRCS:%.c=.deps/%.d)
82 DEPS := $(DEPS:%.cc=.deps/%.d)
83 -include $(DEPS)
84
85 .PHONY : clean
86 clean:
87         rm -f $(CLEAN); rm -rf .deps