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 include .config.mk.autogen
61 .config.mk.autogen
: config.status .config.mk.in
62 $(QCONFACTIVATE
).
/config.status
65 # local build tweaks could go here
70 # >>> then, before building navymail, (re-)build Git and import build variables from its build system
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
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
95 $(Q
)$(MAKE
) $(Qsubdir
) -C git
/ -f ..
/scripts
/mk
/gitmk-proxy.mk
$(git-targets
) __export __export-file
=..
/$@
97 $(Q
)$(MAKE
) $(Qsubdir
) -C git
/templates
100 include .config.mk.git
104 # >>> now let's build navymail
106 CPPFLAGS
:= -Igit
/ -Iinclude
/
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
/$_))
112 QUIET_CC
= $(GIT_QUIET_CC
)
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` &&\
123 ar r
$$Atmp $(wordlist
2,$(words $+),$+) &&\
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
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
$@
$<
148 fromgit
/*.cocci
+ fromgit
/builtin
/*.cocci
+ \
149 *.o fromgit
/*.
[coa
] fromgit
/builtin
/*.
[co] compat
/*.o \
154 configure config.status config.log .config.mk.autogen
&& \
155 $(MAKE
) -C git
/ clean
160 $(Q
)$(MAKE
) $(Qsubdir
) -C t
/