# GLOBAL Makefile for all packages # # DO NOT EDIT -- Automatically generated by Adam's configuration system!!! # IGNORE_OBJDIR_TARGETS := up update diff L4DIR ?= .. include $(L4DIR)/mk/Makeconf BID_STATE_FILE = $(OBJ_BASE)/pkg/BUILD.state # all our packages ALL_SUBDIRS = $(shell find -L . -maxdepth 1 -type d ! -name .svn -printf %P' ') ifneq ($(S),) ALL_SUBDIRS := $(shell echo $(S) | tr ':,' ' ') endif # the broken packages BROKEN_SUBDIRS = $(patsubst %/broken, %, \ $(wildcard $(addsuffix /broken,$(ALL_SUBDIRS)))) # the obsolete packages OBSOLETE_SUBDIRS = $(patsubst %/obsolete, %, \ $(wildcard $(addsuffix /obsolete,$(ALL_SUBDIRS)))) # and the packages we are supposed to build BUILD_SUBDIRS = $(filter-out $(BROKEN_SUBDIRS) $(OBSOLETE_SUBDIRS), \ $(ALL_SUBDIRS)) # force that every package to be built has a Control and Makefile ifneq ($(addsuffix /Makefile,$(BUILD_SUBDIRS)),$(wildcard $(addsuffix /Makefile,$(BUILD_SUBDIRS)))) $(error Missing Makefile files: $(filter-out $(wildcard $(addsuffix /Makefile,$(BUILD_SUBDIRS))), $(addsuffix /Makefile,$(BUILD_SUBDIRS)))) endif ifeq ($(S),) ifneq ($(addsuffix /Control,$(BUILD_SUBDIRS)),$(wildcard $(addsuffix /Control,$(BUILD_SUBDIRS)))) $(error Missing Control files: $(filter-out $(wildcard $(addsuffix /Control,$(BUILD_SUBDIRS))), $(addsuffix /Control,$(BUILD_SUBDIRS)))) endif endif ##################### # Rules begin. # We start with cont-checking, as this requires special treatment ifeq ($(filter cont,$(MAKECMDGOALS)),) ##################### # default make action is "all" - build all packages # # We build all l4env headers (idl+includes), then all l4env libs, then the # l4env servers and examples. Then we build the other headers # (idl+includes), the other libs, the other servers and examples. We use # dependencies for this, witch might allow parallel build processes. # all:: $(BUILD_SUBDIRS) examples: $(filter-out examples,$(BUILD_SUBDIRS)) ##################### # cont handling -include $(BID_STATE_FILE) BID_cont_reset: $(VERBOSE)$(RM) $(BID_STATE_FILE) BID_SAFE_STATE= @echo 'BID_STATE_DONE+=$@'>>$(BID_STATE_FILE) .PHONY: all BID_cont_reset cont bin lib headers idl include doc ptest .PHONY: rm-old-links DOC_MESSAGE =echo "=== Creating documentation for package \"$(1)\" ===" PKG_MESSAGE =echo "=== Building package \"$(basename $@)\" ===" INST_MESSAGE =echo "=== Installing Package \"$(1)\" ===" PURGE_INC_MESSAGE =echo "=== Purging pending links in $(L4DIR)/include ===" PURGE_LIB_MESSAGE =echo "=== Purging pending links in $(L4DIR)/lib ===" UPDATE_MESSAGE =echo -e $(EMPHSTART)"=== Updating \"$(1)\" ==="$(EMPHSTOP) DIFF_MESSAGE =echo -e $(EMPHSTART)"=== Diffing \"$(1)\" ==="$(EMPHSTOP) PTEST_MESSAGE =echo "=== Testing Package \"$(1)\" ===" # given order matters ALIASES_DIRS = $(L4DIR)/mk/aliases.d \ $(wildcard $(OBJ_BASE)/aliases.d) PKGDEPS_CMD = $(L4DIR)/mk/pkgdeps \ -P $(OBJ_BASE)/pc $(addprefix -A ,$(ALIASES_DIRS)) ifneq ($(OBJ_BASE),) $(OBJ_BASE)/pc: $(VERBOSE)mkdir -p $(OBJ_BASE)/pc # deps on disappearing aliases.d-files are not handled... $(OBJ_BASE)/pkg/.Package.deps: $(L4DIR)/mk/pkgdeps \ $(if $(filter update up,$(MAKECMDGOALS)),,Makefile) \ $(wildcard $(foreach d,$(ALIASES_DIRS),$(d)/*)) \ $(OBJ_BASE)/pc \ $(wildcard $(foreach d,$(BUILD_SUBDIRS),$(d)/Control)) $(VERBOSE)mkdir -p $(dir $@) $(VERBOSE)if $(PKGDEPS_CMD) \ generate $(L4DIR)/pkg > $@.tmp; then \ mv $@.tmp $@; else $(RM) $@.tmp; exit 1; fi include $(OBJ_BASE)/pkg/.Package.deps endif $(BUILD_SUBDIRS):%:%/Makefile BID_cont_reset @$(PKG_MESSAGE) $(VERBOSE)PWD=$(PWD)/$(basename $@) $(MAKE) -C $(basename $@) all $(VERBOSE)$(BID_SAFE_STATE) install:: $(VERBOSE)set -e; for i in $(BUILD_SUBDIRS); do \ $(call INST_MESSAGE,$(BID_DOLLARQUOTE)$$i); \ PWD=$(PWD)/$$i $(MAKE) -C $$i $@; \ done doc: $(VERBOSE)set -e; for i in $(BUILD_SUBDIRS); do \ if [ -e $(PWD)/$$i/doc ]; then \ $(call DOC_MESSAGE,$(BID_DOLLARQUOTE)$$i); \ PWD=$(PWD)/$$i $(MAKE) -C $$i $@; \ fi; \ done # Check package dependencies. # CHECK_PKGS: if undefined, check all packages, # otherwise gives a list of space separated packages to check # CHECK_FULL: if set rebuild for every new package check # (ccache recommended when using this flag) depcheck: $(VERBOSE)set -e; \ $(RM) -r $(filter-out $(OBJ_BASE)/pkg/Makefile, \ $(wildcard $(OBJ_BASE)/pkg/*)); \ for checkpkg in $(filter-out $(CHECK_GOOD),$(if $(CHECK_PKGS),$(CHECK_PKGS),$(BUILD_SUBDIRS))); do \ echo ==========================================================; \ echo "Deleting all pkgs in build-dir"; \ $(RM) -r $(OBJ_BASE)/lib $(OBJ_BASE)/bin $(OBJ_BASE)/include \ $(OBJ_BASE)/pc $(OBJ_BASE)/pkg/.Package.deps; \ $(if $(CHECK_FULL),$(RM) -r $(OBJ_BASE)/pkg;,) \ echo "Done"; \ echo ----------------------------------------------------------; \ echo "Trying standalone build of '$$checkpkg'"; \ echo $(MAKE) O=$(OBJ_BASE) --no-print-directory $$checkpkg; \ $(MAKE) O=$(OBJ_BASE) --no-print-directory $$checkpkg \ || (echo "Failed package: $$checkpkg"; \ echo "Good package(s): CHECK_GOOD=\"$(CHECK_GOOD) $$PKGDONE\"";\ exit 1) || exit 1; \ PKGDONE="$$PKGDONE $$checkpkg"; \ done; \ echo "Packages tested: $(CHECK_GOOD) $$PKGDONE" depgraph: depsrcgraph depobjgraph depsrcgraph: $(PKGDIR_OBJ)/depsrc.svg $(PKGDIR_OBJ)/depsrc.ps $(PKGDIR_OBJ)/depsrc.reduced.svg $(PKGDIR_OBJ)/depsrc.reduced.ps depobjgraph: $(PKGDIR_OBJ)/depobj.svg $(PKGDIR_OBJ)/depobj.ps $(PKGDIR_OBJ)/depobj.reduced.svg $(PKGDIR_OBJ)/depobj.reduced.ps %.ps: %.dot @$(GEN_MESSAGE) $(VERBOSE)dot -Tps -o $@ $< %.svg: %.dot @$(GEN_MESSAGE) $(VERBOSE)dot -Tsvg -o $@ $< %.reduced.dot: %.dot @$(GEN_MESSAGE) $(VERBOSE)tred $< > $@ $(PKGDIR_OBJ)/depsrc.dot: FORCE @$(GEN_MESSAGE) $(VERBOSE)$(PKGDEPS_CMD) dot $(L4DIR)/pkg > $@ $(PKGDIR_OBJ)/depobj.dot: FORCE @$(GEN_MESSAGE) $(VERBOSE)$(L4DIR)/tool/bin/pkgdepsobj $(L4DIR_ABS) $(OBJ_BASE) $@ ptest: $(VERBOSE)set -e; \ for d in $(BUILD_SUBDIRS); do \ if [ -n "$$(find $$d -type d -name $@)" ]; then \ $(call PTEST_MESSAGE,$(BID_DOLLARQUOTE)$$d); \ PWD=$(PWD)/$$d $(MAKE) -C $$d $@; \ fi; \ done TAGS: $(ETAGS) tags: $(CTAGS) .PHONY: TAGS tags depsrcgraph depobjgraph depgraph depcheck .PHONY: $(foreach ext, .bin .lib .include .idl .headers,addsuffix $(ext), $(BUILD_SUBDIRS)) clean cleanall:: BID_cont_reset clean cleanall:: $(VERBOSE)$(RM) $(UPDATE_LOG) $(VERBOSE)for i in $(BUILD_SUBDIRS) $(OBSOLETE_SUBDIRS); do \ echo "=== Cleaning in package \"$$i\" ==="; \ if [ -r $$i/Makefile ] ; then PWD=$(PWD)/$$i $(MAKE) -C $$i $@; fi ; \ done $(VERBOSE)$(MAKE) rm-old-links del-backup: $(VERBOSE)rm -i `find . -name "*~"` `find . -name "#*#"` rm-old-links: @$(PURGE_INC_MESSAGE) $(VERBOSE)test ! -d $(L4DIR)/include || \ find $(L4DIR)/include -type l -a ! -xtype f -a ! -xtype d \ -exec rm $(if $(VERBOSE),,-v) '{}' ';' @$(PURGE_LIB_MESSAGE) $(VERBOSE)test ! -d $(L4DIR)/lib || \ find $(L4DIR)/lib -type l -a ! -xtype f -a ! -xtype d \ -exec rm $(if $(VERBOSE),,-v) '{}' ';' # Update Makefile on update. ifneq ($(filter update up,$(MAKECMDGOALS)),) .PHONY: Makefile Makefile: update.log $(SVN) up $@ 2>&1 | tee -a $(UPDATE_LOG) endif UPDATE_LOG = $(call absfilename, $(L4DIR)/pkg/update.log) .PHONY: update.log update.log: $(VERBOSE)$(RM) $(UPDATE_LOG) update up: update.log $(VERBOSE)$(call UPDATE_MESSAGE,Packages) $(VERBOSE)set -e; \ $(SVN) update $(ALL_SUBDIRS) 2>&1 | tee -a $(UPDATE_LOG) # global defines .PHONY: install clean cleanall kernels print-subdirs: @echo $(BUILD_SUBDIRS) @echo obsolete: $(OBSOLETE_SUBDIRS) @echo broken: $(BROKEN_SUBDIRS) help: @echo "Specify one of the following targets:" @echo "all - build the packages neither broken nor obsolete" @echo " Use make S=dir1:dir2:..: to build those directories" @echo "cont - after correcting errors, continue where \"make all\" failed" @echo " - Build package and all its dependencies" # @echo "doc - build documentation (not build per default)" @echo "install - install the packages, use only after making all!" @echo @echo "clean - clean the packages" @echo "cleanall - clean the packages pedanticly" @echo "del-backup - remove temporary file in this tree" @echo "print-subdirs - print the SUBDIRS which are subject to build" @echo "BID_cont_reset - reset the state used by the \"cont\" target" @echo 'rm-old-links - remove invalid symlinks in $$(L4DIR)/lib, $$(L4DIR)/include' @echo "update - update the packages currently checked out" @echo "help - this help" ##################### # cont handling: "cont" is in the target list else -include $(BID_STATE_FILE) cont: $(VERBOSE)$(MAKE) $(addprefix -o ,BID_cont_reset $(BID_STATE_DONE)) \ $(filter-out cont,$(MAKECMDGOALS)) # eat up the other targets .DEFAULT: @true endif