]> 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 diff
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 DIFF_MESSAGE      =echo -e $(EMPHSTART)"=== Diffing \"$(1)\" ==="$(EMPHSTOP)
75 PTEST_MESSAGE     =echo "=== Testing Package \"$(1)\" ==="
76
77 # given order matters
78 ALIASES_DIRS = $(L4DIR)/mk/aliases.d \
79                $(wildcard $(OBJ_BASE)/aliases.d)
80
81 PKGDEPS_CMD  = $(L4DIR)/mk/pkgdeps \
82                      -P $(OBJ_BASE)/pc $(addprefix -A ,$(ALIASES_DIRS))
83
84 ifneq ($(OBJ_BASE),)
85 $(OBJ_BASE)/pc:
86         $(VERBOSE)mkdir -p $(OBJ_BASE)/pc
87
88 # deps on disappearing aliases.d-files are not handled...
89 $(OBJ_BASE)/pkg/.Package.deps: $(L4DIR)/mk/pkgdeps \
90                                $(if $(filter update up,$(MAKECMDGOALS)),Makefile) \
91                                $(wildcard $(foreach d,$(ALIASES_DIRS),$(d)/*)) \
92                                $(OBJ_BASE)/pc \
93                                $(wildcard $(foreach d,$(BUILD_SUBDIRS),$(d)/Control))
94         $(VERBOSE)mkdir -p $(dir $@)
95         $(VERBOSE)if $(PKGDEPS_CMD) \
96           generate $(L4DIR)/pkg > $@.tmp; then \
97             mv $@.tmp $@; else $(RM) $@.tmp; exit 1; fi
98
99 include $(OBJ_BASE)/pkg/.Package.deps
100 endif
101
102 $(BUILD_SUBDIRS):%:%/Makefile BID_cont_reset
103         @$(PKG_MESSAGE)
104         $(VERBOSE)PWD=$(PWD)/$(basename $@) $(MAKE) -C $(basename $@) all
105         $(VERBOSE)$(BID_SAFE_STATE)
106
107 install::
108         $(VERBOSE)set -e; for i in $(BUILD_SUBDIRS); do \
109           $(call INST_MESSAGE,$(BID_DOLLARQUOTE)$$i); \
110           PWD=$(PWD)/$$i $(MAKE) -C $$i $@; \
111         done
112
113 doc:
114         $(VERBOSE)set -e; for i in $(BUILD_SUBDIRS); do \
115           if [ -e $(PWD)/$$i/doc ]; then                \
116           $(call DOC_MESSAGE,$(BID_DOLLARQUOTE)$$i);    \
117           PWD=$(PWD)/$$i $(MAKE) -C $$i $@;             \
118           fi;                                           \
119         done
120
121 # Check package dependencies.
122 #   CHECK_PKGS: if undefined, check all packages,
123 #               otherwise gives a list of space separated packages to check
124 #   CHECK_FULL: if set rebuild for every new package check
125 #                 (ccache recommended when using this flag)
126 depcheck:
127         $(VERBOSE)set -e; \
128         $(RM) -r $(filter-out $(OBJ_BASE)/pkg/Makefile,       \
129                               $(wildcard $(OBJ_BASE)/pkg/*)); \
130         for checkpkg in $(filter-out $(CHECK_GOOD),$(if $(CHECK_PKGS),$(CHECK_PKGS),$(BUILD_SUBDIRS))); do \
131           echo ==========================================================;     \
132           echo "Deleting all pkgs in build-dir";                               \
133           $(RM) -r $(OBJ_BASE)/lib $(OBJ_BASE)/bin $(OBJ_BASE)/include         \
134                    $(OBJ_BASE)/pc;                                             \
135           $(if $(CHECK_FULL),$(RM) -r $(OBJ_BASE)/pkg;,)                       \
136           echo "Done";                                                         \
137           echo ----------------------------------------------------------;     \
138           echo "Trying standalone build of '$$checkpkg'";                      \
139           echo $(MAKE) O=$(OBJ_BASE) --no-print-directory $$checkpkg;          \
140           $(MAKE) O=$(OBJ_BASE) --no-print-directory $$checkpkg                \
141             || (echo "Failed package: $$checkpkg";                             \
142                 echo "Good package(s): CHECK_GOOD=\"$(CHECK_GOOD) $$PKGDONE\"";\
143                 exit 1) || exit 1;                                             \
144           PKGDONE="$$PKGDONE $$checkpkg";                                      \
145         done;                                                                  \
146         echo "Packages     tested: $(CHECK_GOOD) $$PKGDONE"
147
148 depgraph: depsrcgraph depobjgraph
149 depsrcgraph: $(PKGDIR_OBJ)/depsrc.svg $(PKGDIR_OBJ)/depsrc.ps $(PKGDIR_OBJ)/depsrc.reduced.svg $(PKGDIR_OBJ)/depsrc.reduced.ps
150 depobjgraph: $(PKGDIR_OBJ)/depobj.svg $(PKGDIR_OBJ)/depobj.ps $(PKGDIR_OBJ)/depobj.reduced.svg $(PKGDIR_OBJ)/depobj.reduced.ps
151
152 %.ps: %.dot
153         @$(GEN_MESSAGE)
154         $(VERBOSE)dot -Tps -o $@ $<
155
156 %.svg: %.dot
157         @$(GEN_MESSAGE)
158         $(VERBOSE)dot -Tsvg -o $@ $<
159
160 %.reduced.dot: %.dot
161         @$(GEN_MESSAGE)
162         $(VERBOSE)tred $< > $@
163
164 $(PKGDIR_OBJ)/depsrc.dot: FORCE 
165         @$(GEN_MESSAGE)
166         $(VERBOSE)$(PKGDEPS_CMD) dot $(L4DIR)/pkg > $@
167
168 $(PKGDIR_OBJ)/depobj.dot: FORCE
169         @$(GEN_MESSAGE)
170         $(VERBOSE)$(L4DIR)/tool/bin/pkgdepsobj $(L4DIR_ABS) $(OBJ_BASE) $@
171
172 ptest:
173         $(VERBOSE)set -e; \
174         for d in $(BUILD_SUBDIRS); do \
175           if [ -n "$$(find $$d -type d -name $@)" ]; then \
176             $(call PTEST_MESSAGE,$(BID_DOLLARQUOTE)$$d); \
177             PWD=$(PWD)/$$d $(MAKE) -C $$d $@; \
178           fi; \
179         done
180
181 TAGS:
182         $(ETAGS)
183
184 tags:
185         $(CTAGS)
186
187 .PHONY: TAGS tags depsrcgraph depobjgraph depgraph depcheck
188 .PHONY: $(foreach ext, .bin .lib .include .idl .headers,addsuffix $(ext), $(BUILD_SUBDIRS))
189
190 clean cleanall:: BID_cont_reset
191 clean cleanall::
192         $(VERBOSE)$(RM) $(UPDATE_LOG)
193         $(VERBOSE)for i in $(BUILD_SUBDIRS) $(OBSOLETE_SUBDIRS); do \
194           echo "=== Cleaning in package  \"$$i\" ==="; \
195           if [ -r $$i/Makefile ] ; then PWD=$(PWD)/$$i $(MAKE) -C $$i $@; fi ; \
196         done
197         $(VERBOSE)$(MAKE) rm-old-links
198
199 del-backup:
200         $(VERBOSE)rm -i `find . -name "*~"` `find . -name "#*#"`
201
202 rm-old-links:
203         @$(PURGE_INC_MESSAGE)
204         $(VERBOSE)test ! -d $(L4DIR)/include || \
205           find $(L4DIR)/include -type l -a ! -xtype f -a ! -xtype d \
206             -exec rm $(if $(VERBOSE),,-v) '{}' ';'
207         @$(PURGE_LIB_MESSAGE)
208         $(VERBOSE)test ! -d $(L4DIR)/lib || \
209           find $(L4DIR)/lib -type l -a ! -xtype f -a ! -xtype d \
210             -exec rm $(if $(VERBOSE),,-v) '{}' ';'
211
212
213 # Update Makefile on update.
214 ifneq ($(filter update up,$(MAKECMDGOALS)),)
215 .PHONY: Makefile
216 Makefile: update.log
217         $(SVN) up $@ 2>&1 | tee -a $(UPDATE_LOG)
218 endif
219
220 UPDATE_LOG = $(call absfilename, $(L4DIR)/pkg/update.log)
221 .PHONY: update.log
222 update.log:
223         $(VERBOSE)$(RM) $(UPDATE_LOG)
224
225 update up: update.log
226         $(VERBOSE)$(call UPDATE_MESSAGE,Packages)
227         $(VERBOSE)set -e; \
228           $(SVN) update $(ALL_SUBDIRS) 2>&1 | tee -a $(UPDATE_LOG)
229
230 # global defines
231
232 .PHONY: install clean cleanall kernels
233
234
235 print-subdirs:
236         @echo $(BUILD_SUBDIRS)
237         @echo obsolete: $(OBSOLETE_SUBDIRS)
238         @echo broken: $(BROKEN_SUBDIRS)
239
240 help:
241         @echo "Specify one of the following targets:"
242         @echo "all             - build the packages neither broken nor obsolete"
243         @echo " Use make S=dir1:dir2:..: to build those directories"
244         @echo "cont            - after correcting errors, continue where \"make all\" failed"
245         @echo "<pkgname>       - Build package and all its dependencies"
246 #       @echo "doc             - build documentation (not build per default)"
247         @echo "install         - install the packages, use only after making all!"
248         @echo
249         @echo "clean           - clean the packages"
250         @echo "cleanall        - clean the packages pedanticly"
251         @echo "del-backup      - remove temporary file in this tree"
252         @echo "print-subdirs   - print the SUBDIRS which are subject to build"
253         @echo "BID_cont_reset  - reset the state used by the \"cont\" target"
254         @echo 'rm-old-links    - remove invalid symlinks in $$(L4DIR)/lib, $$(L4DIR)/include'
255         @echo "update          - update the packages currently checked out"
256         @echo "help            - this help"
257
258 #####################
259 # cont handling: "cont" is in the target list
260 else
261 -include $(BID_STATE_FILE)
262 cont:
263         $(VERBOSE)$(MAKE) $(addprefix -o ,BID_cont_reset $(BID_STATE_DONE)) \
264                 $(filter-out cont,$(MAKECMDGOALS))
265
266 # eat up the other targets
267 .DEFAULT:
268         @true
269 endif 
270