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