]> git.notmuchmail.org Git - notmuch/blob - Makefile
ae0f99120cc59c459c3b8d0e4819611e7c8b5c62
[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 all_deps = Makefile Makefile.local Makefile.config \
23                    lib/Makefile lib/Makefile.local
24
25 # Now smash together user's values with our extra values
26 override CFLAGS += $(WARN_FLAGS) $(extra_cflags)
27 override CXXFLAGS += $(WARN_FLAGS) $(extra_cflags) $(extra_cxxflags)
28
29 override LDFLAGS += \
30         $(shell pkg-config --libs glib-2.0 gmime-2.4 talloc) \
31         $(shell xapian-config --libs)
32
33 # Include our local Makefile.local first so that its first target is default
34 include Makefile.local
35 include lib/Makefile.local
36
37 # And get user settings from the output of configure
38 Makefile.config: configure
39         ./configure
40
41 include Makefile.config
42
43 # The user has not set any verbosity, default to quiet mode and inform the
44 # user how to enable verbose compiles.
45 ifeq ($(V),)
46 quiet_DOC := "Use \"$(MAKE) V=1\" to see the verbose compile lines.\n"
47 quiet = @echo $(quiet_DOC)$(eval quiet_DOC:=)"  $1      $@"; $($1)
48 endif
49 # The user has explicitly enabled quiet compilation.
50 ifeq ($(V),0)
51 quiet = @echo "  $1     $@"; $($1)
52 endif
53 # Otherwise, print the full command line.
54 quiet ?= $($1)
55
56 %.o: %.cc $(all_deps)
57         $(call quiet,CXX) -c $(CXXFLAGS) $< -o $@
58
59 %.o: %.c $(all_deps)
60         $(call quiet,CC) -c $(CFLAGS) $< -o $@
61
62 %.elc: %.el
63         $(call quiet,EMACS) -batch -f batch-byte-compile $<
64
65 .deps/%.d: %.c $(all_deps)
66         @set -e; rm -f $@; mkdir -p $$(dirname $@) ; \
67         $(CC) -M $(CPPFLAGS) $(CFLAGS) $< > $@.$$$$; \
68         sed 's,'$$(basename $*)'\.o[ :]*,$*.o $@ : ,g' < $@.$$$$ > $@; \
69         rm -f $@.$$$$
70
71 .deps/%.d: %.cc $(all_deps)
72         @set -e; rm -f $@; mkdir -p $$(dirname $@) ; \
73         $(CXX) -M $(CPPFLAGS) $(CXXFLAGS) $< > $@.$$$$; \
74         sed 's,'$$(basename $*)'\.o[ :]*,$*.o $@ : ,g' < $@.$$$$ > $@; \
75         rm -f $@.$$$$
76
77 DEPS := $(SRCS:%.c=.deps/%.d)
78 DEPS := $(DEPS:%.cc=.deps/%.d)
79 -include $(DEPS)
80
81 .PHONY : clean
82 clean:
83         rm -f $(CLEAN); rm -rf .deps