]> 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
8
9 all:
10
11 help:
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"
29
30
31 ifneq ($(srcdir),NOT_SET)
32 Makefile: $(srcdir)/templates/Makefile.builddir.templ
33         perl -p -i -e '$$s = "$(srcdir)"; s/\@SRCDIR\@/$$s/' \
34                         < $< >$@
35 endif
36
37 ifneq ($(MAKECMDGOALS),help)
38
39 ifeq ($(srcdir),NOT_SET)
40 all $(filter config %config,$(MAKECMDGOALS)):
41         @echo "======================================================================"
42         @echo " Building Fiasco in the src directory is not possible!"
43         @echo ""
44         @echo " Go to the Fiasco root directory and create your build directory with"
45         @echo "    cd .. && make BUILDDIR=build-dir"
46         @echo "======================================================================"
47         @exit 1
48
49 else # srcdir != NOT_SET
50
51 all: globalconfig.h
52
53 ifeq ($(filter config %config,$(MAKECMDGOALS)),)
54
55 -include globalconfig.out
56
57 # use patsubst here to prevent confusion of syntax highlighting editors :-)
58 CONFIG_XARCH    := $(patsubst "%",%,$(CONFIG_XARCH))
59 CONFIG_ABI      := $(patsubst "%",%,$(CONFIG_ABI))
60
61 ifeq ("$(CONFIG_XARCH)","")
62
63 all: menuconfig
64         @echo "========================================================="
65         @echo "Now run make again to build!"
66         @echo "========================================================="
67         @exit 1
68
69 else # ! no XARCH
70 ifeq ("$(CONFIG_ABI)","")
71 all:
72         @echo "========================================================="
73         @echo "ERROR: No ABI version set (run 'make menuconfig')!"
74         @echo "========================================================="
75         @exit 1
76 else # ! no ABI
77
78
79 # At this point, globalconfig.out is up-to-date.  Update Modules and
80 # .Modules.deps, then restart using Makefile.sub1, Makefile.sub2.
81 #
82
83 # Read Make configuration
84 include $(srcdir)/Makeconf
85
86 include $(MODULES_FILE)
87
88 ifdef SUBSYSTEMS
89  _modules_read_ = true
90 endif
91
92 ifdef _modules_read_
93 GENERATED_MODULES = $(foreach subsys, $(SUBSYSTEMS), \
94                       $(INTERFACES_$(subsys)))
95 ALL = $(foreach subsys, $(SUBSYSTEMS), $($(subsys)) $($(subsys)_EXTRA))
96
97 $(foreach m, $(GENERATED_MODULES), auto/stamp-$(m).ready): $(MODULES_FILES)
98
99 .PRECIOUS: .Modules.deps
100 .Modules.deps: $(MODULES_FILES) globalconfig.h
101         @mkdir -p auto
102         @echo "Creating $@"
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) $$<; }';        \
110           )) > $@.new
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
124         @mv $@.new $@
125
126 endif # _modules_read_
127
128
129 # Makefile.sub1: Create source files.
130
131
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 $@
137
138 DEPS_FILES=DEPS DEPS.a4 DEPS.tred
139
140 #
141 # Makefile.sub2: Create everything else.
142 #
143 all doc $(addsuffix .ps,$(DEPS_FILES)) $(addsuffix .svg,$(DEPS_FILES)) TAGS tags: \
144   $(MODULES_FILES) .Modules.deps create-sources globalconfig.h
145         $(MAKE) srcdir=$(srcdir) objbase=$(objbase) -f $(srcdir)/Makefile.sub2 $@
146
147 %.o %_t: $(MODULES_FILES) .Modules.deps create-sources globalconfig.h
148         $(MAKE) srcdir=$(srcdir) objbase=$(objbase) -f $(srcdir)/Makefile.sub2 $@
149
150 # Divert any target we do not explicitly mention in this Makefile to
151 # Makefile.sub2.  (Unfortunately 1, this does not work for file
152 # targets that already exist in this directory.  Unfortunately 2,
153 # .DEFAULT does not accept prerequisites, so we must "make
154 # create-sources" manually.)
155 .DEFAULT: 
156         $(MAKE) create-sources
157         $(MAKE) srcdir=$(srcdir) objbase=$(objbase) -f $(srcdir)/Makefile.sub2 $@
158
159 # Well, we need to provide some empty rules for some targets to
160 # prevent the above catch-all from running amok.
161 Makerules.local $(srcdir)/Makeconf.local $(objbase)/Makeconf.local : ;
162
163 %: %.o                          # delete implicit rule
164
165 endif # ! no ABI
166 endif # ! no XARCH
167 endif # ! config xconfig menuconfig oldconfig
168
169 auto:
170         test -e auto || mkdir auto
171
172 BSP_DIR            := $(srcdir)/kern/arm/bsp $(srcdir)/kern/ppc32/bsp
173 KCONFIG_FILE       := Kconfig
174 KCONFIG_SRC_FILE   := $(srcdir)/Kconfig
175 KCONFIG_BSP_FILES  := $(shell find $(BSP_DIR) -name Kconfig -follow -print)
176
177 kconfig_call = $(MAKE) -C $(tooldir)/kconfig O=$(objbase) \
178                Kconfig=$(KCONFIG_FILE) \
179                KCONFIG_AUTOHEADER=globalconfig.h \
180                KCONFIG_TRISTATE=config/tristate.conf \
181                KCONFIG_CONFIG=globalconfig.out \
182                KCONFIG_AUTOCONFIG=config/auto.conf \
183                KERNELVERSION=SVN MENUCONFIG_COLOR=blackbg \
184                INCLUDE_PPC32=$(INCLUDE_PPC32) \
185                fiasco_srcdir=$(srcdir)/..
186
187 $(KCONFIG_FILE): $(KCONFIG_SRC_FILE) $(KCONFIG_BSP_FILES) $(srcdir)/Makefile
188         @$(tooldir)/gen_kconfig $(KCONFIG_SRC_FILE) $(KCONFIG_FILE) $(KCONFIG_BSP_FILES)
189
190 globalconfig.out: $(KCONFIG_FILE)
191         $(kconfig_call) oldconfig
192
193 globalconfig.h: globalconfig.out
194         $(kconfig_call) silentoldconfig
195
196 config: $(KCONFIG_FILE)
197         $(kconfig_call) menuconfig silentoldconfig
198
199 textconfig: $(KCONFIG_FILE)
200         $(kconfig_call) config silentoldconfig
201
202 menuconfig oldconfig xconfig qconfig gconfig randconfig allyesconfig allnoconfig: $(KCONFIG_FILE)
203         $(kconfig_call) $@ silentoldconfig
204
205 ifneq ($(filter clean cleanall mrproper,$(MAKECMDGOALS)),)
206
207 # Try to suck in clean targets from subsystems' Makefile fragments
208 ifdef _modules_read_
209 MAKERULES_SUBSYS = $(foreach subsys, $(SUBSYSTEMS), $(firstword $(wildcard $(addsuffix /Makerules.$(subsys),$(addprefix $(srcdir)/,$(VPATH)) $(srcdir)))))
210 -include $(MAKERULES_SUBSYS)
211 endif
212
213 .DEFAULT:
214
215 .PHONY: clean cleanall mrproper \
216         $(foreach subsys, $(SUBSYSTEMS), clean-$(subsys)) \
217         $(foreach subsys, $(SUBSYSTEMS), cleanall-$(subsys))
218
219 clean: $(foreach subsys, $(SUBSYSTEMS), clean-$(subsys))
220         $(RM) $(ALL)
221         $(RM) *.o fiasco
222         $(RM) auto/*.cc auto/*.h auto/*.S auto/stamp-*.ready
223         $(RM) .Clean-auto .Compiler-config
224
225 cleanall: clean $(foreach subsys, $(SUBSYSTEMS), cleanall-$(subsys))
226         $(foreach subdir, $(SUBDIRS), $(RM) $(subdir)/{.,}*.d)
227         $(RM) {.,}*.d {.,}*.d.new *~ globalconfig.{h,h.old} Circular
228         $(RM) .Modules.deps
229
230 mrproper: cleanall
231         $(RM_R) globalconfig.out Modules.* DEPS*
232         $(RM_R) auto docs config scripts
233
234 endif # clean, cleanall, mrproper
235
236 update:
237         cd $(srcdir)/.. && svn update
238         cd $(dir $(PREPROCESS))/.. && svn update
239
240 endif # srcdir != NOT_SET
241
242 endif # MAKECMDGOALS != help
243