]> rtime.felk.cvut.cz Git - l4.git/blob - kernel/fiasco/src/Makefile.sub2
update
[l4.git] / kernel / fiasco / src / Makefile.sub2
1 # -*- makefile -*-
2
3 # Targets in this Makefile:
4 # - all: Run all subsystems' "all" targets
5 # - doc: Create doxygen documentation in directory "docs"
6 # - DEPS, DEPS.ps, DEPS.a4.ps, DEPS.tred.ps: 
7 #        Create dependency graphs
8 # - TAGS, tags: 
9 #        Create editor tags
10 # This Makefile is invoked in a sub-Make from the top-level Makefile
11 # when globalconfig.out, Modules and .Modules.deps are up-to-date and
12 # all `preprocess'd C++ source files have been created.
13
14 all: do-all
15         $(VERBOSE)echo "  --> Build-Nr: $$(cat .build_nr)"
16
17 BUILD_OBJECTS=true
18
19 include $(srcdir)/Makeconf      # also reads srcdir/Makeconf.local
20                                 # and        objdir/Makeconf.local
21 include $(MODULES_FILE)
22 include .Modules.deps
23
24 # Compute sets of sources.  From these variables, Makeconf computes
25 # $(DEPS) and $(SRC_ALL).  Set them before including Makerules.global.
26 SRC_S = $(foreach subsys, $(SUBSYSTEMS), $(ASSRC_$(subsys)))
27 SRC_C = $(foreach subsys, $(SUBSYSTEMS), $(CSRC_$(subsys)))
28 SRC_CC = $(foreach subsys, $(SUBSYSTEMS), $(CXXSRC_$(subsys)))
29
30 include $(srcdir)/Makerules.global # also reads objdir/Makerules.local
31
32 include $(MAKERULES_SUBSYS)
33 -include $(DEPS)
34
35 # Recompile everything if the compiler configuration has changed.
36 OBJS = $(foreach subsys, $(SUBSYSTEMS), $(OBJ_$(subsys)))
37 $(OBJS): .Compiler-config
38
39 #
40 # Subsystem-specific rules and targets
41 #
42
43 ifeq ("$(CONFIG_MAINTAINER_MODE)","y")
44
45 do-all: Checkinitcalls Circular-ok ToDoItems compilertest $(ALL)
46 ifeq ($(CONFIG_XARCH),ux)
47 # disabled until unittests fixed
48 #do-all: unittest
49 endif # UX
50
51 else  # ! maintainer mode
52
53 do-all: compilertest $(ALL)
54
55 endif # ! maintainer mode
56
57 compilertest:
58 ifeq ($(CCVER_MAJOR),2)
59         @$(ECHO_E) "\033[31m\n"\
60   "  ERROR: gcc version "$(CCVER_MAJOR).$(CCVER_MINOR)" is not supported for"\
61   "Fiasco -- \n"\
62   "         please update gcc to version 3.{3-4}.\033[m\n"; exit -1
63 endif
64 ifeq ($(CCVER_MAJOR),3)
65 ifeq ($(findstring $(CCVER_MINOR),2 3 4),)
66         @$(ECHO_E) "\033[31m\n"\
67   "  WARNING: gcc version $(CCVER_MAJOR).$(CCVER_MINOR) is not supported for"\
68   "Fiasco -- please use gcc\n"\
69   "           version 3.{3-4}. Be prepared to observe bugs in this kernel!\n"\
70   "           Don't use this kernel for performance analysis!\033[m\n"
71 endif
72 endif
73
74 Checkinitcalls: $(KERNEL) $(OBJ_KERNEL)
75 ifneq ($(shell $(CXX) -dumpversion | cut -d . -f1-2),3.4)
76         @echo "Checking initcalls"
77         $(VERBOSE)$(srcdir)/../tool/checkinitcalls \
78           -k fiasco.image \
79           -Werror $(filter-out fiasco.image, $^) \
80           $(if $(SYSTEM_TARGET),-t $(SYSTEM_TARGET)) && \
81         echo "Initcalls OK"
82 else
83         @echo "Initcall check disabled due to gcc-3.4"
84 endif
85
86 ToDoItems:
87         @files=$$(cd $(srcdir) &&                                            \
88                   find . -type f -name '*.cpp' -o -name '*.cc' -o            \
89                                  -name '*.h' -o -name '*.S' -o -name '*.h'); \
90         fixme=$$(cd $(srcdir) && cat $$files | grep -wc FIXME);              \
91         XXX=$$(cd $(srcdir) && cat $$files | grep -wc XXX);                  \
92         if [ "$$fixme" -ne "0" -o "$$XXX" -ne "0" ]; then                    \
93            echo "Found $$fixme times 'FIXME' and $$XXX times 'XXX'";         \
94         fi
95
96 doc: docs/stamp-doc.ready
97
98 docs/stamp-doc.ready: $(foreach m, $(GENERATED_MODULES), auto/stamp-$(m).ready)
99         @mkdir -p docs
100         @touch $@
101         @doxygen $(srcdir)/doxygen.conf
102
103 ###
104
105 # Make function "makedeps":  Creates (on stdout) a list of Make-like
106 # dependencies in a format suitable for $(SHOWDEPS).  Expects a list
107 # of source (BASE-suffix.{cpp,cc,c}, BASE[_i].h) files as input and extracts
108 # include directives from them.  Dependecies contain only basenames of
109 # files (up to the first "-").  Suffixes and extensions are stripped.
110 makedeps= implname () { echo $$1 | sed 's|.*/||; s|_i\.h|.h|; s|[.-].*||;'; };\
111           for i in $(1); \
112           do \
113             echo $$(implname $$i): $$(perl -n -e \
114               '/^\s*\#include\s+["<](.*).h[">]/ && print "$$1 "; next;' \
115               $$i); \
116           done 
117
118 DEPS:   $(SRC_ALL) $(foreach idir, $(PRIVATE_INCDIR), $(wildcard $(idir)/*.h))
119         $(call makedeps, $^) | $(SHOWDEPS) > $@.new
120         mv $@.new $@
121
122 # Graphical version of DEPS dependency graph.
123
124 # XXX DEPS.{dot,ps} only contain dependency graphs for the KERNEL and
125 # LIBK subsystem.  Also, we remove a number of top-level and low-level
126 # modules from the resulting graph to reduce the overwhelming number
127 # of edges; however, `gendotdeps' ensures that modules participating
128 # in circular dependencies are never removed.
129
130 GENDOT_FLAGS ?= -t1u1
131
132 KERNEL_MODULES_CPP = $(foreach mod, $(INTERFACES_KERNEL) $(INTERFACES_LIBK), \
133         $(addsuffix .cpp,$(call eval_impl,$(mod)))) \
134         $(foreach idir, $(srcdir)/kern $(srcdir)/kern/shared \
135                         $(srcdir)/kern/$(CONFIG_XARCH), \
136           $(wildcard $(idir)/*.h))
137
138 ifeq ($(CONFIG_XARCH),ux)
139 EXTRA_INCLUDES = -I/usr/include/c++/$(shell $(CXX) -dumpversion) -I/usr/include
140 endif
141
142 DEPS.dot: $(KERNEL_MODULES_CPP)
143         @echo -n > source_files.mkdeps
144         @for f in $^ ; do \
145            echo $$f >> source_files.mkdeps ; \
146          done
147         $(srcdir)/../tool/gendotdeps \
148           -E "$(PREPROCESS_PARTS)" $(addprefix -I,$(PRIVATE_INCDIR)) \
149           $(EXTRA_INCLUDES) $(addprefix --vpath=,$(VPATH)) $(GENDOT_FLAGS) \
150           -v -b $(srcdir)/DEPS.blacklist source_files.mkdeps -o $@ || $(RM) $@
151         @$(RM) source_files.mkdeps
152
153 %.ps:   %.dot
154         dot -Tps -Gmclimit=200.0 -Gnslimit=500.0 \
155           -Gsize=11,10 -Grotate=90 -o $@ $<
156
157 %.a4.ps: %.dot
158         dot -Tps -Gmclimit=200.0 -Gnslimit=500.0 \
159           -Gsize="11,8" -Granksep=0.7 -Grotate=90 -o $@ $<
160
161 %.tred.ps: %.dot
162         tred $< | dot -Tps -Gmclimit=200.0 -Gnslimit=500.0 \
163           -Gsize="11,8" -Granksep=0.7 -Grotate=90 -o $@ 
164
165 %.svg:  %.dot
166         dot -Tsvg -Gmclimit=200.0 -Gnslimit=500.0 \
167           -Gsize=11,10 -Grotate=90 -o $@ $<
168
169 %.a4.svg: %.dot
170         dot -Tsvg -Gmclimit=200.0 -Gnslimit=500.0 \
171           -Gsize="11,8" -Granksep=0.7 -Grotate=90 -o $@ $<
172
173 %.tred.svg: %.dot
174         tred $< | dot -Tsvg -Gmclimit=200.0 -Gnslimit=500.0 \
175           -Gsize="11,8" -Granksep=0.7 -Grotate=90 -o $@ 
176
177
178 ###
179
180 # Circular should really be dependent on $(DEPS). However, we cannot
181 # enforce that all $(DEPS) are made before this target, because the
182 # Makefile contains "-include $(DEPS)" (which can result in Circular
183 # being created/updated before all $(DEPS) are).  Therefore, depend on
184 # the fiasco.image and on main (not with Fiasco-UX). Once this is made,
185 # we know all $(DEPS) have been updated.
186 Circular: $(KERNEL) $(BOOT) $(RUN_TESTS) $(CHECKSUM)
187         @echo "Creating $@"
188         @( \
189           echo 'Do "make DEPS" for full fine-grained dependency information.';\
190           for i in $(DEPS); \
191           do \
192             $(PREPROCESSDEPS) $$i; \
193           done | $(SHOWDEPS) | $(CIRCULAR) \
194         ) > $@.new
195         @mv $@.new $@
196
197 # Create a Circular.max file for the first time.  Usually this target
198 # is not needed -- there should be a Circular.max file in the CVS.
199 $(srcdir)/Circular.max.$(CONFIG_XARCH): 
200 # Circular is not in the dependencies because we do not want a new
201 # copy of Circular.max every time Circular changes.  We nevertheless
202 # need it to so the copy -- so create it explicitly
203         $(MAKE) -f $(srcdir)/Makefile.sub2 Circular
204         cp Circular $@
205
206 # Check that the number of circular dependency has not increased in
207 # this build.
208 .PHONY: Circular-ok
209 Circular-ok: $(srcdir)/Circular.max.$(CONFIG_XARCH) Circular
210 # Circular.max.* must be the first dependency:  We are going to
211 # reference it as $<.
212         @ max=$$(tail -1 $<); \
213           current=$$(tail -1 Circular); \
214           if [ $$current -gt $$max ]; \
215           then \
216             echo "Number of circular dependencies increased!"; \
217             diff -up $< Circular; \
218             exit 1; \
219           fi; \
220           echo "Circular-dependency check OK ($$current <= $$max)"
221
222 ###
223
224 .PHONY: TAGS tags
225
226 # Find directories for source and header files.  There may be
227 # duplicates, so weed out the list using a tiny Perl script.
228 define source-files
229         ( find $(shell perl -e '                                   \
230                 %seen = ();                                        \
231                 foreach $$i (@ARGV) {                              \
232                     next if ! -e $$i || $$i eq ".";                \
233                     next if defined $$seen{$$i};                   \
234                     $$seen{$$i} = 1;                               \
235                     print "$$i ";                                  \
236                 }' $(filter-out auto, $(VPATH) $(PRIVATE_INCDIR))) \
237           -maxdepth 1 -type f -name '*.cpp' -o -name '*.h'         \
238           -o -name '*.cc' -o -name '*.c' )
239 endef
240
241 TAGS:
242         $(source-files) | etags --members --language=c++ -
243
244 tags:
245         $(source-files) | ctags --members --language=c++ -d -w -T -
246
247