3 # GLOBAL Makefile for FIASCO
7 ALLBUILDDIR := build-all
8 RANDBUILDDIR := build-rand
9 TEMPLDIR := src/templates
10 MAKEFILETEMPL := $(TEMPLDIR)/Makefile.builddir.templ
12 INSTALLSUBDIRS := $(MANSUBDIRS)
13 CLEANSUBDIRS := $(MANSUBDIRS) $(wildcard $(DFLBUILDDIR))
14 CONFIG_FILE := $(TEMPLDIR)/globalconfig.out
15 TEST_TEMPLATES := $(patsubst $(CONFIG_FILE).%,%,$(wildcard $(CONFIG_FILE).*))
16 TEST_TEMPLATES := $(if $(TEMPLATE_FILTER),$(filter $(TEMPLATE_FILTER),$(TEST_TEMPLATES)),$(TEST_TEMPLATES))
17 DFL_TEMPLATE := ia32-1
22 if [ "$${bd\#/}" = "$$bd" -a \
23 "$${bd\#*..}" = "$$bd" ]; then \
25 while [ "$${bd\#*/}" != "$$bd" ]; do \
35 buildmakefile = mkdir -p "$(1)"; \
36 perl -p -i -e '$$s = "$(CURDIR)/src"; s/\@SRCDIR\@/$$s/' \
37 < $(MAKEFILETEMPL) > $(1)/Makefile
39 ifneq ($(strip $(B)),)
42 ifneq ($(strip $(BUILDDIR)),)
44 @echo "Creating build directory \"$(BUILDDIR)\"..."
45 @if [ -e "$(BUILDDIR)" ]; then \
46 echo "Already exists, aborting."; \
49 @$(call buildmakefile,$(BUILDDIR))
53 ifneq ($(strip $(T)),)
56 test -f $(TEMPLDIR)/globalconfig.out.$(T); \
57 bdir=T-$(DFLBUILDDIR)-$(T); \
59 $(call buildmakefile,T-$(DFLBUILDDIR)-$(T)); \
60 cp $(TEMPLDIR)/globalconfig.out.$(T) $$bdir/globalconfig.out; \
64 $(DFLBUILDDIR): fiasco.builddir.create
70 set -e; for i in $(CLEANSUBDIRS); do $(MAKE) -C $$i $@; done
73 $(RM) -r $(DFLBUILDDIR)
76 set -e; for i in $(MANSUBDIRS); do $(MAKE) -C $$i; done
78 fiasco.builddir.create:
79 [ -e $(DFLBUILDDIR)/Makefile ] || \
80 ($(call buildmakefile,$(DFLBUILDDIR)))
81 [ -f $(DFLBUILDDIR)/globalconfig.out ] || { \
82 cp $(TEMPLDIR)/globalconfig.out.$(DFL_TEMPLATE) \
83 $(DFLBUILDDIR)/globalconfig.out; \
86 config $(filter config %config,$(MAKECMDGOALS)): fiasco.builddir.create
87 $(MAKE) -C $(DFLBUILDDIR) $@
89 fiasco: fiasco.builddir.create
90 $(MAKE) -C $(DFLBUILDDIR) -j$(PL)
94 $(RM) -r $(ALLBUILDDIR); \
95 for X in $(TEST_TEMPLATES); do \
96 echo -e "\n= Building configuration: $$X\n\n"; \
97 $(call buildmakefile,$(ALLBUILDDIR)/$$X); \
98 cp $(TEMPLDIR)/globalconfig.out.$$X \
99 $(ALLBUILDDIR)/$$X/globalconfig.out; \
100 if $(MAKE) -C $(ALLBUILDDIR)/$$X -j$(PL); then \
101 [ -z "$(KEEP_BUILD_DIRS)" ] && \
102 $(RM) -r $(ALLBUILDDIR)/$$X; \
105 failed="$$failed $$X"; \
108 rmdir $(ALLBUILDDIR) >/dev/null 2>&1; \
109 [ "$$failed" ] && echo -e "\nFailed configurations:$$failed"; \
113 $(RM) -r $(ALLBUILDDIR)
114 $(MAKE) dobuildparallel SHELL=bash
116 .PHONY: dobuildparallel checkallp
118 dobuildparallel: $(addprefix $(ALLBUILDDIR)/,$(TEST_TEMPLATES))
120 echo "======================================================"; \
121 for d in $(TEST_TEMPLATES); do \
122 if [ -e $(ALLBUILDDIR)/$$d/build.failed ]; then \
123 error=1; failed="$$failed $$d"; \
126 for f in $$failed; do echo "====== Failed Build Log: $$f ======"; \
127 tail -60 $(ALLBUILDDIR)/$$f/build.log; \
129 rmdir $(ALLBUILDDIR) >/dev/null 2>&1; \
130 [ "$$failed" ] && echo -e "\nFailed configurations:$$failed"; \
133 $(addprefix $(ALLBUILDDIR)/,$(TEST_TEMPLATES)):
134 $(call buildmakefile,$@)
135 cp $(TEMPLDIR)/globalconfig.out.$(patsubst $(ALLBUILDDIR)/%,%,$@) \
137 $(MAKE) -C $@ 2>&1 | tee $@/build.log; \
138 if [ $${PIPESTATUS[0]} = 0 ]; \
139 then [ -z "$(KEEP_BUILD_DIRS)" ] && $(RM) -r $@; \
140 else echo $${PIPESTATUS[0]} > $@/build.failed; fi
144 @echo $(TEST_TEMPLATES)
147 $(RM) -r $(RANDBUILDDIR); \
148 $(call buildmakefile,$(RANDBUILDDIR)/b); \
150 $(RM) $(RANDBUILDDIR)/b/globalconfig.out; \
151 $(MAKE) -C $(RANDBUILDDIR)/b randconfig; \
152 fn=$$(cat $(RANDBUILDDIR)/b/globalconfig.out \
153 | grep -e "^CONFIG_" | sort | sha1sum \
155 if [ -e "ok-$$fn" -o -e "failed-$$fn" ]; then \
156 echo "Configuration $$fn already checked." \
159 if $(MAKE) -C $(RANDBUILDDIR)/b -j$(PL); then \
160 cp $(RANDBUILDDIR)/b/globalconfig.out \
161 $(RANDBUILDDIR)/ok-$$fn; \
163 [ -n "$$STOP_ON_ERROR" ] && exit 1; \
164 cp -a $(RANDBUILDDIR)/b \
165 $(RANDBUILDDIR)/failed-$$fn; \
170 $(MAKE) STOP_ON_ERROR=1 randcheck
173 for f in $(RANDBUILDDIR)/failed-*; do \
174 if $(MAKE) -C $$f -j$(PL); then \
177 [ -n "$$STOP_ON_ERROR" ] && exit 1; \
182 $(MAKE) STOP_ON_ERROR=1 randcheckagain
186 @echo "fiasco Builds the default configuration ($(DFL_TEMPLATE))"
187 @echo "T=template Build a certain configuration"
188 @echo "checkall Build all template configurations in one go"
189 @echo "list List templates"
191 @echo "config menuconfig xconfig oldconfig"
192 @echo " Configure kernel in \"$(DFLBUILDDIR)\""
193 @echo "$(DFLBUILDDIR) Build kernel in \"$(DFLBUILDDIR)\""
194 @echo "clean cleanall clean or cleanall in \"$(CLEANSUBDIRS)\""
195 @echo "purge cleanall, remove \"$(DFLBUILDDIR)\" and build helper"
197 @echo "Creating a custom kernel:"
199 @echo " Create a build directory with:"
200 @echo " make BUILDDIR=builddir"
201 @echo " Then build the kernel:"
206 @echo "Call \"make help\" in the build directory for more information on build targets."
208 @echo "Default target: $(DFLBUILDDIR)"
211 .PHONY: man install clean cleanall fiasco.builddir.create fiasco \
212 l4check checkall config oldconfig menuconfig nconfig xconfig \
213 randcheck randcheckstop help