]> rtime.felk.cvut.cz Git - l4.git/blob - kernel/fiasco/src/Makefile
Update
[l4.git] / kernel / fiasco / src / Makefile
1 srcdir          ?= NOT_SET
2 tooldir         := $(srcdir)/../tool
3
4 CONFIG_BANNER_STRING ?= "Fiasco - prepare for world domination"
5
6 .PHONY: all do-all test-all config textconfig menuconfig xconfig \
7         oldconfig regenconfig mrproper doc help update nconfig \
8         savedefconfig listnewconfig oldnoconfig oldaskconfig
9
10 all:
11
12 help:
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"
30
31
32 ifneq ($(srcdir),NOT_SET)
33 Makefile: $(srcdir)/templates/Makefile.builddir.templ
34         perl -p -i -e '$$s = "$(srcdir)"; s/\@SRCDIR\@/$$s/' \
35                         < $< >$@
36 endif
37
38 ifneq ($(MAKECMDGOALS),help)
39
40 ifeq ($(srcdir),NOT_SET)
41 all $(filter config %config,$(MAKECMDGOALS)):
42         @echo "======================================================================"
43         @echo " Building Fiasco in the src directory is not possible!"
44         @echo ""
45         @echo " Go to the Fiasco root directory and create your build directory with"
46         @echo "    cd .. && make BUILDDIR=build-dir"
47         @echo "======================================================================"
48         @exit 1
49
50 else # srcdir != NOT_SET
51
52 all: globalconfig.h
53
54 ifeq ($(filter config %config,$(MAKECMDGOALS)),)
55
56 -include globalconfig.out
57
58 # use patsubst here to prevent confusion of syntax highlighting editors :-)
59 CONFIG_XARCH    := $(patsubst "%",%,$(CONFIG_XARCH))
60 CONFIG_ABI      := $(patsubst "%",%,$(CONFIG_ABI))
61
62 ifeq ("$(CONFIG_XARCH)","")
63
64 all: menuconfig
65         @echo "========================================================="
66         @echo "Now run make again to build!"
67         @echo "========================================================="
68         @exit 1
69
70 else # ! no XARCH
71 ifeq ("$(CONFIG_ABI)","")
72 all:
73         @echo "========================================================="
74         @echo "ERROR: No ABI version set (run 'make menuconfig')!"
75         @echo "========================================================="
76         @exit 1
77 else # ! no ABI
78
79
80 # At this point, globalconfig.out is up-to-date.  Update Modules and
81 # .Modules.deps, then restart using Makefile.sub1, Makefile.sub2.
82 #
83
84 # Read Make configuration
85 include $(srcdir)/Makeconf
86
87 include $(MODULES_FILE)
88 MODULES_FILES += $(srcdir)/Modules.generic
89
90 ifdef SUBSYSTEMS
91  _modules_read_ = true
92 endif
93
94 ifdef _modules_read_
95 GENERATED_MODULES = $(foreach subsys, $(SUBSYSTEMS), \
96                       $(INTERFACES_$(subsys)))
97 ALL = $(foreach subsys, $(SUBSYSTEMS), $($(subsys)) $($(subsys)_EXTRA))
98
99 $(foreach m, $(GENERATED_MODULES), auto/stamp-$(m).ready): $(MODULES_FILES)
100
101 .PRECIOUS: .Modules.deps
102 .Modules.deps: $(MODULES_FILES) globalconfig.h source
103         @mkdir -p auto
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
107         @echo "Creating $@"
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) $$<; }';        \
115           )) > $@.new
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
129         @mv $@.new $@
130
131 endif # _modules_read_
132
133
134 # Makefile.sub1: Create source files.
135
136
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 $@
142
143 DEPS_FILES=DEPS DEPS.a4 DEPS.tred
144
145 #
146 # Makefile.sub2: Create everything else.
147 #
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 $@
151
152 %.o %_t: $(MODULES_FILES) .Modules.deps create-sources globalconfig.h
153         $(MAKE) srcdir=$(srcdir) objbase=$(objbase) -f $(srcdir)/Makefile.sub2 $@
154
155
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.)
161 .DEFAULT: 
162         $(MAKE) create-sources
163         $(MAKE) srcdir=$(srcdir) objbase=$(objbase) -f $(srcdir)/Makefile.sub2 $@
164
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: ;
169
170 %: %.o                          # delete implicit rule
171
172 endif # ! no ABI
173 endif # ! no XARCH
174 endif # ! config xconfig menuconfig oldconfig
175
176 auto:
177         test -e auto || mkdir auto
178
179 source:
180         test -e source || ln -sf $(srcdir) source
181
182
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)
188
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)/..
199
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)
204
205 globalconfig.out: $(KCONFIG_FILE)
206         +$(kconfig_call) oldconfig
207
208 globalconfig.h: globalconfig.out
209         +$(kconfig_call) silentoldconfig
210
211 config: $(KCONFIG_FILE)
212         +$(kconfig_call) menuconfig
213         +$(kconfig_call) silentoldconfig
214
215 textconfig: $(KCONFIG_FILE)
216         +$(kconfig_call) config silentoldconfig
217
218 menuconfig oldconfig xconfig gconfig nconfig randconfig allyesconfig allnoconfig: $(KCONFIG_FILE)
219         +$(kconfig_call) $@
220         +$(kconfig_call) silentoldconfig
221
222 listnewconfig olddefconfig oldnoconfig savedefconfig: $(KCONFIG_FILE)
223         +$(kconfig_call) $@
224
225 oldaskconfig: $(KCONFIG_FILE)
226         +$(kconfig_call) config
227
228 ifneq ($(filter clean cleanall mrproper,$(MAKECMDGOALS)),)
229
230 # Try to suck in clean targets from subsystems' Makefile fragments
231 ifdef _modules_read_
232 MAKERULES_SUBSYS = $(foreach subsys, $(SUBSYSTEMS), $(firstword $(wildcard $(addsuffix /Makerules.$(subsys),$(addprefix $(srcdir)/,$(VPATH)) $(srcdir)))))
233 -include $(MAKERULES_SUBSYS)
234 endif
235
236 .DEFAULT:
237
238 .PHONY: clean cleanall mrproper \
239         $(foreach subsys, $(SUBSYSTEMS), clean-$(subsys)) \
240         $(foreach subsys, $(SUBSYSTEMS), cleanall-$(subsys))
241
242 clean: $(foreach subsys, $(SUBSYSTEMS), clean-$(subsys))
243         $(RM) $(ALL)
244         $(RM) *.o fiasco
245         $(RM) auto/*.cc auto/*.h auto/*.S auto/stamp-*.ready
246         $(RM) .Clean-auto .Compiler-config
247
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
253
254 mrproper: cleanall
255         $(RM_R) globalconfig.out Modules.* DEPS*
256         $(RM_R) auto docs config scripts
257
258 endif # clean, cleanall, mrproper
259
260 update:
261         cd $(srcdir)/.. && svn update
262         cd $(dir $(PREPROCESS))/.. && svn update
263
264 endif # srcdir != NOT_SET
265
266 endif # MAKECMDGOALS != help
267