]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/Makefile
update
[l4.git] / l4 / pkg / Makefile
1 # GLOBAL Makefile for all packages
2 #
3 # DO NOT EDIT -- Automatically generated by Adam's configuration system!!!
4 #
5
6 IGNORE_OBJDIR_TARGETS := up update
7
8 L4DIR ?= ..
9 include $(L4DIR)/mk/Makeconf
10
11 BID_STATE_FILE = $(OBJ_BASE)/pkg/BUILD.state
12
13 # all our packages
14 ALL_SUBDIRS     = $(shell find -L . -maxdepth 1 -type d ! -name .svn -printf %P' ')
15
16 ifneq ($(S),)
17   ALL_SUBDIRS := $(shell echo $(S) | tr ':,' ' ')
18 endif
19
20 # the broken packages
21 BROKEN_SUBDIRS  = $(patsubst %/broken, %, \
22                         $(wildcard $(addsuffix /broken,$(ALL_SUBDIRS))))
23 # the obsolete packages
24 OBSOLETE_SUBDIRS = $(patsubst %/obsolete, %, \
25                         $(wildcard $(addsuffix /obsolete,$(ALL_SUBDIRS))))
26 # and the packages we are supposed to build
27 BUILD_SUBDIRS  = $(filter-out $(BROKEN_SUBDIRS) $(OBSOLETE_SUBDIRS), \
28                    $(ALL_SUBDIRS))
29
30 # force that every package to be built has a Control and Makefile
31 ifneq ($(addsuffix /Makefile,$(BUILD_SUBDIRS)),$(wildcard $(addsuffix /Makefile,$(BUILD_SUBDIRS))))
32 $(error Missing Makefile files: $(filter-out $(wildcard $(addsuffix /Makefile,$(BUILD_SUBDIRS))), $(addsuffix /Makefile,$(BUILD_SUBDIRS))))
33 endif
34 ifeq ($(S),)
35 ifneq ($(addsuffix /Control,$(BUILD_SUBDIRS)),$(wildcard $(addsuffix /Control,$(BUILD_SUBDIRS))))
36 $(error Missing Control files: $(filter-out $(wildcard $(addsuffix /Control,$(BUILD_SUBDIRS))), $(addsuffix /Control,$(BUILD_SUBDIRS))))
37 endif
38 endif
39
40 #####################
41 # Rules begin.
42 # We start with cont-checking, as this requires special treatment
43 ifeq ($(filter cont,$(MAKECMDGOALS)),)
44
45 #####################
46 # default make action is "all" - build all packages
47 #
48 # We build all l4env headers (idl+includes), then all l4env libs, then the
49 # l4env servers and examples. Then we build the other headers
50 # (idl+includes), the other libs, the other servers and examples. We use
51 # dependencies for this, witch might allow parallel build processes.
52 #
53
54 all:: $(BUILD_SUBDIRS)
55
56 examples: $(filter-out examples,$(BUILD_SUBDIRS))
57
58 #####################
59 # cont handling
60 -include $(BID_STATE_FILE)
61 BID_cont_reset:
62         $(VERBOSE)$(RM) $(BID_STATE_FILE)
63 BID_SAFE_STATE= @echo 'BID_STATE_DONE+=$@'>>$(BID_STATE_FILE)
64
65 .PHONY: all BID_cont_reset cont bin lib headers idl include doc ptest
66 .PHONY: rm-old-links
67
68 DOC_MESSAGE       =echo "=== Creating documentation for package \"$(1)\" ==="
69 PKG_MESSAGE       =echo "=== Building package \"$(basename $@)\" ==="
70 INST_MESSAGE      =echo "=== Installing Package \"$(1)\" ==="
71 PURGE_INC_MESSAGE =echo "=== Purging pending links in $(L4DIR)/include ==="
72 PURGE_LIB_MESSAGE =echo "=== Purging pending links in $(L4DIR)/lib ==="
73 UPDATE_MESSAGE    =echo -e $(EMPHSTART)"=== Updating \"$(1)\" ==="$(EMPHSTOP)
74 PTEST_MESSAGE     =echo "=== Testing Package \"$(1)\" ==="
75
76 # given order matters
77 ALIASES_DIRS = $(L4DIR)/mk/aliases.d \
78                $(wildcard $(OBJ_BASE)/aliases.d)
79
80 PKGDEPS_CMD  = $(L4DIR)/mk/pkgdeps \
81                      -P $(OBJ_BASE)/pc $(addprefix -A ,$(ALIASES_DIRS))
82
83 ifneq ($(OBJ_BASE),)
84 $(OBJ_BASE)/pc:
85         $(VERBOSE)mkdir -p $(OBJ_BASE)/pc
86
87 # deps on disappearing aliases.d-files are not handled...
88 $(OBJ_BASE)/pkg/.Package.deps: $(L4DIR)/mk/pkgdeps Makefile \
89                                $(wildcard $(foreach d,$(ALIASES_DIRS),$(d)/*)) \
90                                $(OBJ_BASE)/pc \
91                                $(wildcard $(foreach d,$(BUILD_SUBDIRS),$(d)/Control))
92         $(VERBOSE)mkdir -p $(dir $@)
93         $(VERBOSE)if $(PKGDEPS_CMD) \
94           generate $(L4DIR)/pkg > $@.tmp; then \
95             mv $@.tmp $@; else $(RM) $@.tmp; exit 1; fi
96
97 include $(OBJ_BASE)/pkg/.Package.deps
98 endif
99
100 $(BUILD_SUBDIRS):%:%/Makefile BID_cont_reset
101         @$(PKG_MESSAGE)
102         $(VERBOSE)PWD=$(PWD)/$(basename $@) $(MAKE) -C $(basename $@) all
103         $(VERBOSE)$(BID_SAFE_STATE)
104
105 install::
106         $(VERBOSE)set -e; for i in $(BUILD_SUBDIRS); do \
107           $(call INST_MESSAGE,$(BID_DOLLARQUOTE)$$i); \
108           PWD=$(PWD)/$$i $(MAKE) -C $$i $@; \
109         done
110
111 doc:
112         $(VERBOSE)set -e; for i in $(BUILD_SUBDIRS); do \
113           if [ -e $(PWD)/$$i/doc ]; then                \
114           $(call DOC_MESSAGE,$(BID_DOLLARQUOTE)$$i);    \
115           PWD=$(PWD)/$$i $(MAKE) -C $$i $@;             \
116           fi;                                           \
117         done
118
119 # Check package dependencies.
120 #   CHECK_PKGS: if undefined, check all packages,
121 #               otherwise gives a list of space separated packages to check
122 #   CHECK_FULL: if set rebuild for every new package check
123 #                 (ccache recommended when using this flag)
124 depcheck:
125         $(VERBOSE)set -e; \
126         $(RM) -r $(OBJ_BASE)/pkg; \
127         for checkpkg in $(filter-out $(CHECK_GOOD),$(if $(CHECK_PKGS),$(CHECK_PKGS),$(BUILD_SUBDIRS))); do \
128           echo ==========================================================;     \
129           echo "Deleting all pkgs in build-dir";                               \
130           $(RM) -r $(OBJ_BASE)/lib $(OBJ_BASE)/bin $(OBJ_BASE)/include         \
131                    $(OBJ_BASE)/pc;                                             \
132           $(if $(CHECK_FULL),$(RM) -r $(OBJ_BASE)/pkg;,)                       \
133           echo "Done";                                                         \
134           echo ----------------------------------------------------------;     \
135           echo "Trying standalone build of '$$checkpkg'";                      \
136           echo $(MAKE) O=$(OBJ_BASE) --no-print-directory $$checkpkg;          \
137           $(MAKE) O=$(OBJ_BASE) --no-print-directory $$checkpkg                \
138             || (echo "Failed package: $$checkpkg";                             \
139                 echo "Good package(s): CHECK_GOOD=\"$(CHECK_GOOD) $$PKGDONE\"";\
140                 exit 1) || exit 1;                                             \
141           PKGDONE="$$PKGDONE $$checkpkg";                                      \
142         done;                                                                  \
143         echo "Packages     tested: $(CHECK_GOOD) $$PKGDONE"
144
145 depgraph: depsrcgraph depobjgraph
146 depsrcgraph: $(PKGDIR_OBJ)/depsrc.svg $(PKGDIR_OBJ)/depsrc.ps $(PKGDIR_OBJ)/depsrc.reduced.svg $(PKGDIR_OBJ)/depsrc.reduced.ps
147 depobjgraph: $(PKGDIR_OBJ)/depobj.svg $(PKGDIR_OBJ)/depobj.ps $(PKGDIR_OBJ)/depobj.reduced.svg $(PKGDIR_OBJ)/depobj.reduced.ps
148
149 %.ps: %.dot
150         @$(GEN_MESSAGE)
151         $(VERBOSE)dot -Tps -o $@ $<
152
153 %.svg: %.dot
154         @$(GEN_MESSAGE)
155         $(VERBOSE)dot -Tsvg -o $@ $<
156
157 %.reduced.dot: %.dot
158         @$(GEN_MESSAGE)
159         $(VERBOSE)tred $< > $@
160
161 $(PKGDIR_OBJ)/depsrc.dot: FORCE 
162         @$(GEN_MESSAGE)
163         $(VERBOSE)$(PKGDEPS_CMD) dot $(L4DIR)/pkg > $@
164
165 $(PKGDIR_OBJ)/depobj.dot: FORCE
166         @$(GEN_MESSAGE)
167         $(VERBOSE)$(L4DIR)/tool/bin/pkgdepsobj $(L4DIR_ABS) $(OBJ_BASE) $@
168
169 ptest:
170         $(VERBOSE)set -e; \
171         for d in $(BUILD_SUBDIRS); do \
172           if [ -n "$$(find $$d -type d -name $@)" ]; then \
173             $(call PTEST_MESSAGE,$(BID_DOLLARQUOTE)$$d); \
174             PWD=$(PWD)/$$d $(MAKE) -C $$d $@; \
175           fi; \
176         done
177
178 TAGS:
179         $(ETAGS)
180
181 tags:
182         $(CTAGS)
183
184 .PHONY: TAGS tags depsrcgraph depobjgraph depgraph
185 .PHONY: $(foreach ext, .bin .lib .include .idl .headers,addsuffix $(ext), $(BUILD_SUBDIRS))
186
187 clean cleanall:: BID_cont_reset
188 clean cleanall::
189         $(VERBOSE)$(RM) $(UPDATE_LOG)
190         $(VERBOSE)for i in $(BUILD_SUBDIRS) $(OBSOLETE_SUBDIRS); do \
191           echo "=== Cleaning in package  \"$$i\" ==="; \
192           if [ -r $$i/Makefile ] ; then PWD=$(PWD)/$$i $(MAKE) -C $$i $@; fi ; \
193         done
194         $(VERBOSE)$(MAKE) rm-old-links
195
196 del-backup:
197         $(VERBOSE)rm -i `find . -name "*~"` `find . -name "#*#"`
198
199 rm-old-links:
200         @$(PURGE_INC_MESSAGE)
201         $(VERBOSE)test ! -d $(L4DIR)/include || \
202           find $(L4DIR)/include -type l -a ! -xtype f -a ! -xtype d \
203             -exec rm $(if $(VERBOSE),,-v) '{}' ';'
204         @$(PURGE_LIB_MESSAGE)
205         $(VERBOSE)test ! -d $(L4DIR)/lib || \
206           find $(L4DIR)/lib -type l -a ! -xtype f -a ! -xtype d \
207             -exec rm $(if $(VERBOSE),,-v) '{}' ';'
208
209
210 # Update Makefile on update.
211 ifneq ($(filter update up,$(MAKECMDGOALS)),)
212 .PHONY: Makefile
213 Makefile: update.log
214         $(SVN) up $@ 2>&1 | tee -a $(UPDATE_LOG)
215 endif
216
217 UPDATE_LOG = $(call absfilename, $(L4DIR)/pkg/update.log)
218 .PHONY: update.log
219 update.log:
220         $(VERBOSE)$(RM) $(UPDATE_LOG)
221
222 update up: update.log
223         $(VERBOSE)$(call UPDATE_MESSAGE,Packages)
224         $(VERBOSE)set -e ; \
225             $(SVN) update $(sort $(patsubst %/.svn,%,$(wildcard $(addsuffix /.svn,$(ALL_SUBDIRS))))) 2>&1 | tee -a $(UPDATE_LOG)
226
227 #dice_update: update.log
228 #       $(VERBOSE)if [ -d $(DICE_SRCDIR) ] ; then \
229 #               $(call UPDATE_MESSAGE,$(DICE_SRCDIR)); \
230 #               cd $(DICE_SRCDIR) && $(SVN) update 2>&1 | tee -a $(UPDATE_LOG); \
231 #       fi
232
233 tools_update: update.log
234         $(VERBOSE)if [ -d $(L4DIR)/tool/gen_dopecode ]; then \
235                 $(call UPDATE_MESSAGE,l4/tool/gen_dopecode); \
236                 cd $(L4DIR) && \
237                 $(SVN) update tool/gen_dopecode 2>&1 | tee -a $(UPDATE_LOG); \
238         fi
239         @$(call UPDATE_MESSAGE,l4/tool/gendep)
240         $(VERBOSE)cd $(L4DIR) && \
241                 $(SVN) update tool/gendep 2>&1 | tee -a $(UPDATE_LOG)
242         @$(call UPDATE_MESSAGE,l4/tool/bin)
243         $(VERBOSE)cd $(L4DIR) && \
244                 $(SVN) update tool/bin 2>&1 | tee -a $(UPDATE_LOG)
245
246 l4conf_update: update.log
247         @$(call UPDATE_MESSAGE,l4/Make{confs/files})
248         $(VERBOSE)cd .. && \
249                 $(SVN) update Makefile 2>&1 | tee -a $(UPDATE_LOG)
250         @$(call UPDATE_MESSAGE,l4/mk/)
251         $(VERBOSE)cd ../mk && \
252                 $(SVN) update 2>&1 | tee -a $(UPDATE_LOG)
253
254 relocate:
255         @for i in $(BUILD_SUBDIRS); do                                  \
256              if [ -f $$i/server/src/Makefile ]; then                    \
257                echo "=== Building \"$$i\" relocatable ===";             \
258                PWD=$(PWD)/$$i/server/src $(MAKE) -C $$i/server/src reloc;\
259              else                                                       \
260                echo "( Package \"$$i\" has no server/src dir )";        \
261              fi                                                         \
262          done;                                                          \
263
264 relink:
265         @for i in $(BUILD_SUBDIRS); do                                  \
266              if [ -f $$i/server/Makefile ]; then                        \
267                echo "=== Re-linking \"$$i\" server ===";                \
268                PWD=$(PWD)/$$i/server $(MAKE) -C $$i/server relink;      \
269              else                                                       \
270                echo "( Package \"$$i\" has no server dir )";    \
271              fi;                                                        \
272              if [ -f $$i/examples/Makefile ]; then                      \
273                echo "=== Re-linking \"$$i\" examples ===";              \
274                PWD=$(PWD)/$$i/examples $(MAKE) -C $$i/examples relink;  \
275              else                                                       \
276                echo "( Package \"$$i\" has no examples dir )";          \
277              fi;                                                        \
278          done;                                                          \
279
280 # global defines
281
282 .PHONY:         install clean cleanall kernels
283
284
285 l4_utcb-users:
286         $(VERBOSE)$(ECHO) "Packages using l4_utcb():"
287         $(VERBOSE)for p in $(BUILD_SUBDIRS); do \
288           x=$$(find $$p ! -path '*/.svn/*' -type f | xargs grep -w l4_utcb); \
289           if [ -n "$$x" ]; then \
290             echo "   $$p"; \
291           fi \
292         done
293
294
295 print-subdirs:
296         @echo $(BUILD_SUBDIRS)
297         @echo obsolete: $(OBSOLETE_SUBDIRS)
298         @echo broken: $(BROKEN_SUBDIRS)
299
300 help:
301         @echo "Specify one of the following targets:"
302         @echo "all             - build the packages neither broken nor obsolete"
303         @echo "cont            - after correcting errors, continue where \"make all\" failed"
304         @echo "doc             - build documentation (not build per default)"
305         @echo "install         - install the packages, use only after making all!"
306         @echo
307         @echo "clean           - clean the packages"
308         @echo "cleanall        - clean the packages pedanticly"
309         @echo "del-backup      - remove temporary file in this tree"
310 #       @echo "l4conf_update   - cvsupdate the diverse Makeconf.* in the L4DIR"
311         @echo "print-subdirs   - print the SUBDIRS which are subject to build"
312 #       @echo "relink          - rebuild servers and examples"
313 #       @echo "relocate        - building the relocatable binaries in the dirs"
314         @echo "BID_cont_reset  - reset the state used by the \"cont\" target"
315         @echo 'rm-old-links    - remove invalid symlinks in $$(L4DIR)/lib, $$(L4DIR)/include'
316         @echo "update          - update the packages currently checked out"
317         @echo "help            - this help"
318
319 #####################
320 # cont handling: "cont" is in the target list
321 else
322 -include $(BID_STATE_FILE)
323 cont:
324         $(VERBOSE)$(MAKE) $(addprefix -o ,BID_cont_reset $(BID_STATE_DONE)) \
325                 $(filter-out cont,$(MAKECMDGOALS))
326
327 # eat up the other targets
328 .DEFAULT:
329         @true
330 endif 
331