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 \
8 savedefconfig listnewconfig oldnoconfig oldaskconfig
13 @echo "Possible targets are:"
14 @echo " menuconfig - configure Fiasco (ncurses mode)"
15 @echo " config - like menuconfig"
16 @echo " textconfig - line-oriented config"
17 @echo " xconfig - configure Fiasco (graphical mode)"
18 @echo " all - Fiasco binary"
19 @echo " clean - clear all auto-generated files in auto"
20 @echo " cleanall - like clean + dependencies"
21 @echo " mrproper - like cleanall + config files"
22 @echo " update - update Fiasco and preprocess using svn"
23 @echo " DEPS - dependencies between kernel object files"
24 @echo " DEPS.ps - graphical (ps) representation of DEPS"
25 @echo " DEPS.svg - graphical (svg) representation of DEPS"
26 @echo " DEPS.tred.ps - transitive reduction of DEPS.ps"
27 @echo " DEPS.tred.svg - transitive reduction of DEPS.svg"
28 @echo " doc - doxygen HTML documentation into docs/"
29 @echo " TAGS tags - create tags files"
32 ifneq ($(srcdir),NOT_SET)
33 Makefile: $(srcdir)/templates/Makefile.builddir.templ
34 perl -p -i -e '$$s = "$(srcdir)"; s/\@SRCDIR\@/$$s/' \
38 ifneq ($(MAKECMDGOALS),help)
40 ifeq ($(srcdir),NOT_SET)
41 all $(filter config %config,$(MAKECMDGOALS)):
42 @echo "======================================================================"
43 @echo " Building Fiasco in the src directory is not possible!"
45 @echo " Go to the Fiasco root directory and create your build directory with"
46 @echo " cd .. && make BUILDDIR=build-dir"
47 @echo "======================================================================"
50 else # srcdir != NOT_SET
54 ifeq ($(filter config %config,$(MAKECMDGOALS)),)
56 -include globalconfig.out
58 # use patsubst here to prevent confusion of syntax highlighting editors :-)
59 CONFIG_XARCH := $(patsubst "%",%,$(CONFIG_XARCH))
60 CONFIG_ABI := $(patsubst "%",%,$(CONFIG_ABI))
62 ifeq ("$(CONFIG_XARCH)","")
65 @echo "========================================================="
66 @echo "Now run make again to build!"
67 @echo "========================================================="
71 ifeq ("$(CONFIG_ABI)","")
73 @echo "========================================================="
74 @echo "ERROR: No ABI version set (run 'make menuconfig')!"
75 @echo "========================================================="
80 # At this point, globalconfig.out is up-to-date. Update Modules and
81 # .Modules.deps, then restart using Makefile.sub1, Makefile.sub2.
84 # Read Make configuration
85 include $(srcdir)/Makeconf
87 include $(MODULES_FILE)
88 MODULES_FILES += $(srcdir)/Modules.generic
95 GENERATED_MODULES = $(foreach subsys, $(SUBSYSTEMS), \
96 $(INTERFACES_$(subsys)))
97 ALL = $(foreach subsys, $(SUBSYSTEMS), $($(subsys)) $($(subsys)_EXTRA))
99 $(foreach m, $(GENERATED_MODULES), auto/stamp-$(m).ready): $(MODULES_FILES)
101 .PRECIOUS: .Modules.deps
102 .Modules.deps: $(MODULES_FILES) globalconfig.h source
104 @echo "Cleaning up build directory"
105 $(VERBOSE)$(RM_R) *.o fiasco *.d .*.d .*.d.new *.d.new
106 $(VERBOSE)$(RM_R) auto/*.cc auto/*.h auto/*.S auto/stamp-*.ready
108 @($(foreach mod, $(GENERATED_MODULES), \
109 echo 'auto/stamp-$(mod).ready: \
110 $(addsuffix .cpp,$(call eval_impl,$(mod)))'; \
111 echo '$(patsubst %,auto/%.cc,$(call eval_impl,$(mod)))' \
112 'auto/$(mod).h auto/$(mod)_i.h: \
113 auto/stamp-$(mod).ready ; \
114 @[ -e $$@ ] || { $$(RM) $$<; $$(MAKE) $$<; }'; \
116 @($(foreach subsys, $(SUBSYSTEMS), \
117 echo 'IFDEPS += $(addprefix ., $(addsuffix .cc.d, \
118 $(foreach in,$(INTERFACES_$(subsys)), \
119 $(call eval_impl,$(in)))))' ; \
120 echo 'CXXSRC_$(subsys) += $(addsuffix .cc, \
121 $(foreach in,$(INTERFACES_$(subsys)), \
122 $(call eval_impl,$(in))))'; \
123 echo 'OBJ_$(subsys) += $$(CXXSRC_$(subsys):.cc=.o) \
124 $$(CSRC_$(subsys):.c=.o) \
125 $$(ASSRC_$(subsys):.S=.o)' ; ) ) >> $@.new
126 @echo "GENERATED_MODULES = $(GENERATED_MODULES)" >> $@.new
127 @echo "ALL = $(ALL)" >> $@.new
128 @echo "_modules_deps_read_ = true" >> $@.new
131 endif # _modules_read_
134 # Makefile.sub1: Create source files.
137 .PHONY: create-sources
138 create-sources: $(MODULES_FILES) globalconfig.h .Modules.deps
139 $(MAKE) srcdir=$(srcdir) objbase=$(objbase) -f $(srcdir)/Makefile.sub1
140 auto/stamp-%.ready: $(MODULES_FILES) globalconfig.h .Modules.deps
141 $(MAKE) srcdir=$(srcdir) objbase=$(objbase) -f $(srcdir)/Makefile.sub1 $@
143 DEPS_FILES=DEPS DEPS.a4 DEPS.tred
146 # Makefile.sub2: Create everything else.
148 all doc $(addsuffix .ps,$(DEPS_FILES)) $(addsuffix .svg,$(DEPS_FILES)) TAGS tags: \
149 $(MODULES_FILES) .Modules.deps create-sources globalconfig.h
150 $(MAKE) srcdir=$(srcdir) objbase=$(objbase) -f $(srcdir)/Makefile.sub2 $@
152 %.o %_t: $(MODULES_FILES) .Modules.deps create-sources globalconfig.h
153 $(MAKE) srcdir=$(srcdir) objbase=$(objbase) -f $(srcdir)/Makefile.sub2 $@
156 # Divert any target we do not explicitly mention in this Makefile to
157 # Makefile.sub2. (Unfortunately 1, this does not work for file
158 # targets that already exist in this directory. Unfortunately 2,
159 # .DEFAULT does not accept prerequisites, so we must "make
160 # create-sources" manually.)
162 $(MAKE) create-sources
163 $(MAKE) srcdir=$(srcdir) objbase=$(objbase) -f $(srcdir)/Makefile.sub2 $@
165 # Well, we need to provide some empty rules for some targets to
166 # prevent the above catch-all from running amok.
167 Makerules.local $(srcdir)/Makeconf.local $(objbase)/Makeconf.local \
168 $(objbase)/.Host-config: ;
170 %: %.o # delete implicit rule
174 endif # ! config xconfig menuconfig oldconfig
177 test -e auto || mkdir auto
180 test -e source || ln -sf $(srcdir) source
183 BSP_DIR := $(wildcard $(srcdir)/kern/*/bsp)
184 KCONFIG_FILE := Kconfig
185 KCONFIG_SRC_FILE := $(srcdir)/Kconfig
186 KCONFIG_BSP_FILES := $(shell find $(BSP_DIR) -name Kconfig -follow -print)
187 KCONFIG_ARCH_FILES := $(wildcard $(srcdir)/kern/*/Kconfig)
189 kconfig_call = $(MAKE) -C $(tooldir)/kconfig O=$(objbase) \
190 Kconfig=$(KCONFIG_FILE) \
191 KCONFIG_AUTOHEADER=globalconfig.h \
192 KCONFIG_TRISTATE=include/config/tristate.conf \
193 KCONFIG_CONFIG=globalconfig.out \
194 KCONFIG_AUTOCONFIG=include/config/auto.conf \
195 KERNELVERSION=SVN MENUCONFIG_COLOR=blackbg \
196 INCLUDE_PPC32=$(INCLUDE_PPC32) \
197 INCLUDE_SPARC=$(INCLUDE_SPARC) \
198 fiasco_srcdir=$(srcdir)/..
200 $(KCONFIG_FILE): $(KCONFIG_SRC_FILE) $(KCONFIG_BSP_FILES) \
201 $(KCONFIG_ARCH_FILES) $(srcdir)/Makefile
202 @$(tooldir)/gen_kconfig $(KCONFIG_SRC_FILE) $(KCONFIG_FILE) \
203 $(KCONFIG_BSP_FILES) $(KCONFIG_ARCH_FILES)
205 globalconfig.out: $(KCONFIG_FILE)
206 +$(kconfig_call) oldconfig
208 globalconfig.h: globalconfig.out
209 +$(kconfig_call) silentoldconfig
211 config: $(KCONFIG_FILE)
212 +$(kconfig_call) menuconfig
213 +$(kconfig_call) silentoldconfig
215 textconfig: $(KCONFIG_FILE)
216 +$(kconfig_call) config silentoldconfig
218 menuconfig oldconfig xconfig gconfig nconfig randconfig allyesconfig allnoconfig: $(KCONFIG_FILE)
220 +$(kconfig_call) silentoldconfig
222 listnewconfig olddefconfig oldnoconfig savedefconfig: $(KCONFIG_FILE)
225 oldaskconfig: $(KCONFIG_FILE)
226 +$(kconfig_call) config
228 ifneq ($(filter clean cleanall mrproper,$(MAKECMDGOALS)),)
230 # Try to suck in clean targets from subsystems' Makefile fragments
232 MAKERULES_SUBSYS = $(foreach subsys, $(SUBSYSTEMS), $(firstword $(wildcard $(addsuffix /Makerules.$(subsys),$(addprefix $(srcdir)/,$(VPATH)) $(srcdir)))))
233 -include $(MAKERULES_SUBSYS)
238 .PHONY: clean cleanall mrproper \
239 $(foreach subsys, $(SUBSYSTEMS), clean-$(subsys)) \
240 $(foreach subsys, $(SUBSYSTEMS), cleanall-$(subsys))
242 clean: $(foreach subsys, $(SUBSYSTEMS), clean-$(subsys))
245 $(RM) auto/*.cc auto/*.h auto/*.S auto/stamp-*.ready
246 $(RM) .Clean-auto .Compiler-config
248 cleanall: clean $(foreach subsys, $(SUBSYSTEMS), cleanall-$(subsys))
249 $(foreach subdir, $(SUBDIRS), $(RM) $(subdir)/*.d $(subdir)/.*.d)
250 $(RM) *.d .*.d .*.d.new *.d.new *~
251 $(RM) globalconfig.h globalconfig.h.old Circular
252 $(RM) .Modules.deps source
255 $(RM_R) globalconfig.out Modules.* DEPS*
256 $(RM_R) auto docs config scripts
258 endif # clean, cleanall, mrproper
261 cd $(srcdir)/.. && svn update
262 cd $(dir $(PREPROCESS))/.. && svn update
264 endif # srcdir != NOT_SET
266 endif # MAKECMDGOALS != help