contrib/ksmtpproxy: SMTP proxy to ask account password in between sending mail
[navymail.git] / Makefile
blob55d49115ab4ebc426a4a9b700e344c58817a2051
1 # make script to build navymail
2 # Copyright (C) 2011 Kirill Smelkov <kirr@navytux.spb.ru>
3 all :
5 SPATCH := spatch
7 # don't delete intermediate targets
8 .SECONDARY:
11 # >>> decide early, whether we are doing a clean-style target
12 __cleaning := $(filter clean mrproper,$(MAKECMDGOALS))
13 ifneq ($(__cleaning),)
14 # if cleaning, ensure there is no other targets besides clean
15 ifneq ($(filter-out $(__cleaning),$(MAKECMDGOALS)),)
16 $(error E: target(s) "$(filter-out $(__cleaning),$(MAKECMDGOALS))" \
17 conflict with "$(__cleaning)")
18 endif
19 endif
22 # >>> for pretty build output
23 ifeq ($(V),)
24 Q := @
25 Qsubdir := --no-print-directory
26 Qspatch := -very_quiet
28 QAUTOCONF = @echo ' ' AUTOCONF $@;
29 QCONFIGURE = @echo ' ' CONFIGURE...;
30 QRECONFIGURE = @echo ' ' RECONFIGURE...;
31 QCONFACTIVATE = @echo ' ' GEN $@ '(+ friends)';
33 QARtweak = @echo ' ' ARtweak $@;
34 QSPATCH = @echo ' ' COCCI $@;
35 QCLEAN = @echo ' ' CLEAN;
36 QMRPROPER = @echo ' ' MRPROPER;
37 endif
39 # cocci: don't show diff until requested
40 ifeq ($(VCOCCI),)
41 Qspatch += -no_show_diff
42 else
43 # drop -very_quiet on VCOCCI=1 and automatically show diff
44 Qspatch :=
45 endif
49 # >>> before building anything, load configure findings, reconfiguring if needed
51 # NOTE configure dependencies have to be listed here explicitely
52 configure: configure.ac scripts/mk/pkg.m4
53 $(QAUTOCONF)autoconf --warnings=all
54 config.status: configure
55 $(if $(wildcard $@),\
56 $(QRECONFIGURE)./config.status --recheck,\
57 $(QCONFIGURE)./configure)
59 ifeq ($(__cleaning),)
60 include .config.mk.autogen
61 .config.mk.autogen : config.status .config.mk.in
62 $(QCONFACTIVATE)./config.status
63 endif
65 # local build tweaks could go here
66 -include .config.mk
70 # >>> then, before building navymail, (re-)build Git and import build variables from its build system
72 ifeq ($(__cleaning),)
73 git-targets := libgit.a
74 # test depends on git targets, without which git's test-lib.sh won't run
75 # TODO test-chmtime -> test-chmtime$X
76 git-targets += GIT-BUILD-OPTIONS test-chmtime
78 # also test needs git/templates/blt which is put directly into recipe
80 # reconfigure goes first
81 .config.mk.git: | .config.mk.autogen
82 endif
84 # XXX unfortunately .PHONY makefiles are not re-read, so we have to do dirty
85 # tricks with MAKE_RESTARTS instead -- see bugs.debian.org/614916
86 # .PHONY: .config.mk.git
87 ifeq ($(MAKE_RESTARTS),)
88 # touch trick is needed to tell make to rebuild it without initial warning
89 # reset mtime only on first make pass
90 $(shell touch -t 197001020101 .config.mk.git)
91 .config.mk.git : . # mtime of anything should be after epoch
92 endif
94 .config.mk.git:
95 $(Q)$(MAKE) $(Qsubdir) -C git/ -f ../scripts/mk/gitmk-proxy.mk $(git-targets) __export __export-file=../$@
96 ifeq ($(__cleaning),)
97 $(Q)$(MAKE) $(Qsubdir) -C git/templates
98 endif
100 include .config.mk.git
104 # >>> now let's build navymail
106 CPPFLAGS:= -Igit/ -Iinclude/
107 CC := $(GIT_CC)
108 CFLAGS := $(GIT_ALL_CFLAGS) $(FUSE_CFLAGS)
109 # lib.a -> git/lib.a , but -lsomething stays the same
110 GIT_LIBS:= $(foreach _,$(GIT_LIBS),$(if $(filter -%,$_),$_,git/$_))
111 X := $(GIT_X)
112 QUIET_CC = $(GIT_QUIET_CC)
116 all : navymail$X
118 # libgit.a is tweaked a bit with here-compiled code
119 GIT_LIBS_wo_libgit := $(filter-out git/libgit.a,$(GIT_LIBS))
120 fromgit/libgit.a: git/libgit.a fromgit/help.o fromgit/exec_cmd.o
121 $(QARtweak)Atmp=`mktemp $@.XXXXXX.a` &&\
122 cp $< $$Atmp &&\
123 ar r $$Atmp $(wordlist 2,$(words $+),$+) &&\
124 mv -f $$Atmp $@
126 navymail$X: navymail.o export.o gbox-walk.o fs.o fromgit/builtin/help.o compat/progexe.o fromgit/libgit.a
127 $(QUIET_CC)$(CC) $(CFLAGS) -o $@ $^ $(GIT_LDFLAGS) $(GIT_LIBS_wo_libgit) $(FUSE_LIBS)
129 # TODO automatically extract dependencies on compile
130 %.o : %.c
131 $(QUIET_CC)$(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $<
134 navymail.o : fromgit/git.c
136 # NOTE -no_includes so that it does not modify .h
137 # XXX -no_loops so that it does not take forever...
138 # XXX .cocci files can't include other .cocci (only .iso) so we do "includes"
139 # manually via generating .cocci+
140 fromgit/%.c : git/%.c fromgit/%.cocci fromgit/common.cocci
141 $(Q)cat fromgit/$*.cocci fromgit/common.cocci > fromgit/$*.cocci+
142 $(QSPATCH) $(SPATCH) $(Qspatch) -no_loops -no_includes -sp_file fromgit/$*.cocci+ -o $@ $<
145 clean :
146 $(QCLEAN)$(RM) \
147 navymail \
148 fromgit/*.cocci+ fromgit/builtin/*.cocci+ \
149 *.o fromgit/*.[coa] fromgit/builtin/*.[co] compat/*.o \
150 .config.mk.git
152 mrproper: clean
153 $(QMRPROPER)$(RM) \
154 configure config.status config.log .config.mk.autogen && \
155 $(MAKE) -C git/ clean
159 test : navymail$X
160 $(Q)$(MAKE) $(Qsubdir) -C t/