contrib/ksmtpproxy: Fix typo
[navymail.git] / Makefile
blobd66342e4e893aa534586dfb9b48d29f4e3a3ca72
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 # rebuild .config.mk.autogen without initial warning
61 ifeq ($(wildcard .config.mk.autogen),)
62 $(shell touch -t 197001020101 .config.mk.autogen)
63 endif
64 include .config.mk.autogen
65 .config.mk.autogen : config.status .config.mk.in
66 $(QCONFACTIVATE)./config.status
67 endif
69 # local build tweaks could go here
70 -include .config.mk
74 # >>> then, before building navymail, (re-)build Git and import build variables from its build system
76 ifeq ($(__cleaning),)
77 git-targets := libgit.a
78 # test depends on git targets, without which git's test-lib.sh won't run
79 # TODO test-chmtime -> test-chmtime$X
80 git-targets += GIT-BUILD-OPTIONS test-chmtime
82 # also test needs git/templates/blt which is put directly into recipe
84 # reconfigure goes first
85 .config.mk.git: | .config.mk.autogen
86 endif
88 # XXX unfortunately .PHONY makefiles are not re-read, so we have to do dirty
89 # tricks with MAKE_RESTARTS instead -- see bugs.debian.org/614916
90 # .PHONY: .config.mk.git
91 ifeq ($(MAKE_RESTARTS),)
92 # touch trick is needed to tell make to rebuild it without initial warning
93 # reset mtime only on first make pass
94 $(shell touch -t 197001020101 .config.mk.git)
95 .config.mk.git : . # mtime of anything should be after epoch
96 endif
98 .config.mk.git:
99 $(Q)$(MAKE) $(Qsubdir) -C git/ -f ../scripts/mk/gitmk-proxy.mk $(git-targets) __export __export-file=../$@
100 ifeq ($(__cleaning),)
101 $(Q)$(MAKE) $(Qsubdir) -C git/templates
102 endif
104 include .config.mk.git
108 # >>> now let's build navymail
110 CPPFLAGS:= -Igit/ -Iinclude/
111 CC := $(GIT_CC)
112 CFLAGS := $(GIT_ALL_CFLAGS) $(FUSE_CFLAGS)
113 # lib.a -> git/lib.a , but -lsomething stays the same
114 GIT_LIBS:= $(foreach _,$(GIT_LIBS),$(if $(filter -%,$_),$_,git/$_))
115 X := $(GIT_X)
116 QUIET_CC = $(GIT_QUIET_CC)
120 all : navymail$X
122 # libgit.a is tweaked a bit with here-compiled code
123 GIT_LIBS_wo_libgit := $(filter-out git/libgit.a,$(GIT_LIBS))
124 fromgit/libgit.a: git/libgit.a fromgit/help.o fromgit/exec_cmd.o
125 $(QARtweak)Atmp=`mktemp $@.XXXXXX.a` &&\
126 cp $< $$Atmp &&\
127 ar r $$Atmp $(wordlist 2,$(words $+),$+) &&\
128 mv -f $$Atmp $@
130 navymail$X: navymail.o export.o gbox-walk.o fs.o mbox-walk.o import.o fromgit/builtin/help.o compat/progexe.o fromgit/libgit.a
131 $(QUIET_CC)$(CC) $(CFLAGS) -o $@ $^ $(GIT_LDFLAGS) $(GIT_LIBS_wo_libgit) $(FUSE_LIBS)
133 # TODO automatically extract dependencies on compile
134 %.o : %.c
135 $(QUIET_CC)$(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $<
138 navymail.o : fromgit/git.c
140 # NOTE -no_includes so that it does not modify .h
141 # XXX -no_loops so that it does not take forever...
142 # XXX .cocci files can't include other .cocci (only .iso) so we do "includes"
143 # manually via generating .cocci+
144 fromgit/%.c : git/%.c fromgit/%.cocci fromgit/common.cocci
145 $(Q)cat fromgit/$*.cocci fromgit/common.cocci > fromgit/$*.cocci+
146 $(QSPATCH) $(SPATCH) $(Qspatch) -no_loops -no_includes -sp_file fromgit/$*.cocci+ -o $@ $<
149 clean :
150 $(QCLEAN)$(RM) \
151 navymail \
152 fromgit/*.cocci+ fromgit/builtin/*.cocci+ \
153 *.o fromgit/*.[coa] fromgit/builtin/*.[co] compat/*.o \
154 .config.mk.git
156 mrproper: clean
157 $(QMRPROPER)$(RM) \
158 configure config.status config.log .config.mk.autogen && \
159 $(MAKE) -C git/ clean
163 test : navymail$X
164 $(Q)$(MAKE) $(Qsubdir) -C t/