2 tooldir := $(srcdir)/../tool
4 CONFIG_BANNER_STRING ?= "Fiasco - prepare for world domination"
6 .PHONY: all do-all test-all config textconfig menuconfig xconfig \
7 oldconfig regenconfig mrproper doc help update
12 @echo "Possible targets are:"
13 @echo " menuconfig - configure Fiasco (ncurses mode)"
14 @echo " config - like menuconfig"
15 @echo " textconfig - line-oriented config"
16 @echo " xconfig - configure Fiasco (graphical mode)"
17 @echo " all - Fiasco binary"
18 @echo " clean - clear all auto-generated files in auto"
19 @echo " cleanall - like clean + dependencies"
20 @echo " mrproper - like cleanall + config files"
21 @echo " update - update Fiasco and preprocess using svn"
22 @echo " DEPS - dependencies between kernel object files"
23 @echo " DEPS.ps - graphical (ps) representation of DEPS"
24 @echo " DEPS.svg - graphical (svg) representation of DEPS"
25 @echo " DEPS.tred.ps - transitive reduction of DEPS.ps"
26 @echo " DEPS.tred.svg - transitive reduction of DEPS.svg"
27 @echo " doc - doxygen HTML documentation into docs/"
28 @echo " TAGS tags - create tags files"
31 ifneq ($(srcdir),NOT_SET)
32 Makefile: $(srcdir)/templates/Makefile.builddir.templ
33 perl -p -i -e '$$s = "$(srcdir)"; s/\@SRCDIR\@/$$s/' \
37 ifneq ($(MAKECMDGOALS),help)
39 ifeq ($(srcdir),NOT_SET)
40 all $(filter config %config,$(MAKECMDGOALS)):
41 @echo "======================================================================"
42 @echo " Building Fiasco in the src directory is not possible!"
44 @echo " Go to the Fiasco root directory and create your build directory with"
45 @echo " cd .. && make BUILDDIR=build-dir"
46 @echo "======================================================================"
49 else # srcdir != NOT_SET
53 ifeq ($(filter config %config,$(MAKECMDGOALS)),)
55 -include globalconfig.out
57 # use patsubst here to prevent confusion of syntax highlighting editors :-)
58 CONFIG_XARCH := $(patsubst "%",%,$(CONFIG_XARCH))
59 CONFIG_ABI := $(patsubst "%",%,$(CONFIG_ABI))
61 ifeq ("$(CONFIG_XARCH)","")
64 @echo "========================================================="
65 @echo "Now run make again to build!"
66 @echo "========================================================="
70 ifeq ("$(CONFIG_ABI)","")
72 @echo "========================================================="
73 @echo "ERROR: No ABI version set (run 'make menuconfig')!"
74 @echo "========================================================="
79 # At this point, globalconfig.out is up-to-date. Update Modules and
80 # .Modules.deps, then restart using Makefile.sub1, Makefile.sub2.
83 # Read Make configuration
84 include $(srcdir)/Makeconf
86 include $(MODULES_FILE)
93 GENERATED_MODULES = $(foreach subsys, $(SUBSYSTEMS), \
94 $(INTERFACES_$(subsys)))
95 ALL = $(foreach subsys, $(SUBSYSTEMS), $($(subsys)) $($(subsys)_EXTRA))
97 $(foreach m, $(GENERATED_MODULES), auto/stamp-$(m).ready): $(MODULES_FILES)
99 .PRECIOUS: .Modules.deps
100 .Modules.deps: $(MODULES_FILES) globalconfig.h
103 @($(foreach mod, $(GENERATED_MODULES), \
104 echo 'auto/stamp-$(mod).ready: \
105 $(addsuffix .cpp,$(call eval_impl,$(mod)))'; \
106 echo '$(patsubst %,auto/%.cc,$(call eval_impl,$(mod)))' \
107 'auto/$(mod).h auto/$(mod)_i.h: \
108 auto/stamp-$(mod).ready ; \
109 @[ -e $$@ ] || { $$(RM) $$<; $$(MAKE) $$<; }'; \
111 @($(foreach subsys, $(SUBSYSTEMS), \
112 echo 'IFDEPS += $(addprefix ., $(addsuffix .cc.d, \
113 $(foreach in,$(INTERFACES_$(subsys)), \
114 $(call eval_impl,$(in)))))' ; \
115 echo 'CXXSRC_$(subsys) += $(addsuffix .cc, \
116 $(foreach in,$(INTERFACES_$(subsys)), \
117 $(call eval_impl,$(in))))'; \
118 echo 'OBJ_$(subsys) += $$(CXXSRC_$(subsys):.cc=.o) \
119 $$(CSRC_$(subsys):.c=.o) \
120 $$(ASSRC_$(subsys):.S=.o)' ; ) ) >> $@.new
121 @echo "GENERATED_MODULES = $(GENERATED_MODULES)" >> $@.new
122 @echo "ALL = $(ALL)" >> $@.new
123 @echo "_modules_deps_read_ = true" >> $@.new
126 endif # _modules_read_
129 # Makefile.sub1: Create source files.
132 .PHONY: create-sources
133 create-sources: $(MODULES_FILES) globalconfig.h .Modules.deps
134 $(MAKE) srcdir=$(srcdir) objbase=$(objbase) -f $(srcdir)/Makefile.sub1
135 auto/stamp-%.ready: $(MODULES_FILES) globalconfig.h .Modules.deps
136 $(MAKE) srcdir=$(srcdir) objbase=$(objbase) -f $(srcdir)/Makefile.sub1 $@
138 DEPS_FILES=DEPS DEPS.a4 DEPS.tred
141 # Makefile.sub2: Create everything else.
143 all doc $(addsuffix .ps,$(DEPS_FILES)) $(addsuffix .svg,$(DEPS_FILES)) TAGS tags %.o %_t: \
144 $(MODULES_FILES) .Modules.deps create-sources globalconfig.h
145 $(MAKE) srcdir=$(srcdir) objbase=$(objbase) -f $(srcdir)/Makefile.sub2 $@
147 # Divert any target we do not explicitly mention in this Makefile to
148 # Makefile.sub2. (Unfortunately 1, this does not work for file
149 # targets that already exist in this directory. Unfortunately 2,
150 # .DEFAULT does not accept prerequisites, so we must "make
151 # create-sources" manually.)
153 $(MAKE) create-sources
154 $(MAKE) srcdir=$(srcdir) objbase=$(objbase) -f $(srcdir)/Makefile.sub2 $@
156 # Well, we need to provide some empty rules for some targets to
157 # prevent the above catch-all from running amok.
158 Makerules.local $(srcdir)/Makeconf.local $(objbase)/Makeconf.local : ;
160 %: %.o # delete implicit rule
164 endif # ! config xconfig menuconfig oldconfig
167 test -e auto || mkdir auto
169 BSP_DIR := $(srcdir)/kern/arm/bsp $(srcdir)/kern/ppc32/bsp
170 KCONFIG_FILE := Kconfig
171 KCONFIG_SRC_FILE := $(srcdir)/Kconfig
172 KCONFIG_BSP_FILES := $(shell find $(BSP_DIR) -name Kconfig -follow -print)
174 kconfig_call = $(MAKE) -C $(tooldir)/kconfig O=$(objbase) \
175 Kconfig=$(KCONFIG_FILE) \
176 KCONFIG_AUTOHEADER=globalconfig.h \
177 KCONFIG_TRISTATE=config/tristate.conf \
178 KCONFIG_CONFIG=globalconfig.out \
179 KCONFIG_AUTOCONFIG=config/auto.conf \
180 KERNELVERSION=SVN MENUCONFIG_COLOR=blackbg \
181 INCLUDE_PPC32=$(INCLUDE_PPC32) \
182 fiasco_srcdir=$(srcdir)/..
184 $(KCONFIG_FILE): $(KCONFIG_SRC_FILE) $(KCONFIG_BSP_FILES) $(srcdir)/Makefile
185 @$(tooldir)/gen_kconfig $(KCONFIG_SRC_FILE) $(KCONFIG_FILE) $(KCONFIG_BSP_FILES)
187 globalconfig.out: $(KCONFIG_FILE)
188 $(kconfig_call) oldconfig
190 globalconfig.h: globalconfig.out
191 $(kconfig_call) silentoldconfig
193 config: $(KCONFIG_FILE)
194 $(kconfig_call) menuconfig silentoldconfig
196 textconfig: $(KCONFIG_FILE)
197 $(kconfig_call) config silentoldconfig
199 menuconfig oldconfig xconfig qconfig gconfig randconfig allyesconfig allnoconfig: $(KCONFIG_FILE)
200 $(kconfig_call) $@ silentoldconfig
202 ifneq ($(filter clean cleanall mrproper,$(MAKECMDGOALS)),)
204 # Try to suck in clean targets from subsystems' Makefile fragments
206 MAKERULES_SUBSYS = $(foreach subsys, $(SUBSYSTEMS), $(firstword $(wildcard $(addsuffix /Makerules.$(subsys),$(addprefix $(srcdir)/,$(VPATH)) $(srcdir)))))
207 -include $(MAKERULES_SUBSYS)
212 .PHONY: clean cleanall mrproper \
213 $(foreach subsys, $(SUBSYSTEMS), clean-$(subsys)) \
214 $(foreach subsys, $(SUBSYSTEMS), cleanall-$(subsys))
216 clean: $(foreach subsys, $(SUBSYSTEMS), clean-$(subsys))
219 $(RM) auto/*.cc auto/*.h auto/*.S auto/stamp-*.ready
220 $(RM) .Clean-auto .Compiler-config
222 cleanall: clean $(foreach subsys, $(SUBSYSTEMS), cleanall-$(subsys))
223 $(foreach subdir, $(SUBDIRS), $(RM) $(subdir)/{.,}*.d)
224 $(RM) {.,}*.d {.,}*.d.new *~ globalconfig.{h,h.old} Circular
228 $(RM_R) globalconfig.out Modules.* DEPS*
229 $(RM_R) auto docs config scripts
231 endif # clean, cleanall, mrproper
234 cd $(srcdir)/.. && svn update
235 cd $(dir $(PREPROCESS))/.. && svn update
237 endif # srcdir != NOT_SET
239 endif # MAKECMDGOALS != help