]> git.notmuchmail.org Git - notmuch/blob - Makefile
0411cbbed663c933fad48d434d9168ea4508995e
[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 flags that we will append to whatever the user set.
6 # These aren't intended for the user to manipulate.
7 extra_cflags := $(shell pkg-config --cflags glib-2.0 gmime-2.4 talloc)
8 extra_cxxflags := $(shell xapian-config --cxxflags)
9
10 emacs_lispdir := $(shell pkg-config emacs --variable sitepkglispdir)
11 # Hard-code if this system doesn't have an emacs.pc file
12 ifeq ($(emacs_lispdir),)
13         emacs_lispdir = $(prefix)/share/site-lisp
14 endif
15
16 # Now smash together user's values with our extra values
17 override CFLAGS += $(WARN_FLAGS) $(extra_cflags)
18 override CXXFLAGS += $(WARN_FLAGS) $(extra_cflags) $(extra_cxxflags)
19
20 override LDFLAGS += \
21         $(shell pkg-config --libs glib-2.0 gmime-2.4 talloc) \
22         $(shell xapian-config --libs)
23
24 # Include our local Makefile.local first so that its first target is default
25 include Makefile.local
26 include lib/Makefile.local
27
28 # And get user settings from the output of configure
29 include Makefile.config
30
31 %.o: %.cc
32         $(CXX) -c $(CFLAGS) $(CXXFLAGS) $< -o $@
33
34 %.o: %.c
35         $(CC) -c $(CFLAGS) $< -o $@
36
37 %.elc: %.el
38         emacs -batch -f batch-byte-compile $<
39
40 .deps/%.d: %.c
41         @set -e; rm -f $@; mkdir -p $$(dirname $@) ; \
42         $(CC) -M $(CPPFLAGS) $(CFLAGS) $< > $@.$$$$; \
43         sed 's,'$$(basename $*)'\.o[ :]*,$*.o $@ : ,g' < $@.$$$$ > $@; \
44         rm -f $@.$$$$
45
46 .deps/%.d: %.cc
47         @set -e; rm -f $@; mkdir -p $$(dirname $@) ; \
48         $(CXX) -M $(CPPFLAGS) $(CXXFLAGS) $< > $@.$$$$; \
49         sed 's,'$$(basename $*)'\.o[ :]*,$*.o $@ : ,g' < $@.$$$$ > $@; \
50         rm -f $@.$$$$
51
52 DEPS := $(SRCS:%.c=.deps/%.d)
53 DEPS := $(DEPS:%.cc=.deps/%.d)
54 -include $(DEPS)
55
56 clean:
57         rm -f $(CLEAN); rm -rf .deps