]> git.notmuchmail.org Git - notmuch/blob - Makefile.local
Makefiles: Eliminate shell for loops in rule definitions.
[notmuch] / Makefile.local
1 # Get settings from the output of configure by running it to generate
2 # Makefile.config if it doesn't exist yet. And add Makefile.config to
3 # our global dependency list.
4 include Makefile.config
5 global_deps += Makefile.config
6 Makefile.config: configure
7         @echo ""
8         @echo "Note: Calling ./configure with no command-line arguments. This is often fine,"
9         @echo "      but if you want to specify any arguments (such as an alternate prefix"
10         @echo "      into which to install), call ./configure explicitly and then make again."
11         @echo "      See \"./configure --help\" for more details."
12         @echo ""
13         ./configure
14
15 # Sub-directory Makefile.local fragments can append to these variables
16 # to have directory-specific cflags as necessary.
17 extra_cflags :=
18 extra_cxxflags :=
19
20 # Smash together user's values with our extra values
21 FINAL_CFLAGS = $(CFLAGS) $(WARN_CFLAGS) $(CONFIGURE_CFLAGS) $(extra_cflags)
22 FINAL_CXXFLAGS = $(CXXFLAGS) $(WARN_CXXFLAGS) $(CONFIGURE_CXXFLAGS) $(extra_cflags) $(extra_cxxflags)
23 FINAL_LDFLAGS = $(LDFLAGS) $(CONFIGURE_LDFLAGS)
24
25 all: notmuch notmuch.1.gz
26 ifeq ($(MAKECMDGOALS),)
27         @echo ""
28         @echo "Compilation of notmuch is now complete. You can install notmuch with:"
29         @echo ""
30         @echo " make install"
31         @echo ""
32         @echo "Note that depending on the prefix to which you are installing"
33         @echo "you may need root permission (such as \"sudo make install\")."
34         @echo "See \"./configure --help\" for help on setting an alternate prefix."
35 endif
36
37 # The user has not set any verbosity, default to quiet mode and inform the
38 # user how to enable verbose compiles.
39 ifeq ($(V),)
40 quiet_DOC := "Use \"$(MAKE) V=1\" to see the verbose compile lines.\n"
41 quiet = @printf $(quiet_DOC)$(eval quiet_DOC:=)"  $1 $2 $@\n"; $($1)
42 endif
43 # The user has explicitly enabled quiet compilation.
44 ifeq ($(V),0)
45 quiet = @printf "  $1   $@\n"; $($1)
46 endif
47 # Otherwise, print the full command line.
48 quiet ?= $($1)
49
50 %.o: %.cc $(global_deps)
51         $(call quiet,CXX,$(CXXFLAGS)) -c $(FINAL_CXXFLAGS) $< -o $@
52
53 %.o: %.c $(global_deps)
54         $(call quiet,CC,$(CFLAGS)) -c $(FINAL_CFLAGS) $< -o $@
55
56 %.elc: %.el
57         $(call quiet,EMACS) -batch -f batch-byte-compile $<
58
59 .deps/%.d: %.c $(global_deps)
60         @set -e; rm -f $@; mkdir -p $$(dirname $@) ; \
61         $(CC) -M $(CPPFLAGS) $(FINAL_CFLAGS) $< > $@.$$$$ 2>/dev/null ; \
62         sed 's,'$$(basename $*)'\.o[ :]*,$*.o $@ : ,g' < $@.$$$$ > $@; \
63         rm -f $@.$$$$
64
65 .deps/%.d: %.cc $(global_deps)
66         @set -e; rm -f $@; mkdir -p $$(dirname $@) ; \
67         $(CXX) -M $(CPPFLAGS) $(FINAL_CXXFLAGS) $< > $@.$$$$ 2>/dev/null ; \
68         sed 's,'$$(basename $*)'\.o[ :]*,$*.o $@ : ,g' < $@.$$$$ > $@; \
69         rm -f $@.$$$$
70
71 DEPS := $(SRCS:%.c=.deps/%.d)
72 DEPS := $(DEPS:%.cc=.deps/%.d)
73 -include $(DEPS)
74
75 .PHONY : clean
76 clean:
77         rm -f $(CLEAN); rm -rf .deps
78
79 notmuch_client_srcs =           \
80         $(notmuch_compat_srcs)  \
81         debugger.c              \
82         gmime-filter-reply.c    \
83         notmuch.c               \
84         notmuch-config.c        \
85         notmuch-count.c         \
86         notmuch-dump.c          \
87         notmuch-new.c           \
88         notmuch-reply.c         \
89         notmuch-restore.c       \
90         notmuch-search.c        \
91         notmuch-search-tags.c   \
92         notmuch-setup.c         \
93         notmuch-show.c          \
94         notmuch-tag.c           \
95         notmuch-time.c          \
96         query-string.c          \
97         show-message.c          \
98         json.c
99
100 notmuch_client_modules = $(notmuch_client_srcs:.c=.o)
101 notmuch: $(notmuch_client_modules) lib/libnotmuch.so
102         $(call quiet,CC,$(LDFLAGS)) -Llib -lnotmuch $(filter-out lib/libnotmuch.so,$^) $(FINAL_LDFLAGS) -o $@
103
104 notmuch.1.gz: notmuch.1
105         $(call quiet,gzip) --stdout $^ > $@
106
107 install: all notmuch.1.gz
108         install -d $(DESTDIR)$(prefix)/bin/
109         install -d $(DESTDIR)$(libdir)/
110         install -d $(DESTDIR)$(prefix)/include/
111         install -d $(DESTDIR)$(prefix)/share/man/man1
112         install notmuch $(DESTDIR)$(prefix)/bin/
113         install -m0644 notmuch.1.gz $(DESTDIR)$(prefix)/share/man/man1/
114 ifeq ($(MAKECMDGOALS), install)
115         @echo ""
116         @echo "Notmuch is now installed."
117         @echo ""
118         @echo "You may now want to install additional components to support using notmuch"
119         @echo "together with other software packages:"
120         @echo ""
121         @echo " make install-emacs"
122         @echo " make install-bash"
123         @echo " make install-zsh"
124         @echo ""
125 endif
126
127 install-desktop:
128         install -d $(DESTDIR)$(desktop_dir)
129         desktop-file-install --mode 0644 --dir $(DESTDIR)$(desktop_dir) notmuch.desktop
130
131 install-bash:
132         install -d $(DESTDIR)$(bash_completion_dir)
133         install -m0644 contrib/notmuch-completion.bash \
134                 $(DESTDIR)$(bash_completion_dir)/notmuch
135
136 install-zsh:
137         install -d $(DESTDIR)$(zsh_completion_dir)
138         install -m0644 contrib/notmuch-completion.zsh \
139                 $(DESTDIR)$(zsh_completion_dir)/notmuch
140
141 SRCS  := $(SRCS) $(notmuch_client_srcs)
142 CLEAN := $(CLEAN) notmuch $(notmuch_client_modules) notmuch.elc notmuch.1.gz