1 # make script to build navymail
2 # Copyright (C) 2011 Kirill Smelkov <kirr@navytux.spb.ru>
7 # don't delete intermediate targets
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)")
22 # >>> for pretty build output
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
;
39 # cocci: don't show diff until requested
41 Qspatch
+= -no_show_diff
43 # drop -very_quiet on VCOCCI=1 and automatically show diff
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
56 $(QRECONFIGURE
).
/config.status
--recheck
,\
57 $(QCONFIGURE
).
/configure
)
60 # rebuild .config.mk.autogen without initial warning
61 ifeq ($(wildcard .config.mk.autogen
),)
62 $(shell touch
-t
197001020101 .config.mk.autogen
)
64 include .config.mk.autogen
65 .config.mk.autogen
: config.status .config.mk.in
66 $(QCONFACTIVATE
).
/config.status
69 # local build tweaks could go here
74 # >>> then, before building navymail, (re-)build Git and import build variables from its build system
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
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
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
104 include .config.mk.git
108 # >>> now let's build navymail
110 CPPFLAGS
:= -Igit
/ -Iinclude
/
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
/$_))
116 QUIET_CC
= $(GIT_QUIET_CC
)
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` &&\
127 ar r
$$Atmp $(wordlist
2,$(words $+),$+) &&\
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
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
$@
$<
152 fromgit
/*.cocci
+ fromgit
/builtin
/*.cocci
+ \
153 *.o fromgit
/*.
[coa
] fromgit
/builtin
/*.
[co] compat
/*.o \
158 configure config.status config.log .config.mk.autogen
&& \
159 $(MAKE
) -C git
/ clean
164 $(Q
)$(MAKE
) $(Qsubdir
) -C t
/