]> 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 $(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: $(ALL)
54
55 endif # ! maintainer mode
56
57
58 Checkinitcalls: $(KERNEL) $(OBJ_KERNEL)
59 ifneq ($(shell $(CXX) -dumpversion | cut -d . -f1-2),3.4)
60         @echo "Checking initcalls"
61         $(VERBOSE)$(srcdir)/../tool/checkinitcalls \
62           -k fiasco.image \
63           -Werror $(filter-out fiasco.image, $^) \
64           $(if $(CROSS_COMPILE),-t $(CROSS_COMPILE)) && \
65         echo "Initcalls OK"
66 else
67         @echo "Initcall check disabled due to gcc-3.4"
68 endif
69
70 TOOL_GDB_DIR=$(srcdir)/../tool/gdb
71 GDB ?= gdb-multiarch
72
73 gdb: fiasco.image
74         $(VERBOSE)FIASCO_TOOL_GDB_DIR=$(TOOL_GDB_DIR) \
75          $(GDB) -x $(TOOL_GDB_DIR)/interactive.gdb fiasco.image
76
77 gen_ktrace_events.h: fiasco.image
78         $(VERBOSE)FIASCO_TOOL_GDB_DIR=$(TOOL_GDB_DIR) \
79          $(GDB) --batch -x $(TOOL_GDB_DIR)/gen_ktrace_events.gdb \
80                        fiasco.image
81
82 ToDoItems:
83         @files=$$(cd $(srcdir) &&                                            \
84                   find . -type f -name '*.cpp' -o -name '*.cc' -o            \
85                                  -name '*.h' -o -name '*.S' -o -name '*.h'); \
86         fixme=$$(cd $(srcdir) && cat $$files | grep -wc FIXME);              \
87         XXX=$$(cd $(srcdir) && cat $$files | grep -wc XXX);                  \
88         if [ "$$fixme" -ne "0" -o "$$XXX" -ne "0" ]; then                    \
89            echo "Found $$fixme times 'FIXME' and $$XXX times 'XXX'";         \
90         fi
91
92 doc: docs/stamp-doc.ready
93
94 docs/stamp-doc.ready: $(srcdir)/doxygen.conf $(foreach m, $(GENERATED_MODULES), auto/stamp-$(m).ready)
95         @mkdir -p docs
96         @touch $@
97         $(VERBOSE)doxygen $(srcdir)/doxygen.conf
98
99 ###
100
101 # Make function "makedeps":  Creates (on stdout) a list of Make-like
102 # dependencies in a format suitable for $(SHOWDEPS).  Expects a list
103 # of source (BASE-suffix.{cpp,cc,c}, BASE[_i].h) files as input and extracts
104 # include directives from them.  Dependecies contain only basenames of
105 # files (up to the first "-").  Suffixes and extensions are stripped.
106 makedeps= implname () { echo $$1 | sed 's|.*/||; s|_i\.h|.h|; s|[.-].*||;'; };\
107           for i in $(1); \
108           do \
109             echo $$(implname $$i): $$(perl -n -e \
110               '/^\s*\#include\s+["<](.*).h[">]/ && print "$$1 "; next;' \
111               $$i); \
112           done 
113
114 DEPS:   $(SRC_ALL) $(foreach idir, $(PRIVATE_INCDIR), $(wildcard $(idir)/*.h))
115         $(call makedeps, $^) | $(SHOWDEPS) > $@.new
116         mv $@.new $@
117
118 # Graphical version of DEPS dependency graph.
119
120 # XXX DEPS.{dot,ps} only contain dependency graphs for the KERNEL and
121 # LIBK subsystem.  Also, we remove a number of top-level and low-level
122 # modules from the resulting graph to reduce the overwhelming number
123 # of edges; however, `gendotdeps' ensures that modules participating
124 # in circular dependencies are never removed.
125
126 GENDOT_FLAGS ?= -t1u1
127
128 KERNEL_MODULES_CPP = $(foreach mod, $(INTERFACES_KERNEL) $(INTERFACES_LIBK), \
129         $(addsuffix .cpp,$(call eval_impl,$(mod)))) \
130         $(foreach idir, $(srcdir)/kern $(srcdir)/kern/shared \
131                         $(srcdir)/kern/$(CONFIG_XARCH), \
132           $(wildcard $(idir)/*.h))
133
134 ifeq ($(CONFIG_XARCH),ux)
135 EXTRA_INCLUDES = -I/usr/include/c++/$(shell $(CXX) -dumpversion) -I/usr/include
136 endif
137
138 DEPS.dot: $(KERNEL_MODULES_CPP)
139         @echo -n > source_files.mkdeps
140         @for f in $^ ; do \
141            echo $$f >> source_files.mkdeps ; \
142          done
143         $(srcdir)/../tool/gendotdeps \
144           -E "$(PREPROCESS_PARTS)" $(addprefix -I,$(PRIVATE_INCDIR)) \
145           $(EXTRA_INCLUDES) $(addprefix --vpath=,$(VPATH)) $(GENDOT_FLAGS) \
146           -v -b $(srcdir)/DEPS.blacklist source_files.mkdeps -o $@ || $(RM) $@
147         @$(RM) source_files.mkdeps
148
149 %.ps:   %.dot
150         dot -Tps -Gmclimit=200.0 -Gnslimit=500.0 \
151           -Gsize=11,10 -Grotate=90 -o $@ $<
152
153 %.a4.ps: %.dot
154         dot -Tps -Gmclimit=200.0 -Gnslimit=500.0 \
155           -Gsize="11,8" -Granksep=0.7 -Grotate=90 -o $@ $<
156
157 %.tred.ps: %.dot
158         tred $< | dot -Tps -Gmclimit=200.0 -Gnslimit=500.0 \
159           -Gsize="11,8" -Granksep=0.7 -Grotate=90 -o $@ 
160
161 %.svg:  %.dot
162         dot -Tsvg -Gmclimit=200.0 -Gnslimit=500.0 \
163           -Gsize=11,10 -Grotate=90 -o $@ $<
164
165 %.a4.svg: %.dot
166         dot -Tsvg -Gmclimit=200.0 -Gnslimit=500.0 \
167           -Gsize="11,8" -Granksep=0.7 -Grotate=90 -o $@ $<
168
169 %.tred.svg: %.dot
170         tred $< | dot -Tsvg -Gmclimit=200.0 -Gnslimit=500.0 \
171           -Gsize="11,8" -Granksep=0.7 -Grotate=90 -o $@ 
172
173
174 ###
175
176 # Circular should really be dependent on $(DEPS). However, we cannot
177 # enforce that all $(DEPS) are made before this target, because the
178 # Makefile contains "-include $(DEPS)" (which can result in Circular
179 # being created/updated before all $(DEPS) are).  Therefore, depend on
180 # the fiasco.image and on main (not with Fiasco-UX). Once this is made,
181 # we know all $(DEPS) have been updated.
182 Circular: $(KERNEL) $(BOOT) $(RUN_TESTS) $(CHECKSUM)
183         @echo "Creating $@"
184         @( \
185           echo 'Do "make DEPS" for full fine-grained dependency information.';\
186           for i in $(DEPS); \
187           do \
188             $(PREPROCESSDEPS) $$i; \
189           done | $(SHOWDEPS) | $(CIRCULAR) \
190         ) > $@.new
191         @mv $@.new $@
192
193 # Create a Circular.max file for the first time.  Usually this target
194 # is not needed -- there should be a Circular.max file in the CVS.
195 $(srcdir)/Circular.max.$(CONFIG_XARCH): 
196 # Circular is not in the dependencies because we do not want a new
197 # copy of Circular.max every time Circular changes.  We nevertheless
198 # need it to so the copy -- so create it explicitly
199         $(MAKE) -f $(srcdir)/Makefile.sub2 Circular
200         cp Circular $@
201
202 # Check that the number of circular dependency has not increased in
203 # this build.
204 .PHONY: Circular-ok
205 Circular-ok: $(srcdir)/Circular.max.$(CONFIG_XARCH) Circular
206 # Circular.max.* must be the first dependency:  We are going to
207 # reference it as $<.
208         @ max=$$(tail -1 $<); \
209           current=$$(tail -1 Circular); \
210           if [ $$current -gt $$max ]; \
211           then \
212             echo "Number of circular dependencies increased!"; \
213             diff -up $< Circular; \
214             exit 1; \
215           fi; \
216           echo "Circular-dependency check OK ($$current <= $$max)"
217
218 ###
219
220 .PHONY: TAGS tags
221
222 # Find directories for source and header files.  There may be
223 # duplicates, so weed out the list using a tiny Perl script.
224 define source-files
225         ( find $(shell perl -e '                                   \
226                 %seen = ();                                        \
227                 foreach $$i (@ARGV) {                              \
228                     next if ! -e $$i || $$i eq ".";                \
229                     next if defined $$seen{$$i};                   \
230                     $$seen{$$i} = 1;                               \
231                     print "$$i ";                                  \
232                 }' $(filter-out auto, $(VPATH) $(PRIVATE_INCDIR))) \
233           -maxdepth 1 -type f -name '*.cpp' -o -name '*.h'         \
234           -o -name '*.cc' -o -name '*.c' )
235 endef
236
237 TAGS:
238         $(source-files) | etags --members --language=c++ -
239
240 tags:
241         $(source-files) | ctags --members --language=c++ -d -w -T -
242
243