1 # Default FLAGS, (can be overridden by user such as "make CFLAGS=-g")
4 WARN_CXXFLAGS=-Wall -Wextra -Wwrite-strings -Wswitch-enum
5 WARN_CFLAGS=$(WARN_CXXFLAGS) -Wmissing-declarations
7 # Additional programs that are used during the compilation process.
9 # Lowercase to avoid clash with GZIP environment variable for passing
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)
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
24 bash_completion_dir = /etc/bash_completion.d
26 all_deps = Makefile Makefile.local Makefile.config \
27 lib/Makefile lib/Makefile.local
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)
34 $(shell pkg-config --libs glib-2.0 gmime-2.4 talloc) \
35 $(shell xapian-config --libs)
37 all: notmuch notmuch.1.gz
39 # Before including any other Makefile fragments, get settings from the
41 Makefile.config: configure
44 include Makefile.config
46 include lib/Makefile.local
47 include compat/Makefile.local
48 include Makefile.local
50 # The user has not set any verbosity, default to quiet mode and inform the
51 # user how to enable verbose compiles.
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)
56 # The user has explicitly enabled quiet compilation.
58 quiet = @printf " $1 $@\n"; $($1)
60 # Otherwise, print the full command line.
64 $(call quiet,CXX) -c $(CXXFLAGS) $< -o $@
67 $(call quiet,CC) -c $(CFLAGS) $< -o $@
70 $(call quiet,EMACS) -batch -f batch-byte-compile $<
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' < $@.$$$$ > $@; \
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' < $@.$$$$ > $@; \
84 DEPS := $(SRCS:%.c=.deps/%.d)
85 DEPS := $(DEPS:%.cc=.deps/%.d)
90 rm -f $(CLEAN); rm -rf .deps