-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
213 lines (188 loc) · 7.31 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
#
#
# GLOBAL Makefile for FIASCO
# enviroment
DFLBUILDDIR := build
ALLBUILDDIR := build-all
RANDBUILDDIR := build-rand
TEMPLDIR := src/templates
MAKEFILETEMPL := $(TEMPLDIR)/Makefile.builddir.templ
MANSUBDIRS := man
INSTALLSUBDIRS := $(MANSUBDIRS)
CLEANSUBDIRS := $(MANSUBDIRS) $(wildcard $(DFLBUILDDIR))
CONFIG_FILE := $(TEMPLDIR)/globalconfig.out
TEST_TEMPLATES := $(patsubst $(CONFIG_FILE).%,%,$(wildcard $(CONFIG_FILE).*))
TEST_TEMPLATES := $(if $(TEMPLATE_FILTER),$(filter $(TEMPLATE_FILTER),$(TEST_TEMPLATES)),$(TEST_TEMPLATES))
DFL_TEMPLATE := ia32-1
PL ?= 1
getdir = $(shell \
bd="$(1)"; \
if [ "$${bd\#/}" = "$$bd" -a \
"$${bd\#*..}" = "$$bd" ]; then \
relp=".."; \
while [ "$${bd\#*/}" != "$$bd" ]; do \
relp="$$relp/.."; \
bd="$${bd\#*/}"; \
done; \
echo "$$relp"; \
else \
pwd; \
fi \
)
buildmakefile = mkdir -p "$(1)"; \
perl -p -i -e '$$s = "$(CURDIR)/src"; s/\@SRCDIR\@/$$s/' \
< $(MAKEFILETEMPL) > $(1)/Makefile
ifneq ($(strip $(B)),)
BUILDDIR := $(B)
endif
ifneq ($(strip $(BUILDDIR)),)
builddir:
@echo "Creating build directory \"$(BUILDDIR)\"..."
@if [ -e "$(BUILDDIR)" ]; then \
echo "Already exists, aborting."; \
exit 1; \
fi
@$(call buildmakefile,$(BUILDDIR))
@echo "done."
endif
ifneq ($(strip $(T)),)
this:
set -e; \
test -f $(TEMPLDIR)/globalconfig.out.$(T); \
bdir=T-$(DFLBUILDDIR)-$(T); \
rm -rf $$bdir; \
$(call buildmakefile,T-$(DFLBUILDDIR)-$(T)); \
cp $(TEMPLDIR)/globalconfig.out.$(T) $$bdir/globalconfig.out; \
$(MAKE) -C $$bdir
endif
$(DFLBUILDDIR): fiasco.builddir.create
$(MAKE) -C $@ -j$(PL)
all: fiasco man
clean cleanall:
set -e; for i in $(CLEANSUBDIRS); do $(MAKE) -C $$i $@; done
purge: cleanall
$(RM) -r $(DFLBUILDDIR)
man:
set -e; for i in $(MANSUBDIRS); do $(MAKE) -C $$i; done
fiasco.builddir.create:
[ -e $(DFLBUILDDIR)/Makefile ] || \
($(call buildmakefile,$(DFLBUILDDIR)))
[ -f $(DFLBUILDDIR)/globalconfig.out ] || { \
cp $(TEMPLDIR)/globalconfig.out.$(DFL_TEMPLATE) \
$(DFLBUILDDIR)/globalconfig.out; \
}
config $(filter config %config,$(MAKECMDGOALS)): fiasco.builddir.create
$(MAKE) -C $(DFLBUILDDIR) $@
fiasco: fiasco.builddir.create
$(MAKE) -C $(DFLBUILDDIR) -j$(PL)
checkall l4check:
error=0; \
$(RM) -r $(ALLBUILDDIR); \
for X in $(TEST_TEMPLATES); do \
echo -e "\n= Building configuration: $$X\n\n"; \
$(call buildmakefile,$(ALLBUILDDIR)/$$X); \
cp $(TEMPLDIR)/globalconfig.out.$$X \
$(ALLBUILDDIR)/$$X/globalconfig.out; \
if $(MAKE) -C $(ALLBUILDDIR)/$$X -j$(PL); then \
[ -z "$(KEEP_BUILD_DIRS)" ] && \
$(RM) -r $(ALLBUILDDIR)/$$X; \
else \
error=$$?; \
failed="$$failed $$X"; \
fi \
done; \
rmdir $(ALLBUILDDIR) >/dev/null 2>&1; \
[ "$$failed" ] && echo -e "\nFailed configurations:$$failed"; \
exit $$error;
checkallp:
$(RM) -r $(ALLBUILDDIR)
$(MAKE) dobuildparallel SHELL=bash
.PHONY: dobuildparallel checkallp
dobuildparallel: $(addprefix $(ALLBUILDDIR)/,$(TEST_TEMPLATES))
error=0; \
echo "======================================================"; \
for d in $(TEST_TEMPLATES); do \
if [ -e $(ALLBUILDDIR)/$$d/build.failed ]; then \
error=1; failed="$$failed $$d"; \
fi; \
done; \
for f in $$failed; do echo "====== Failed Build Log: $$f ======"; \
tail -60 $(ALLBUILDDIR)/$$f/build.log; \
done; \
rmdir $(ALLBUILDDIR) >/dev/null 2>&1; \
[ "$$failed" ] && echo -e "\nFailed configurations:$$failed"; \
exit $$error;
$(addprefix $(ALLBUILDDIR)/,$(TEST_TEMPLATES)):
$(call buildmakefile,$@)
cp $(TEMPLDIR)/globalconfig.out.$(patsubst $(ALLBUILDDIR)/%,%,$@) \
$@/globalconfig.out
$(MAKE) -C $@ 2>&1 | tee $@/build.log; \
if [ $${PIPESTATUS[0]} = 0 ]; \
then [ -z "$(KEEP_BUILD_DIRS)" ] && $(RM) -r $@; \
else echo $${PIPESTATUS[0]} > $@/build.failed; fi
list:
@echo "Templates:"
@echo $(TEST_TEMPLATES)
randcheck:
$(RM) -r $(RANDBUILDDIR); \
$(call buildmakefile,$(RANDBUILDDIR)/b); \
while true; do \
$(RM) $(RANDBUILDDIR)/b/globalconfig.out; \
$(MAKE) -C $(RANDBUILDDIR)/b randconfig; \
fn=$$(cat $(RANDBUILDDIR)/b/globalconfig.out \
| grep -e "^CONFIG_" | sort | sha1sum \
| cut -f1 -d\ ); \
if [ -e "ok-$$fn" -o -e "failed-$$fn" ]; then \
echo "Configuration $$fn already checked." \
continue; \
fi; \
if $(MAKE) -C $(RANDBUILDDIR)/b -j$(PL); then \
cp $(RANDBUILDDIR)/b/globalconfig.out \
$(RANDBUILDDIR)/ok-$$fn; \
else \
[ -n "$$STOP_ON_ERROR" ] && exit 1; \
cp -a $(RANDBUILDDIR)/b \
$(RANDBUILDDIR)/failed-$$fn; \
fi; \
done
randcheckstop:
$(MAKE) STOP_ON_ERROR=1 randcheck
randcheckagain:
for f in $(RANDBUILDDIR)/failed-*; do \
if $(MAKE) -C $$f -j$(PL); then \
$(RM) -rf $$f; \
else \
[ -n "$$STOP_ON_ERROR" ] && exit 1; \
fi \
done
randcheckagainstop:
$(MAKE) STOP_ON_ERROR=1 randcheckagain
help:
@echo
@echo "fiasco Builds the default configuration ($(DFL_TEMPLATE))"
@echo "T=template Build a certain configuration"
@echo "checkall Build all template configurations in one go"
@echo "list List templates"
@echo
@echo "config menuconfig xconfig oldconfig"
@echo " Configure kernel in \"$(DFLBUILDDIR)\""
@echo "$(DFLBUILDDIR) Build kernel in \"$(DFLBUILDDIR)\""
@echo "clean cleanall clean or cleanall in \"$(CLEANSUBDIRS)\""
@echo "purge cleanall, remove \"$(DFLBUILDDIR)\" and build helper"
@echo
@echo "Creating a custom kernel:"
@echo
@echo " Create a build directory with:"
@echo " make BUILDDIR=builddir"
@echo " Then build the kernel:"
@echo " cd builddir"
@echo " make config"
@echo " make"
@echo
@echo "Call \"make help\" in the build directory for more information on build targets."
@echo
@echo "Default target: $(DFLBUILDDIR)"
@echo
.PHONY: man install clean cleanall fiasco.builddir.create fiasco \
l4check checkall config oldconfig menuconfig nconfig xconfig \
randcheck randcheckstop help