1 # Default FLAGS, (can be overridden by user such as "make CFLAGS=-O2")
2 WARN_FLAGS=-Wall -Wextra -Wmissing-declarations -Wwrite-strings -Wswitch-enum
5 # Additional programs that are used during the compilation process.
7 # Lowercase to avoid clash with GZIP environment variable for passing
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)
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
22 bash_completion_dir = /etc/bash_completion.d
24 all_deps = Makefile Makefile.local Makefile.config \
25 lib/Makefile lib/Makefile.local
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)
32 $(shell pkg-config --libs glib-2.0 gmime-2.4 talloc) \
33 $(shell xapian-config --libs)
35 all: notmuch notmuch.1.gz
37 # Before including any other Makefile fragments, get settings from the
39 Makefile.config: configure
42 include Makefile.config
44 include lib/Makefile.local
45 include compat/Makefile.local
46 include Makefile.local
48 # The user has not set any verbosity, default to quiet mode and inform the
49 # user how to enable verbose compiles.
51 quiet_DOC := "Use \"$(MAKE) V=1\" to see the verbose compile lines.\n"
52 quiet = @printf $(quiet_DOC)$(eval quiet_DOC:=)" $1 $@\n"; $($1)
54 # The user has explicitly enabled quiet compilation.
56 quiet = @printf " $1 $@\n"; $($1)
58 # Otherwise, print the full command line.
62 $(call quiet,CXX) -c $(CXXFLAGS) $< -o $@
65 $(call quiet,CC) -c $(CFLAGS) $< -o $@
68 $(call quiet,EMACS) -batch -f batch-byte-compile $<
70 .deps/%.d: %.c $(all_deps)
71 @set -e; rm -f $@; mkdir -p $$(dirname $@) ; \
72 $(CC) -M $(CPPFLAGS) $(CFLAGS) $< > $@.$$$$; \
73 sed 's,'$$(basename $*)'\.o[ :]*,$*.o $@ : ,g' < $@.$$$$ > $@; \
76 .deps/%.d: %.cc $(all_deps)
77 @set -e; rm -f $@; mkdir -p $$(dirname $@) ; \
78 $(CXX) -M $(CPPFLAGS) $(CXXFLAGS) $< > $@.$$$$; \
79 sed 's,'$$(basename $*)'\.o[ :]*,$*.o $@ : ,g' < $@.$$$$ > $@; \
82 DEPS := $(SRCS:%.c=.deps/%.d)
83 DEPS := $(DEPS:%.cc=.deps/%.d)
88 rm -f $(CLEAN); rm -rf .deps