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