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 nconfig
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)
87 MODULES_FILES += $(srcdir)/Modules.generic
94 GENERATED_MODULES = $(foreach subsys, $(SUBSYSTEMS), \
95 $(INTERFACES_$(subsys)))
96 ALL = $(foreach subsys, $(SUBSYSTEMS), $($(subsys)) $($(subsys)_EXTRA))
98 $(foreach m, $(GENERATED_MODULES), auto/stamp-$(m).ready): $(MODULES_FILES)
100 .PRECIOUS: .Modules.deps
101 .Modules.deps: $(MODULES_FILES) globalconfig.h source
103 @echo "Cleaning up build directory"
104 $(VERBOSE)$(RM_R) *.o fiasco *.d .*.d .*.d.new *.d.new
105 $(VERBOSE)$(RM_R) auto/*.cc auto/*.h auto/*.S auto/stamp-*.ready
107 @($(foreach mod, $(GENERATED_MODULES), \
108 echo 'auto/stamp-$(mod).ready: \
109 $(addsuffix .cpp,$(call eval_impl,$(mod)))'; \
110 echo '$(patsubst %,auto/%.cc,$(call eval_impl,$(mod)))' \
111 'auto/$(mod).h auto/$(mod)_i.h: \
112 auto/stamp-$(mod).ready ; \
113 @[ -e $$@ ] || { $$(RM) $$<; $$(MAKE) $$<; }'; \
115 @($(foreach subsys, $(SUBSYSTEMS), \
116 echo 'IFDEPS += $(addprefix ., $(addsuffix .cc.d, \
117 $(foreach in,$(INTERFACES_$(subsys)), \
118 $(call eval_impl,$(in)))))' ; \
119 echo 'CXXSRC_$(subsys) += $(addsuffix .cc, \
120 $(foreach in,$(INTERFACES_$(subsys)), \
121 $(call eval_impl,$(in))))'; \
122 echo 'OBJ_$(subsys) += $$(CXXSRC_$(subsys):.cc=.o) \
123 $$(CSRC_$(subsys):.c=.o) \
124 $$(ASSRC_$(subsys):.S=.o)' ; ) ) >> $@.new
125 @echo "GENERATED_MODULES = $(GENERATED_MODULES)" >> $@.new
126 @echo "ALL = $(ALL)" >> $@.new
127 @echo "_modules_deps_read_ = true" >> $@.new
130 endif # _modules_read_
133 # Makefile.sub1: Create source files.
136 .PHONY: create-sources
137 create-sources: $(MODULES_FILES) globalconfig.h .Modules.deps
138 $(MAKE) srcdir=$(srcdir) objbase=$(objbase) -f $(srcdir)/Makefile.sub1
139 auto/stamp-%.ready: $(MODULES_FILES) globalconfig.h .Modules.deps
140 $(MAKE) srcdir=$(srcdir) objbase=$(objbase) -f $(srcdir)/Makefile.sub1 $@
142 DEPS_FILES=DEPS DEPS.a4 DEPS.tred
145 # Makefile.sub2: Create everything else.
147 all doc $(addsuffix .ps,$(DEPS_FILES)) $(addsuffix .svg,$(DEPS_FILES)) TAGS tags: \
148 $(MODULES_FILES) .Modules.deps create-sources globalconfig.h
149 $(MAKE) srcdir=$(srcdir) objbase=$(objbase) -f $(srcdir)/Makefile.sub2 $@
151 %.o %_t: $(MODULES_FILES) .Modules.deps create-sources globalconfig.h
152 $(MAKE) srcdir=$(srcdir) objbase=$(objbase) -f $(srcdir)/Makefile.sub2 $@
155 # Divert any target we do not explicitly mention in this Makefile to
156 # Makefile.sub2. (Unfortunately 1, this does not work for file
157 # targets that already exist in this directory. Unfortunately 2,
158 # .DEFAULT does not accept prerequisites, so we must "make
159 # create-sources" manually.)
161 $(MAKE) create-sources
162 $(MAKE) srcdir=$(srcdir) objbase=$(objbase) -f $(srcdir)/Makefile.sub2 $@
164 # Well, we need to provide some empty rules for some targets to
165 # prevent the above catch-all from running amok.
166 Makerules.local $(srcdir)/Makeconf.local $(objbase)/Makeconf.local \
167 $(objbase)/.Host-config: ;
169 %: %.o # delete implicit rule
173 endif # ! config xconfig menuconfig oldconfig
176 test -e auto || mkdir auto
179 test -e source || ln -sf $(srcdir) source
182 BSP_DIR := $(srcdir)/kern/arm/bsp $(srcdir)/kern/ppc32/bsp $(srcdir)/kern/sparc/bsp
183 KCONFIG_FILE := Kconfig
184 KCONFIG_SRC_FILE := $(srcdir)/Kconfig
185 KCONFIG_BSP_FILES := $(shell find $(BSP_DIR) -name Kconfig -follow -print)
187 kconfig_call = $(MAKE) -C $(tooldir)/kconfig O=$(objbase) \
188 Kconfig=$(KCONFIG_FILE) \
189 KCONFIG_AUTOHEADER=globalconfig.h \
190 KCONFIG_TRISTATE=config/tristate.conf \
191 KCONFIG_CONFIG=globalconfig.out \
192 KCONFIG_AUTOCONFIG=config/auto.conf \
193 KERNELVERSION=SVN MENUCONFIG_COLOR=blackbg \
194 INCLUDE_PPC32=$(INCLUDE_PPC32) \
195 INCLUDE_SPARC=$(INCLUDE_SPARC) \
196 fiasco_srcdir=$(srcdir)/..
198 $(KCONFIG_FILE): $(KCONFIG_SRC_FILE) $(KCONFIG_BSP_FILES) $(srcdir)/Makefile
199 @$(tooldir)/gen_kconfig $(KCONFIG_SRC_FILE) $(KCONFIG_FILE) $(KCONFIG_BSP_FILES)
201 globalconfig.out: $(KCONFIG_FILE)
202 +$(kconfig_call) oldconfig
204 globalconfig.h: globalconfig.out
205 +$(kconfig_call) silentoldconfig
207 config: $(KCONFIG_FILE)
208 +$(kconfig_call) menuconfig silentoldconfig
210 textconfig: $(KCONFIG_FILE)
211 +$(kconfig_call) config silentoldconfig
213 menuconfig oldconfig xconfig gconfig nconfig randconfig allyesconfig allnoconfig: $(KCONFIG_FILE)
214 +$(kconfig_call) $@ silentoldconfig
216 ifneq ($(filter clean cleanall mrproper,$(MAKECMDGOALS)),)
218 # Try to suck in clean targets from subsystems' Makefile fragments
220 MAKERULES_SUBSYS = $(foreach subsys, $(SUBSYSTEMS), $(firstword $(wildcard $(addsuffix /Makerules.$(subsys),$(addprefix $(srcdir)/,$(VPATH)) $(srcdir)))))
221 -include $(MAKERULES_SUBSYS)
226 .PHONY: clean cleanall mrproper \
227 $(foreach subsys, $(SUBSYSTEMS), clean-$(subsys)) \
228 $(foreach subsys, $(SUBSYSTEMS), cleanall-$(subsys))
230 clean: $(foreach subsys, $(SUBSYSTEMS), clean-$(subsys))
233 $(RM) auto/*.cc auto/*.h auto/*.S auto/stamp-*.ready
234 $(RM) .Clean-auto .Compiler-config
236 cleanall: clean $(foreach subsys, $(SUBSYSTEMS), cleanall-$(subsys))
237 $(foreach subdir, $(SUBDIRS), $(RM) $(subdir)/*.d $(subdir)/.*.d)
238 $(RM) *.d .*.d .*.d.new *.d.new *~
239 $(RM) globalconfig.h globalconfig.h.old Circular
240 $(RM) .Modules.deps source
243 $(RM_R) globalconfig.out Modules.* DEPS*
244 $(RM_R) auto docs config scripts
246 endif # clean, cleanall, mrproper
249 cd $(srcdir)/.. && svn update
250 cd $(dir $(PREPROCESS))/.. && svn update
252 endif # srcdir != NOT_SET
254 endif # MAKECMDGOALS != help