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 DFL_TEMPLATE := ia32-1
21 if [ "$${bd\#/}" = "$$bd" -a \
22 "$${bd\#*..}" = "$$bd" ]; then \
24 while [ "$${bd\#*/}" != "$$bd" ]; do \
34 buildmakefile = mkdir -p "$(1)"; \
35 perl -p -i -e '$$s = "$(CURDIR)/src"; s/\@SRCDIR\@/$$s/' \
36 < $(MAKEFILETEMPL) > $(1)/Makefile
38 ifneq ($(strip $(B)),)
41 ifneq ($(strip $(BUILDDIR)),)
43 @echo "Creating build directory \"$(BUILDDIR)\"..."
44 @if [ -e "$(BUILDDIR)" ]; then \
45 echo "Already exists, aborting."; \
48 @$(call buildmakefile,$(BUILDDIR))
52 ifneq ($(strip $(T)),)
55 test -f $(TEMPLDIR)/globalconfig.out.$(T); \
56 bdir=T-$(DFLBUILDDIR)-$(T); \
58 $(call buildmakefile,T-$(DFLBUILDDIR)-$(T)); \
59 cp $(TEMPLDIR)/globalconfig.out.$(T) $$bdir/globalconfig.out; \
63 $(DFLBUILDDIR): fiasco.builddir.create
69 set -e; for i in $(CLEANSUBDIRS); do $(MAKE) -C $$i $@; done
72 $(RM) -r $(DFLBUILDDIR)
75 set -e; for i in $(MANSUBDIRS); do $(MAKE) -C $$i; done
77 fiasco.builddir.create:
78 [ -e $(DFLBUILDDIR)/Makefile ] || \
79 ($(call buildmakefile,$(DFLBUILDDIR)))
80 [ -f $(DFLBUILDDIR)/globalconfig.out ] || { \
81 cp $(TEMPLDIR)/globalconfig.out.$(DFL_TEMPLATE) \
82 $(DFLBUILDDIR)/globalconfig.out; \
85 config $(filter config %config,$(MAKECMDGOALS)): fiasco.builddir.create
86 $(MAKE) -C $(DFLBUILDDIR) $@
88 fiasco: fiasco.builddir.create
89 $(MAKE) -C $(DFLBUILDDIR) -j$(PL)
93 $(RM) -r $(ALLBUILDDIR); \
94 for X in $(TEST_TEMPLATES); do \
95 echo -e "\n= Building configuration: $$X\n\n"; \
96 $(call buildmakefile,$(ALLBUILDDIR)/$$X); \
97 cp $(TEMPLDIR)/globalconfig.out.$$X \
98 $(ALLBUILDDIR)/$$X/globalconfig.out; \
99 if $(MAKE) -C $(ALLBUILDDIR)/$$X -j$(PL); then \
100 [ -z "$(KEEP_BUILD_DIRS)" ] && \
101 $(RM) -r $(ALLBUILDDIR)/$$X; \
104 failed="$$failed $$X"; \
107 rmdir $(ALLBUILDDIR) >/dev/null 2>&1; \
108 [ "$$failed" ] && echo -e "\nFailed configurations:$$failed"; \
113 @echo $(patsubst $(TEMPLDIR)/globalconfig.out.%,%,$(wildcard $(TEMPLDIR)/globalconfig.out.*))
116 $(RM) -r $(RANDBUILDDIR); \
117 $(call buildmakefile,$(RANDBUILDDIR)/b); \
119 $(MAKE) -C $(RANDBUILDDIR)/b randconfig; \
120 fn=$$(cat $(RANDBUILDDIR)/b/globalconfig.out \
121 | grep -e "^CONFIG_" | sort | sha1sum \
123 if [ -e "ok-$$fn" -o -e "failed-$$fn" ]; then \
124 echo "Configuration $$fn already checked." \
127 if $(MAKE) -C $(RANDBUILDDIR)/b -j$(PL); then \
128 cp $(RANDBUILDDIR)/b/globalconfig.out \
129 $(RANDBUILDDIR)/ok-$$fn; \
131 [ -n "$$STOP_ON_ERROR" ] && exit 1; \
132 cp -a $(RANDBUILDDIR)/b \
133 $(RANDBUILDDIR)/failed-$$fn; \
138 $(MAKE) STOP_ON_ERROR=1 randcheck
141 for f in $(RANDBUILDDIR)/failed-*; do \
142 if $(MAKE) -C $$f -j$(PL); then \
145 [ -n "$$STOP_ON_ERROR" ] && exit 1; \
150 $(MAKE) STOP_ON_ERROR=1 randcheckagain
154 @echo "fiasco Builds the default configuration ($(DFL_TEMPLATE))"
155 @echo "T=template Build a certain configuration"
156 @echo "checkall Build all template configurations in one go"
157 @echo "list List templates"
159 @echo "config menuconfig xconfig oldconfig"
160 @echo " Configure kernel in \"$(DFLBUILDDIR)\""
161 @echo "$(DFLBUILDDIR) Build kernel in \"$(DFLBUILDDIR)\""
162 @echo "clean cleanall clean or cleanall in \"$(CLEANSUBDIRS)\""
163 @echo "purge cleanall, remove \"$(DFLBUILDDIR)\" and build helper"
165 @echo "Creating a custom kernel:"
167 @echo " Create a build directory with:"
168 @echo " make BUILDDIR=builddir"
169 @echo " Then build the kernel:"
174 @echo "Call \"make help\" in the build directory for more information on build targets."
176 @echo "Default target: $(DFLBUILDDIR)"
179 .PHONY: man install clean cleanall fiasco.builddir.create fiasco \
180 l4check checkall help config oldconfig menuconfig xconfig \
181 randcheck randcheckstop